-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoreilly-annotations.csv
We can't make this file beautiful and searchable because it's too large.
3202 lines (2868 loc) · 1000 KB
/
oreilly-annotations.csv
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
Book Title,Chapter Title,Date of Highlight,Book URL,Chapter URL,Annotation URL,Highlight,Personal Note
Monolith to Microservices,5. Growing Pains,2021-11-17,https://learning.oreilly.com/library/view/-/9781492047834/,https://learning.oreilly.com/library/view/-/9781492047834/ch05.html,https://learning.oreilly.com/library/view/-/9781492047834/ch05.html#3c5bbfca-42c2-49c6-8981-60df37139169,Collective code ownership,
Monolith to Microservices,5. Growing Pains,2021-11-17,https://learning.oreilly.com/library/view/-/9781492047834/,https://learning.oreilly.com/library/view/-/9781492047834/ch05.html,https://learning.oreilly.com/library/view/-/9781492047834/ch05.html#906125fd-ab69-4e0f-a649-f5c7240187e0,Weak code ownership,
Monolith to Microservices,5. Growing Pains,2021-11-17,https://learning.oreilly.com/library/view/-/9781492047834/,https://learning.oreilly.com/library/view/-/9781492047834/ch05.html,https://learning.oreilly.com/library/view/-/9781492047834/ch05.html#b44ab7f3-b7f4-43f2-93bc-b9a5d82cc9d1,Strong code ownership,
Monolith to Microservices,5. Growing Pains,2021-11-17,https://learning.oreilly.com/library/view/-/9781492047834/,https://learning.oreilly.com/library/view/-/9781492047834/ch05.html,https://learning.oreilly.com/library/view/-/9781492047834/ch05.html#9a429a5c-bd6d-4144-af30-7479b7a6481b,"let’s first take a look at the concepts Martin outlines, and put them in the context of microservice architecture:",
Monolith to Microservices,5. Growing Pains,2021-11-17,https://learning.oreilly.com/library/view/-/9781492047834/,https://learning.oreilly.com/library/view/-/9781492047834/ch05.html,https://learning.oreilly.com/library/view/-/9781492047834/ch05.html#c83ea265-958e-4b90-a3d3-c5593f31dd11,Figure 5-1 roughly maps the pain points we’ll cover in the rest of this chapter based on where in your service growth these issues are most likely to arise,
Monolith to Microservices,5. Growing Pains,2021-11-17,https://learning.oreilly.com/library/view/-/9781492047834/,https://learning.oreilly.com/library/view/-/9781492047834/ch05.html,https://learning.oreilly.com/library/view/-/9781492047834/ch05.html#1e549312-7c56-468c-966d-c481f03d6d79,"What I’m hoping to do with this chapter is give you just enough information about the sorts of issues you may face. I can’t solve them all in this book, and many of the problems I outline here already have a more detailed treatment in Building Microservices, which was very much written with these challenges in mind.",
Monolith to Microservices,4. Decomposing the Database,2021-11-17,https://learning.oreilly.com/library/view/-/9781492047834/,https://learning.oreilly.com/library/view/-/9781492047834/ch04.html,https://learning.oreilly.com/library/view/-/9781492047834/ch04.html#a5a23395-2551-4dc4-9cbc-eb3457b60737,"Splitting the Database First, or the Code?
So far, we’ve spoken about patterns to help work with shared databases, and hopefully move on to less coupled models. In a moment, we need to look in detail at patterns around database decomposition. Before we do that, though, we need to discuss sequencing. Extracting a microservice isn’t “done” until the application code is running in its own service, and the data it controls is extracted into its own logically isolated database. But with this being a book largely about enabling incremental change, we have to explore a little how this extraction should be sequenced. We have a few options:
Split the database first, then the code.
Split the code first, then the database.
Split them both at once.",
Monolith to Microservices,3. Splitting the Monolith,2021-11-17,https://learning.oreilly.com/library/view/-/9781492047834/,https://learning.oreilly.com/library/view/-/9781492047834/ch03.html,https://learning.oreilly.com/library/view/-/9781492047834/ch03.html#fecbffcc-c041-48d1-b4a6-08c8cc07977d,"Pattern: Change Data Capture
With change data capture, rather than trying to intercept and act on calls made into the monolith, we react to changes made in a datastore. For change data capture to work, the underlying capture system has to be coupled to the monolith’s datastore. That’s really an unavoidable challenge with this pattern.",
Monolith to Microservices,3. Splitting the Monolith,2021-11-17,https://learning.oreilly.com/library/view/-/9781492047834/,https://learning.oreilly.com/library/view/-/9781492047834/ch03.html,https://learning.oreilly.com/library/view/-/9781492047834/ch03.html#71595d2e-7ceb-4198-af72-1f16e7a36120,Pattern: Decorating Collaborator,
Monolith to Microservices,3. Splitting the Monolith,2021-11-17,https://learning.oreilly.com/library/view/-/9781492047834/,https://learning.oreilly.com/library/view/-/9781492047834/ch03.html,https://learning.oreilly.com/library/view/-/9781492047834/ch03.html#7541c8d6-fd41-484f-90ef-4f3c2d2b8ad1,Pattern: Parallel Run,
Monolith to Microservices,3. Splitting the Monolith,2021-11-17,https://learning.oreilly.com/library/view/-/9781492047834/,https://learning.oreilly.com/library/view/-/9781492047834/ch03.html,https://learning.oreilly.com/library/view/-/9781492047834/ch03.html#51023c38-4219-408d-8939-7cc5f268812e,Pattern: Branch by Abstraction,
Monolith to Microservices,3. Splitting the Monolith,2021-11-17,https://learning.oreilly.com/library/view/-/9781492047834/,https://learning.oreilly.com/library/view/-/9781492047834/ch03.html,https://learning.oreilly.com/library/view/-/9781492047834/ch03.html#13a0e8b9-ce7f-4570-b8db-58714f3acad3,Pattern: UI Composition,
Monolith to Microservices,2. Planning a Migration,2021-11-17,https://learning.oreilly.com/library/view/-/9781492047834/,https://learning.oreilly.com/library/view/-/9781492047834/ch02.html,https://learning.oreilly.com/library/view/-/9781492047834/ch02.html#1e6e8c5b-dad6-4cf7-97b7-a8b00efeba03,Figure 2-7. A simple two-axis model for prioritizing service decomposition,
Monolith to Microservices,2. Planning a Migration,2021-11-17,https://learning.oreilly.com/library/view/-/9781492047834/,https://learning.oreilly.com/library/view/-/9781492047834/ch02.html,https://learning.oreilly.com/library/view/-/9781492047834/ch02.html#e6aefeab-9ba5-4074-be8d-f0e194a23b60,"Based on the number of upstream or downstream dependencies, we can extrapolate a view regarding which functionality is likely to be easier—or harder—to extract",
Monolith to Microservices,2. Planning a Migration,2021-11-17,https://learning.oreilly.com/library/view/-/9781492047834/,https://learning.oreilly.com/library/view/-/9781492047834/ch02.html,https://learning.oreilly.com/library/view/-/9781492047834/ch02.html#1273df7b-05b4-4101-a1aa-b4a21e8d2c19,"If it takes too long for people to see progress being made, they’ll lose faith in the vision. So go for some quick wins. Focusing initially on small, easy, low-hanging fruit will help build momentum. When it comes to microservice decomposition, functionality that can easily be extracted from our monolith should be high on your list.",
Monolith to Microservices,1. Just Enough Microservices,2021-10-04,https://learning.oreilly.com/library/view/-/9781492047834/,https://learning.oreilly.com/library/view/-/9781492047834/ch01.html,https://learning.oreilly.com/library/view/-/9781492047834/ch01.html#8dd0b89d-8a2f-4144-86b9-5613e61b4a97,"Mapping Aggregates and Bounded Contexts to Microservices
Both the aggregate and the bounded context give us units of cohesion with well-defined interfaces with the wider system. The aggregate is a self-contained state machine that focuses on a single domain concept in our system, with the bounded context representing a collection of associated aggregates, again with an explicit interface to the wider world.",
Monolith to Microservices,1. Just Enough Microservices,2021-10-04,https://learning.oreilly.com/library/view/-/9781492047834/,https://learning.oreilly.com/library/view/-/9781492047834/ch01.html,https://learning.oreilly.com/library/view/-/9781492047834/ch01.html#053c51d1-ceff-4591-ad40-b55dc4cfd541,"A bounded context typically represents a larger organizational boundary inside an organization. Within the scope of that boundary, explicit responsibilities need to be carried out.",
Monolith to Microservices,1. Just Enough Microservices,2021-10-04,https://learning.oreilly.com/library/view/-/9781492047834/,https://learning.oreilly.com/library/view/-/9781492047834/ch01.html,https://learning.oreilly.com/library/view/-/9781492047834/ch01.html#864f647d-9ad8-4fd3-80f0-bb662e817db2,"Coupling speaks to how changing one thing requires a change in another; cohesion talks to how we group related code. These concepts are directly linked. Constantine’s law articulates this relationship well:
A structure is stable if cohesion is high, and coupling is low.
Larry Constantine",Identify coupling and cohesion goals
Monolith to Microservices,1. Just Enough Microservices,2021-10-04,https://learning.oreilly.com/library/view/-/9781492047834/,https://learning.oreilly.com/library/view/-/9781492047834/ch01.html,https://learning.oreilly.com/library/view/-/9781492047834/ch01.html#ca2ee9c1-e1db-4d4d-b841-3b937189ce95,incremental migration to a microservice architecture.,
Monolith to Microservices,1. Just Enough Microservices,2021-10-04,https://learning.oreilly.com/library/view/-/9781492047834/,https://learning.oreilly.com/library/view/-/9781492047834/ch01.html,https://learning.oreilly.com/library/view/-/9781492047834/ch01.html#84931b2c-46cd-4347-a418-aa12028a1303,"Don’t share databases, unless you really have to. And even then do everything you can to avoid it. In my opinion, it’s one of the worst things you can do if you’re trying to achieve independent deployability.",
Monolith to Microservices,1. Just Enough Microservices,2021-10-04,https://learning.oreilly.com/library/view/-/9781492047834/,https://learning.oreilly.com/library/view/-/9781492047834/ch01.html,https://learning.oreilly.com/library/view/-/9781492047834/ch01.html#deaa99a6-5839-4c5e-9da8-45c0e8cb6087,"Our business domain becomes the primary force driving our system architecture, hopefully making it easier to make changes, and making it easier for us to organize our teams around our business domain",
Monolith to Microservices,1. Just Enough Microservices,2021-10-04,https://learning.oreilly.com/library/view/-/9781492047834/,https://learning.oreilly.com/library/view/-/9781492047834/ch01.html,https://learning.oreilly.com/library/view/-/9781492047834/ch01.html#10c6fff5-5772-4205-8bf4-8acc97d92834,"To guarantee independent deployability, we need to ensure our services are loosely coupled",
Monolith to Microservices,1. Just Enough Microservices,2021-10-04,https://learning.oreilly.com/library/view/-/9781492047834/,https://learning.oreilly.com/library/view/-/9781492047834/ch01.html,https://learning.oreilly.com/library/view/-/9781492047834/ch01.html#3dd25439-78b2-436f-97ae-e8ec136bbd0f,"Independent deployability is the idea that we can make a change to a microservice and deploy it into a production environment without having to utilize any other services. More importantly, it’s not just that we can do this; it’s that this is actually how you manage deployments in your system",
Monolith to Microservices,1. Just Enough Microservices,2021-10-04,https://learning.oreilly.com/library/view/-/9781492047834/,https://learning.oreilly.com/library/view/-/9781492047834/ch01.html,https://learning.oreilly.com/library/view/-/9781492047834/ch01.html#5088fe15-d824-4473-9f16-c826932d816a,Microservices are independently deployable services modeled around a business domain.,
Monolith to Microservices,3. Splitting the Monolith,2021-10-04,https://learning.oreilly.com/library/view/-/9781492047834/,https://learning.oreilly.com/library/view/-/9781492047834/ch03.html,https://learning.oreilly.com/library/view/-/9781492047834/ch03.html#e56aef48-36a2-4ada-bcac-72e5b0157e3c,a variety of migration patterns and tips that can help you adopt a microservice architecture,
Monolith to Microservices,2. Planning a Migration,2021-10-04,https://learning.oreilly.com/library/view/-/9781492047834/,https://learning.oreilly.com/library/view/-/9781492047834/ch02.html,https://learning.oreilly.com/library/view/-/9781492047834/ch02.html#0367f3b4-4f75-4cd2-8ab0-95c9b9551e25,"Figure 2-11. An example skills chart, showing those areas that I want to improve",Copy
Monolith to Microservices,2. Planning a Migration,2021-10-04,https://learning.oreilly.com/library/view/-/9781492047834/,https://learning.oreilly.com/library/view/-/9781492047834/ch02.html,https://learning.oreilly.com/library/view/-/9781492047834/ch02.html#9187ecd1-99f4-4264-a34b-2f2a996d020b,Figure 2-8. An example of the prioritization quadrant in use,Copy
Monolith to Microservices,2. Planning a Migration,2021-10-04,https://learning.oreilly.com/library/view/-/9781492047834/,https://learning.oreilly.com/library/view/-/9781492047834/ch02.html,https://learning.oreilly.com/library/view/-/9781492047834/ch02.html#85b4fe14-c2f5-4c87-8e74-e9a8b6b677d5,"When assessing likely difficulty of extraction, these relationships are a good way to start, but we have to understand that this domain model represents a logical view of an existing system. There is no guarantee that the underlying code structure of our monolith is structured in this way. This means that our logical model can help guide us in terms of pieces of functionality that are likely to be more (or less) coupled, but we may still need to look at the code itself to get a better assessment of the degree of entanglement of the current functionality.",
Monolith to Microservices,2. Planning a Migration,2021-10-04,https://learning.oreilly.com/library/view/-/9781492047834/,https://learning.oreilly.com/library/view/-/9781492047834/ch02.html,https://learning.oreilly.com/library/view/-/9781492047834/ch02.html#69eee1a2-8f55-41f2-8955-73744887d712,"It’s important to note that Event Storming doesn’t mean you have to then build an event-driven system. Instead, it focuses on understanding what (logical) events occur in the system—identifying the facts that you care about as a stakeholder of the system. These domain events can map to events fired as part of an event-driven system, but they could be represented in different ways.",
Monolith to Microservices,2. Planning a Migration,2021-10-04,https://learning.oreilly.com/library/view/-/9781492047834/,https://learning.oreilly.com/library/view/-/9781492047834/ch02.html,https://learning.oreilly.com/library/view/-/9781492047834/ch02.html#d77e7ef6-ec94-43d6-b56b-f4fee811da24,"Event Storming, created by Alberto Brandolini, is a collaborative exercise involving technical and nontechnical stakeholders who together define a shared domain model. Event Storming works from the bottom up. Participants start by defining the “Domain Events”—things that happen in the system. Then these events are grouped into aggregates, and the aggregates are then grouped into bounded contexts.",
Monolith to Microservices,2. Planning a Migration,2021-10-04,https://learning.oreilly.com/library/view/-/9781492047834/,https://learning.oreilly.com/library/view/-/9781492047834/ch02.html,https://learning.oreilly.com/library/view/-/9781492047834/ch02.html#65e87a4c-7ee4-4c27-b167-c0e5cc9d6489,"Each of these bounded contexts represents a potential unit of decomposition. As we discussed previously, bounded contexts make great starting points for defining microservice boundaries",
Monolith to Microservices,2. Planning a Migration,2021-10-04,https://learning.oreilly.com/library/view/-/9781492047834/,https://learning.oreilly.com/library/view/-/9781492047834/ch02.html,https://learning.oreilly.com/library/view/-/9781492047834/ch02.html#66e21425-2f01-4b95-add2-c027f1dc3664,"When it comes to decomposing an existing monolithic system, we need to have some form of logical decomposition to work with, and this is where domain-driven design can come in handy.",
Monolith to Microservices,2. Planning a Migration,2021-10-04,https://learning.oreilly.com/library/view/-/9781492047834/,https://learning.oreilly.com/library/view/-/9781492047834/ch02.html,https://learning.oreilly.com/library/view/-/9781492047834/ch02.html#970606ac-edbe-4d5c-91e8-0e0ed803de38,"Cost of Change
There are many reasons why, throughout the book, I promote the need to make small, incremental changes, but one of the key drivers is to understand the impact of each alteration we make and change course if required. This allows us to better mitigate the cost of mistakes, but doesn’t remove the chance of mistakes entirely",
Monolith to Microservices,2. Planning a Migration,2021-10-04,https://learning.oreilly.com/library/view/-/9781492047834/,https://learning.oreilly.com/library/view/-/9781492047834/ch02.html,https://learning.oreilly.com/library/view/-/9781492047834/ch02.html#13cf2987-0056-45c4-a14b-ddd1f076db81,"An incremental approach will help you learn about microservices as you go, and will also limit the impact of getting something wrong (and you will get things wrong!).",
Monolith to Microservices,2. Planning a Migration,2021-10-04,https://learning.oreilly.com/library/view/-/9781492047834/,https://learning.oreilly.com/library/view/-/9781492047834/ch02.html,https://learning.oreilly.com/library/view/-/9781492047834/ch02.html#831abb03-abdb-4ef2-a1b1-b76472f890c7,The reason that program even got started was because of previous endeavors by what we would now call a community of practice (a “Grouplet” in Google nomenclature) to help share the importance of automated testing,
Monolith to Microservices,2. Planning a Migration,2021-10-04,https://learning.oreilly.com/library/view/-/9781492047834/,https://learning.oreilly.com/library/view/-/9781492047834/ch02.html,https://learning.oreilly.com/library/view/-/9781492047834/ch02.html#459a344c-71af-4f6b-8eb2-1e156d2d8e3a,Figure 2-2. Kotter’s eight-step process for making organizational change,Copy
Monolith to Microservices,2. Planning a Migration,2021-10-04,https://learning.oreilly.com/library/view/-/9781492047834/,https://learning.oreilly.com/library/view/-/9781492047834/ch02.html,https://learning.oreilly.com/library/view/-/9781492047834/ch02.html#4aba557f-e751-40e2-bf4f-6e59770fb82a,"Prematurely decomposing a system into microservices can be costly, especially if you are new to the domain. In many ways, having an existing codebase you want to decompose into microservices is much easier than trying to go to microservices from the beginning.",
Monolith to Microservices,2. Planning a Migration,2021-10-04,https://learning.oreilly.com/library/view/-/9781492047834/,https://learning.oreilly.com/library/view/-/9781492047834/ch02.html,https://learning.oreilly.com/library/view/-/9781492047834/ch02.html#f90acb6e-1ba8-4b6e-85bc-963831a02e3a,Unclear Domain,
Monolith to Microservices,2. Planning a Migration,2021-10-04,https://learning.oreilly.com/library/view/-/9781492047834/,https://learning.oreilly.com/library/view/-/9781492047834/ch02.html,https://learning.oreilly.com/library/view/-/9781492047834/ch02.html#d28217e5-c685-4553-af63-2d19283b9861,When Might Microservices Be a Bad Idea?,
Monolith to Microservices,2. Planning a Migration,2021-10-04,https://learning.oreilly.com/library/view/-/9781492047834/,https://learning.oreilly.com/library/view/-/9781492047834/ch02.html,https://learning.oreilly.com/library/view/-/9781492047834/ch02.html#1389635b-73ea-40a9-b76a-04aef0ff5090,"By isolating the technology change in one service boundary, we can understand the benefits of the new technology in isolation, and limit the impact if the technology turns out to have issues.",
Monolith to Microservices,2. Planning a Migration,2021-10-04,https://learning.oreilly.com/library/view/-/9781492047834/,https://learning.oreilly.com/library/view/-/9781492047834/ch02.html,https://learning.oreilly.com/library/view/-/9781492047834/ch02.html#8747f9b6-382a-4e06-b7ca-4a2974c6b1bd,Embrace New Technology,
Monolith to Microservices,2. Planning a Migration,2021-10-04,https://learning.oreilly.com/library/view/-/9781492047834/,https://learning.oreilly.com/library/view/-/9781492047834/ch02.html,https://learning.oreilly.com/library/view/-/9781492047834/ch02.html#fc5598ed-c693-431e-b857-a85b01c6065e,"With clearly identified boundaries, and an architecture that has focused around ensuring our microservices limit their coupling with each other, we come up with pieces of code that can be worked on independently. Therefore, we hope we can scale the number of developers by reducing the delivery contention.",
Monolith to Microservices,2. Planning a Migration,2021-10-04,https://learning.oreilly.com/library/view/-/9781492047834/,https://learning.oreilly.com/library/view/-/9781492047834/ch02.html,https://learning.oreilly.com/library/view/-/9781492047834/ch02.html#d96642e4-bf1d-4ee0-acb3-efbefb497566,Scale the Number of Developers,
Monolith to Microservices,2. Planning a Migration,2021-10-04,https://learning.oreilly.com/library/view/-/9781492047834/,https://learning.oreilly.com/library/view/-/9781492047834/ch02.html,https://learning.oreilly.com/library/view/-/9781492047834/ch02.html#1d3cf64c-60f0-47b0-a5f6-2b77c5cd09ab,"Robustness is the ability to have a system that is able to react to expected variations. Resilience is having an organization capable of adapting to things that haven’t been thought of, which could well include creating a culture of experimentation through things like chaos engineering.",
Monolith to Microservices,2. Planning a Migration,2021-10-04,https://learning.oreilly.com/library/view/-/9781492047834/,https://learning.oreilly.com/library/view/-/9781492047834/ch02.html,https://learning.oreilly.com/library/view/-/9781492047834/ch02.html#1c22a833-1e12-4d78-a045-01e4347b67b6,"By breaking our application into individual, independently deployable processes, we open up a host of mechanisms to improve the robustness of our applications.",
Monolith to Microservices,2. Planning a Migration,2021-10-04,https://learning.oreilly.com/library/view/-/9781492047834/,https://learning.oreilly.com/library/view/-/9781492047834/ch02.html,https://learning.oreilly.com/library/view/-/9781492047834/ch02.html#b3ef510b-49a0-46a1-88e3-e7d21630d025,Improve Robustness,
Monolith to Microservices,2. Planning a Migration,2021-10-04,https://learning.oreilly.com/library/view/-/9781492047834/,https://learning.oreilly.com/library/view/-/9781492047834/ch02.html,https://learning.oreilly.com/library/view/-/9781492047834/ch02.html#8b3a5418-a046-4b06-ac76-27ba83e25102,"Scale Cost-Effectively for Load
By breaking our processing into individual microservices, these processes can be scaled independently. This means we can also hopefully cost-effectively scale—we need to scale up only those parts of our processing that are currently constraining our ability to handle load. It also follows that we can then scale down those microservices that are under less load, perhaps even turning them off when not required.",
Monolith to Microservices,2. Planning a Migration,2021-10-04,https://learning.oreilly.com/library/view/-/9781492047834/,https://learning.oreilly.com/library/view/-/9781492047834/ch02.html,https://learning.oreilly.com/library/view/-/9781492047834/ch02.html#8ea759b8-e5fb-44d3-bc8d-3583a45012e1,"By being able to make and deploy changes to individual microservices, and deploy these changes without having to wait for coordinated releases, we have the potential to release functionality to our customers more quickly",
Monolith to Microservices,2. Planning a Migration,2021-10-04,https://learning.oreilly.com/library/view/-/9781492047834/,https://learning.oreilly.com/library/view/-/9781492047834/ch02.html,https://learning.oreilly.com/library/view/-/9781492047834/ch02.html#51f53a52-102b-41cd-9b4e-02e8b13f9603,Reduce Time to Market,
Monolith to Microservices,2. Planning a Migration,2021-10-04,https://learning.oreilly.com/library/view/-/9781492047834/,https://learning.oreilly.com/library/view/-/9781492047834/ch02.html,https://learning.oreilly.com/library/view/-/9781492047834/ch02.html#d5bbc8ec-c8fa-417b-834e-7f4b95c10d05,"If done right, team autonomy can empower people, help them step up and grow, and get the job done faster. When teams own microservices, and have full control over those services, they increase the amount of autonomy they can have within a larger organization.",
Monolith to Microservices,2. Planning a Migration,2021-10-04,https://learning.oreilly.com/library/view/-/9781492047834/,https://learning.oreilly.com/library/view/-/9781492047834/ch02.html,https://learning.oreilly.com/library/view/-/9781492047834/ch02.html#e7a96f2f-e26e-4f3e-a8f7-dc8e3cc834a7,Improve Team Autonomy,
Monolith to Microservices,2. Planning a Migration,2021-10-04,https://learning.oreilly.com/library/view/-/9781492047834/,https://learning.oreilly.com/library/view/-/9781492047834/ch02.html,https://learning.oreilly.com/library/view/-/9781492047834/ch02.html#ad066cc3-c540-41c1-a309-2e729470cc1c,Why Might You Choose Microservices?,
Monolith to Microservices,2. Planning a Migration,2021-10-04,https://learning.oreilly.com/library/view/-/9781492047834/,https://learning.oreilly.com/library/view/-/9781492047834/ch02.html,https://learning.oreilly.com/library/view/-/9781492047834/ch02.html#e17d1025-7bc1-480d-8ba3-4e053a3384da,How will you know if the transition is working?,
Monolith to Microservices,2. Planning a Migration,2021-10-04,https://learning.oreilly.com/library/view/-/9781492047834/,https://learning.oreilly.com/library/view/-/9781492047834/ch02.html,https://learning.oreilly.com/library/view/-/9781492047834/ch02.html#a05c328e-4d22-4eb7-aff2-bf4280930137,Have you considered alternatives to using microservices?,
Monolith to Microservices,2. Planning a Migration,2021-10-04,https://learning.oreilly.com/library/view/-/9781492047834/,https://learning.oreilly.com/library/view/-/9781492047834/ch02.html,https://learning.oreilly.com/library/view/-/9781492047834/ch02.html#a47aeb2d-53b1-4dc7-a592-5daba01bf676,"When working with an organization to help them understand if they should consider adopting a microservice architecture, I tend to ask the same set of questions:
What are you hoping to achieve?",
Monolith to Microservices,2. Planning a Migration,2021-10-04,https://learning.oreilly.com/library/view/-/9781492047834/,https://learning.oreilly.com/library/view/-/9781492047834/ch02.html,https://learning.oreilly.com/library/view/-/9781492047834/ch02.html#fe2824bb-16ac-4672-a3d5-e592f98704cc,"Some work is already being done to this end in the form of things like “The State of DevOps Report”, but that looks at architecture only in passing.",
"Essential Algorithms, 2nd Edition",CHAPTER 12: Decision Trees,2021-08-24,https://learning.oreilly.com/library/view/-/9781119575993/,https://learning.oreilly.com/library/view/-/9781119575993/c12.xhtml,https://learning.oreilly.com/library/view/-/9781119575993/c12.xhtml#2e664b20-ab46-49c5-ba48-91ce5c76e532,The following sections describe four heuristics for use with the partition problem.,
"Essential Algorithms, 2nd Edition",CHAPTER 12: Decision Trees,2021-08-24,https://learning.oreilly.com/library/view/-/9781119575993/,https://learning.oreilly.com/library/view/-/9781119575993/c12.xhtml,https://learning.oreilly.com/library/view/-/9781119575993/c12.xhtml#85c01444-1e6f-4c09-9593-dcfeb4f38b3f,"You can make random path selection more effective if you pick a random path and then try to improve it. Start with a random path. Then randomly pick an item, and switch it from the group it is in to the other group. If that improves the partitioning, keep that change. If that change ",
"Essential Algorithms, 2nd Edition",CHAPTER 12: Decision Trees,2021-08-24,https://learning.oreilly.com/library/view/-/9781119575993/,https://learning.oreilly.com/library/view/-/9781119575993/c12.xhtml,https://learning.oreilly.com/library/view/-/9781119575993/c12.xhtml#fb27e019-cf71-4769-8624-dda084600520,Hill Climbing,
"Essential Algorithms, 2nd Edition",CHAPTER 12: Decision Trees,2021-08-24,https://learning.oreilly.com/library/view/-/9781119575993/,https://learning.oreilly.com/library/view/-/9781119575993/c12.xhtml,https://learning.oreilly.com/library/view/-/9781119575993/c12.xhtml#ca29334b-6e9e-4cf9-84e8-0b0e91dad678,One easy way to improve the hill-climbing algorithm is to sort the weights and then consider them in order of decreasing size. The idea is that the early stages of the algorithm place the heavier objects in groups and then the later stages use the smaller items to try to balance the groups.,
Beginning Functional JavaScript: Uncover the Concepts of Functional Programming with EcmaScript 8,"10. Pause, Resume, and Async with Generators",2021-06-02,https://learning.oreilly.com/library/view/-/9781484240878/,https://learning.oreilly.com/library/view/-/9781484240878/A429083_2_En_10_Chapter.html,https://learning.oreilly.com/library/view/-/9781484240878/A429083_2_En_10_Chapter.html#a5c6fda1-4304-45dd-9aa0-f2951487330c,"n simple terms, lazy evaluation means the code won't run until ",
Beginning Functional JavaScript: Uncover the Concepts of Functional Programming with EcmaScript 8,7. Composition and Pipelines,2021-06-02,https://learning.oreilly.com/library/view/-/9781484240878/,https://learning.oreilly.com/library/view/-/9781484240878/A429083_2_En_7_Chapter.html,https://learning.oreilly.com/library/view/-/9781484240878/A429083_2_En_7_Chapter.html#79087e44-1406-4a54-b9fb-969f038d60fd,This process of flowing the data from right to left is called pipelines or even sequences.,
Beginning Functional JavaScript: Uncover the Concepts of Functional Programming with EcmaScript 8,7. Composition and Pipelines,2021-06-02,https://learning.oreilly.com/library/view/-/9781484240878/,https://learning.oreilly.com/library/view/-/9781484240878/A429083_2_En_7_Chapter.html,https://learning.oreilly.com/library/view/-/9781484240878/A429083_2_En_7_Chapter.html#b0a7baf2-acbc-4f5e-8e21-d40db239bacd,"Expect the output of every program to become the input to another, as yet unknown, program.",
Beginning Functional JavaScript: Uncover the Concepts of Functional Programming with EcmaScript 8,6. Currying and Partial Application,2021-06-02,https://learning.oreilly.com/library/view/-/9781484240878/,https://learning.oreilly.com/library/view/-/9781484240878/A429083_2_En_6_Chapter.html,https://learning.oreilly.com/library/view/-/9781484240878/A429083_2_En_6_Chapter.html#2c452e77-4ad7-4fe3-b3fa-ec55b1eec727,"Functional programming is all about composing functions, namely composing several small functions to build a new function.",
Docker Deep Dive,5: The Docker Engine,2021-05-18,https://learning.oreilly.com/library/view/-/9781800565135/,https://learning.oreilly.com/library/view/-/9781800565135/chap07.xhtml,https://learning.oreilly.com/library/view/-/9781800565135/chap07.xhtml#40c0978c-fd4b-4314-a588-1cbf9d26e797,"Some of the responsibilities the shim performs as a container’s parent include:
Keeping any STDIN and STDOUT streams open so that when the daemon is restarted, the container doesn’t terminate due to pipes being closed etc.
Reports the container’s exit status back to the daemon.",
Docker Deep Dive,5: The Docker Engine,2021-05-18,https://learning.oreilly.com/library/view/-/9781800565135/,https://learning.oreilly.com/library/view/-/9781800565135/chap07.xhtml,https://learning.oreilly.com/library/view/-/9781800565135/chap07.xhtml#131fc0a9-b8b2-4b34-acae-c676c2ac5cca,"When you type commands like this into the Docker CLI, the Docker client converts them into the appropriate API payload and POSTs them to the API endpoint exposed by the Docker daemon.
The API is implemented in the daemon and can be exposed over a local socket or the network. On Linux the socket is /var/run/docker.sock and on Windows it’s \pipe\docker_engine.",
Docker Deep Dive,5: The Docker Engine,2021-05-18,https://learning.oreilly.com/library/view/-/9781800565135/,https://learning.oreilly.com/library/view/-/9781800565135/chap07.xhtml,https://learning.oreilly.com/library/view/-/9781800565135/chap07.xhtml#e7ecd58f-3c4a-4dc3-b045-ea2f15a99bdc,"At the time of writing, the major components that make up the Docker engine are; the Docker daemon, containerd, runc, and various plugins such as networking and storage.",
Docker Deep Dive,4: The big picture,2021-05-12,https://learning.oreilly.com/library/view/-/9781800565135/,https://learning.oreilly.com/library/view/-/9781800565135/chap05.xhtml,https://learning.oreilly.com/library/view/-/9781800565135/chap05.xhtml#4eb32150-8e23-4313-88d0-ed0ff4456677,You can attach your shell to the terminal of a running container with the docker container exec command.,
Docker Deep Dive,2: Docker,2021-05-12,https://learning.oreilly.com/library/view/-/9781800565135/,https://learning.oreilly.com/library/view/-/9781800565135/chap03.xhtml,https://learning.oreilly.com/library/view/-/9781800565135/chap03.xhtml#e4382d3b-cdf5-44c4-b585-f452c7849bcb,"Docker also has native support for managing clusters of nodes running Docker. These clusters are called swarms and the native technology is called Docker Swarm. Docker Swarm is easy-to-use and many companies are using it in real-world production. However, most people are choosing to use Kubernetes instead of Docker Swarm.",
Docker Deep Dive,2: Docker,2021-05-12,https://learning.oreilly.com/library/view/-/9781800565135/,https://learning.oreilly.com/library/view/-/9781800565135/chap03.xhtml,https://learning.oreilly.com/library/view/-/9781800565135/chap03.xhtml#ddf3fbc2-2f67-4fd9-a2f2-f944aad620f9,"The Docker daemon (dockerd) sits above containerd and performs higher-level tasks such as; exposing the Docker remote API, managing images, managing volumes, managing networks, and more…",
Docker Deep Dive,2: Docker,2021-05-12,https://learning.oreilly.com/library/view/-/9781800565135/,https://learning.oreilly.com/library/view/-/9781800565135/chap03.xhtml,https://learning.oreilly.com/library/view/-/9781800565135/chap03.xhtml#7f25ad42-34c0-49d0-a86f-62458a6aab96,"The higher-level runtime is called containerd. containerd does a lot more than runc. It manages the entire lifecycle of a container, including pulling images, creating network interfaces, and managing lower-level runc instances.",
Docker Deep Dive,2: Docker,2021-05-12,https://learning.oreilly.com/library/view/-/9781800565135/,https://learning.oreilly.com/library/view/-/9781800565135/chap03.xhtml,https://learning.oreilly.com/library/view/-/9781800565135/chap03.xhtml#b3b70e39-4e76-46af-a98b-c92662bb7adb,The runtime operates at the lowest level and is responsible for starting and stopping containers (this includes building all of the OS constructs such as namespaces and cgroups). Docker implements a tiered runtime architecture with high-level and low-level runtimes that work together.,
Docker Deep Dive,2: Docker,2021-05-12,https://learning.oreilly.com/library/view/-/9781800565135/,https://learning.oreilly.com/library/view/-/9781800565135/chap03.xhtml,https://learning.oreilly.com/library/view/-/9781800565135/chap03.xhtml#3b193cfe-2240-44e6-94f2-78c71e1c7aa8,"there are at least three things to be aware of when referring to Docker as a technology:
The runtime
The daemon (a.k.a. engine)
The orchestrator",
Docker Deep Dive,"1: Containers from 30,000 feet",2021-05-12,https://learning.oreilly.com/library/view/-/9781800565135/,https://learning.oreilly.com/library/view/-/9781800565135/chap02.xhtml,https://learning.oreilly.com/library/view/-/9781800565135/chap02.xhtml#0ff2ce45-7c63-4388-8d7d-1ee62f877780,Kubernetes is the most popular tool for deploying and managing containerized apps.,
"Kubernetes: Up and Running, 2nd Edition",16. Extending Kubernetes,2021-05-06,https://learning.oreilly.com/library/view/-/9781492046523/,https://learning.oreilly.com/library/view/-/9781492046523/ch16.html,https://learning.oreilly.com/library/view/-/9781492046523/ch16.html#95256709-1407-4ad2-a3fb-71fded2e2890,"The Kubernetes API server is not designed to be a key/value store for your app; instead, API extensions should be control or configuration objects that help you manage the deployment or runtime of your application. An example use case for the “just data” pattern might be configuration for canary deployments of your application—for example, directing 10% of all traffic to an experimental backend. While in theory such configuration information could also be stored in a ConfigMap, ConfigMaps are essentially untyped, and sometimes using a more strongly typed API extension object provides clarity and ease of use.",
"Kubernetes: Up and Running, 2nd Edition",15. Integrating Storage Solutions and Kubernetes,2021-05-04,https://learning.oreilly.com/library/view/-/9781492046523/,https://learning.oreilly.com/library/view/-/9781492046523/ch15.html,https://learning.oreilly.com/library/view/-/9781492046523/ch15.html#c9d8b63b-6d10-44b3-917a-c068cc0e6df1,"to ensure that our database Pod is rescheduled in the presence of machine failures, we use the higher-level ReplicaSet controller, with a replica size of one, to manage our database",
"Kubernetes: Up and Running, 2nd Edition",15. Integrating Storage Solutions and Kubernetes,2021-05-04,https://learning.oreilly.com/library/view/-/9781492046523/,https://learning.oreilly.com/library/view/-/9781492046523/ch15.html,https://learning.oreilly.com/library/view/-/9781492046523/ch15.html#eb5a19ab-a958-4d08-979c-3c233f09d01b,"By using volume claims, you can keep your Pod specifications cloud-agnostic; simply create different volumes, specific to the cloud, and use a PersistentVolumeClaim to bind them together.",
"Kubernetes: Up and Running, 2nd Edition",14. Role-Based Access Control for Kubernetes,2021-05-04,https://learning.oreilly.com/library/view/-/9781492046523/,https://learning.oreilly.com/library/view/-/9781492046523/ch14.html,https://learning.oreilly.com/library/view/-/9781492046523/ch14.html#fb649251-3f56-423a-9161-611632a218cb,kubectl auth can-i create pods,
"Kubernetes: Up and Running, 2nd Edition",14. Role-Based Access Control for Kubernetes,2021-05-04,https://learning.oreilly.com/library/view/-/9781492046523/,https://learning.oreilly.com/library/view/-/9781492046523/ch14.html,https://learning.oreilly.com/library/view/-/9781492046523/ch14.html#18d5d095-8768-4619-b95e-9d40da376788,"The first useful tool is the auth can-i command for kubectl. This tool is very useful for testing if a particular user can do a particular action. You can use can-i to validate configuration settings as you configure your cluster, or you can ask users to use the tool to validate their access when filing errors or bug reports.",
"Kubernetes: Up and Running, 2nd Edition",14. Role-Based Access Control for Kubernetes,2021-05-04,https://learning.oreilly.com/library/view/-/9781492046523/,https://learning.oreilly.com/library/view/-/9781492046523/ch14.html,https://learning.oreilly.com/library/view/-/9781492046523/ch14.html#080c7d9c-d051-447e-8894-681735a6e720,In Kubernetes there are two pairs of related resources that represent roles and role bindings. One pair applies to just a namespace (Role and RoleBinding) while the other pair applies across the cluster (ClusterRole and ClusterRoleBinding).,
"Kubernetes: Up and Running, 2nd Edition",13. ConfigMaps and Secrets,2021-04-30,https://learning.oreilly.com/library/view/-/9781492046523/,https://learning.oreilly.com/library/view/-/9781492046523/ch13.html,https://learning.oreilly.com/library/view/-/9781492046523/ch13.html#455fdc06-1543-4520-be39-47e0d9b7b1be,"There are three main ways to use a ConfigMap:
Filesystem
You can mount a ConfigMap into a Pod. A file is created for each entry based on the key name. The contents of that file are set to the value.
Environment variable
A ConfigMap can be used to dynamically set the value of an environment variable.
Command-line argument
Kubernetes supports dynamically creating the command line for a container based on ConfigMap values.",
"Kubernetes: Up and Running, 2nd Edition",13. ConfigMaps and Secrets,2021-04-30,https://learning.oreilly.com/library/view/-/9781492046523/,https://learning.oreilly.com/library/view/-/9781492046523/ch13.html,https://learning.oreilly.com/library/view/-/9781492046523/ch13.html#6c03a903-c322-44a6-b055-693106c3fa9e,"The same image should be able to be used for development, staging, and production. It is even better if the same image is general-purpose enough to be used across applications and services.",
"Kubernetes: Up and Running, 2nd Edition",12. Jobs,2021-04-30,https://learning.oreilly.com/library/view/-/9781492046523/,https://learning.oreilly.com/library/view/-/9781492046523/ch12.html,https://learning.oreilly.com/library/view/-/9781492046523/ch12.html#636a52d6-0b18-4700-a1d4-9abb56de21f7,"Sometimes you want to schedule a job to be run at a certain interval. To achieve this you can declare a CronJob in Kubernetes, which is responsible for creating a new Job object at a particular interval",
"Kubernetes: Up and Running, 2nd Edition",12. Jobs,2021-04-30,https://learning.oreilly.com/library/view/-/9781492046523/,https://learning.oreilly.com/library/view/-/9781492046523/ch12.html,https://learning.oreilly.com/library/view/-/9781492046523/ch12.html#a5e6df67-f9f7-4e02-8f70-69ae72aaf91d,We’re going to use a combination of the completions and parallelism parameters.,
"Kubernetes: Up and Running, 2nd Edition",12. Jobs,2021-04-30,https://learning.oreilly.com/library/view/-/9781492046523/,https://learning.oreilly.com/library/view/-/9781492046523/ch12.html,https://learning.oreilly.com/library/view/-/9781492046523/ch12.html#8865ab46-796f-4324-88d8-d1675aff0078,"A job creates Pods that run until successful termination (i.e., exit with 0). In contrast, a regular Pod will continually restart",
"Kubernetes: Up and Running, 2nd Edition",11. DaemonSets,2021-04-29,https://learning.oreilly.com/library/view/-/9781492046523/,https://learning.oreilly.com/library/view/-/9781492046523/ch11.html,https://learning.oreilly.com/library/view/-/9781492046523/ch11.html#f3950e51-dffc-4659-affe-522af5a34903,"DaemonSet ensures a copy of a Pod is running across a set of nodes in a Kubernetes cluster. DaemonSets are used to deploy system daemons such as log collectors and monitoring agents, which typically must run on every node.",
"Kubernetes: Up and Running, 2nd Edition",11. DaemonSets,2021-04-29,https://learning.oreilly.com/library/view/-/9781492046523/,https://learning.oreilly.com/library/view/-/9781492046523/ch11.html,https://learning.oreilly.com/library/view/-/9781492046523/ch11.html#9e856f23-788e-4301-b45e-01a3e7e0e766,"Deployments and ReplicaSets are generally about creating a service (e.g., a web server) with multiple replicas for redundancy. But that is not the only reason you may want to replicate a set of Pods within a cluster. Another reason to replicate a set of Pods is to schedule a single Pod on every node within the cluster. Generally, the motivation for replicating a Pod to every node is to land some sort of agent or daemon on each node, and the Kubernetes object for achieving this is the DaemonSet.",
"Kubernetes: Up and Running, 2nd Edition",10. Deployments,2021-04-28,https://learning.oreilly.com/library/view/-/9781492046523/,https://learning.oreilly.com/library/view/-/9781492046523/ch10.html,https://learning.oreilly.com/library/view/-/9781492046523/ch10.html#3695a31d-7508-499d-8611-a1ec9dcef668,"In either case, by default, deleting a deployment deletes the entire service. It will delete not just the deployment, but also any ReplicaSets being managed by the deployment, as well as any Pods being managed by the ReplicaSets. As with ReplicaSets, if this is not the desired behavior, you can use the --cascade=false flag to exclusively delete the Deployment object.",
"Kubernetes: Up and Running, 2nd Edition",10. Deployments,2021-04-28,https://learning.oreilly.com/library/view/-/9781492046523/,https://learning.oreilly.com/library/view/-/9781492046523/ch10.html,https://learning.oreilly.com/library/view/-/9781492046523/ch10.html#40df2442-57d5-4c19-a9b6-76db11f35ca6,"To set the timeout period, the deployment parameter progressDeadlineSeconds",
"Kubernetes: Up and Running, 2nd Edition",10. Deployments,2021-04-28,https://learning.oreilly.com/library/view/-/9781492046523/,https://learning.oreilly.com/library/view/-/9781492046523/ch10.html,https://learning.oreilly.com/library/view/-/9781492046523/ch10.html#17c76211-cc66-4771-95f3-33656d403e1e,Setting minReadySeconds to 60 indicates that the deployment must wait for 60 seconds after seeing a Pod become healthy before moving on to updating the next Pod.,
"Kubernetes: Up and Running, 2nd Edition",10. Deployments,2021-04-28,https://learning.oreilly.com/library/view/-/9781492046523/,https://learning.oreilly.com/library/view/-/9781492046523/ch10.html,https://learning.oreilly.com/library/view/-/9781492046523/ch10.html#8320f708-d4d9-4343-ba76-c76f89d0ff45,"Setting maxSurge to 100% is equivalent to a blue/green deployment. The deployment controller first scales the new version up to 100% of the old version. Once the new version is healthy, it immediately scales the old version down to 0%.",
"Kubernetes: Up and Running, 2nd Edition",10. Deployments,2021-04-28,https://learning.oreilly.com/library/view/-/9781492046523/,https://learning.oreilly.com/library/view/-/9781492046523/ch10.html,https://learning.oreilly.com/library/view/-/9781492046523/ch10.html#e7150f61-7851-48bc-95fe-e08db7a39ebb,The maxSurge parameter controls how many extra resources can be created to achieve a rollout.,
"Kubernetes: Up and Running, 2nd Edition",10. Deployments,2021-04-28,https://learning.oreilly.com/library/view/-/9781492046523/,https://learning.oreilly.com/library/view/-/9781492046523/ch10.html,https://learning.oreilly.com/library/view/-/9781492046523/ch10.html#2369905f-44b2-429f-b5ad-1d769fc870b3,"The maxUnavailable parameter sets the maximum number of Pods that can be unavailable during a rolling update. It can either be set to an absolute number (e.g., 3, meaning a maximum of three Pods can be unavailable) or to a percentage",
"Kubernetes: Up and Running, 2nd Edition",10. Deployments,2021-04-28,https://learning.oreilly.com/library/view/-/9781492046523/,https://learning.oreilly.com/library/view/-/9781492046523/ch10.html,https://learning.oreilly.com/library/view/-/9781492046523/ch10.html#79f625be-926a-4dc3-b575-86e93132183c,There are two parameters you can use to tune the rolling update behavior: maxUnavailable and maxSurge.,
"Kubernetes: Up and Running, 2nd Edition",10. Deployments,2021-04-28,https://learning.oreilly.com/library/view/-/9781492046523/,https://learning.oreilly.com/library/view/-/9781492046523/ch10.html,https://learning.oreilly.com/library/view/-/9781492046523/ch10.html#37698267-e74f-43ea-ac09-7ec65ce43b4b,"the RollingUpdate strategy works by updating a few Pods at a time, moving incrementally until all of the Pods are running the new version of your software.",
"Kubernetes: Up and Running, 2nd Edition",10. Deployments,2021-04-28,https://learning.oreilly.com/library/view/-/9781492046523/,https://learning.oreilly.com/library/view/-/9781492046523/ch10.html,https://learning.oreilly.com/library/view/-/9781492046523/ch10.html#798080e3-1b43-4b2a-b786-97abdd04ad82,"The Recreate strategy is the simpler of the two rollout strategies. It simply updates the ReplicaSet it manages to use the new image and terminates all of the Pods associated with the deployment. The ReplicaSet notices that it no longer has any replicas, and re-creates all Pods using the new image. Once the Pods are re-created, they are running the new version.
While this strategy is fast and simple, it has one major drawback—it is potentially catastrophic, and will almost certainly result in some site downtime.",
"Kubernetes: Up and Running, 2nd Edition",10. Deployments,2021-04-28,https://learning.oreilly.com/library/view/-/9781492046523/,https://learning.oreilly.com/library/view/-/9781492046523/ch10.html,https://learning.oreilly.com/library/view/-/9781492046523/ch10.html#56daa89f-5008-4374-9a8f-d7c719a72db1,"you can use the kubectl rollout undo command to roll back to a previous version of a deployment. Additionally, you can roll back to a specific revision in the history using the --to-revision flag:",
"Kubernetes: Up and Running, 2nd Edition",10. Deployments,2021-04-28,https://learning.oreilly.com/library/view/-/9781492046523/,https://learning.oreilly.com/library/view/-/9781492046523/ch10.html,https://learning.oreilly.com/library/view/-/9781492046523/ch10.html#317e8671-d85c-42af-bdb5-12095420e143,Deployments are declarative objects that describe a deployed application. The two most common operations on a deployment are scaling and application updates.,
"Kubernetes: Up and Running, 2nd Edition",10. Deployments,2021-04-28,https://learning.oreilly.com/library/view/-/9781492046523/,https://learning.oreilly.com/library/view/-/9781492046523/ch10.html,https://learning.oreilly.com/library/view/-/9781492046523/ch10.html#d7955ec7-8ac8-4fc5-a1bd-cf93450970e0,The strategy object dictates the different ways in which a rollout of new software can proceed. There are two different strategies supported by deployments: Recreate and RollingUpdate.,
"Kubernetes: Up and Running, 2nd Edition",10. Deployments,2021-04-28,https://learning.oreilly.com/library/view/-/9781492046523/,https://learning.oreilly.com/library/view/-/9781492046523/ch10.html,https://learning.oreilly.com/library/view/-/9781492046523/ch10.html#525d5831-ba38-4931-8e61-6ef6045882ed,"If you ever want to manage that ReplicaSet directly, you need to delete the deployment (remember to set --cascade to false, or else it will delete the ReplicaSet and Pods as well!).",
"Kubernetes: Up and Running, 2nd Edition",10. Deployments,2021-04-28,https://learning.oreilly.com/library/view/-/9781492046523/,https://learning.oreilly.com/library/view/-/9781492046523/ch10.html,https://learning.oreilly.com/library/view/-/9781492046523/ch10.html#43ceaf7f-77a0-4903-ac79-a692d481c476,"Like all objects in Kubernetes, a deployment can be represented as a declarative YAML object that provides the details about what you want to run",
"Kubernetes: Up and Running, 2nd Edition",9. ReplicaSets,2021-04-14,https://learning.oreilly.com/library/view/-/9781492046523/,https://learning.oreilly.com/library/view/-/9781492046523/ch09.html,https://learning.oreilly.com/library/view/-/9781492046523/ch09.html#9acf724d-5491-451f-87e8-447184dd68c8,In some cases you may want to scale in response to custom application metrics. Kubernetes can handle all of these scenarios via Horizontal Pod Autoscaling (HPA).,
"Kubernetes: Up and Running, 2nd Edition",9. ReplicaSets,2021-04-14,https://learning.oreilly.com/library/view/-/9781492046523/,https://learning.oreilly.com/library/view/-/9781492046523/ch09.html,https://learning.oreilly.com/library/view/-/9781492046523/ch09.html#bdfe397d-681d-4a8b-8b0c-12945e37aef0,"If you don’t want to delete the Pods that are being managed by the ReplicaSet, you can set the --cascade flag to false to ensure only the ReplicaSet object is deleted and not the Pods:
$ kubectl delete rs kuard --cascade=false",
"Kubernetes: Up and Running, 2nd Edition",9. ReplicaSets,2021-04-14,https://learning.oreilly.com/library/view/-/9781492046523/,https://learning.oreilly.com/library/view/-/9781492046523/ch09.html,https://learning.oreilly.com/library/view/-/9781492046523/ch09.html#63631948-67c1-4ff1-b69a-2f128f793116,"When initially created, a ReplicaSet fetches a Pod listing from the Kubernetes API and filters the results by labels. Based on the number of Pods returned by the query, the ReplicaSet deletes or creates Pods to meet the desired number of replicas. The labels used for filtering are defined in the ReplicaSet spec section and are the key to understanding how ReplicaSets work.",
"Kubernetes: Up and Running, 2nd Edition",9. ReplicaSets,2021-04-14,https://learning.oreilly.com/library/view/-/9781492046523/,https://learning.oreilly.com/library/view/-/9781492046523/ch09.html,https://learning.oreilly.com/library/view/-/9781492046523/ch09.html#8f5e100f-98bb-42b0-b1d1-5f876a48286c,"ReplicaSets are designed to represent a single, scalable microservice inside your architecture",
"Kubernetes: Up and Running, 2nd Edition",9. ReplicaSets,2021-04-14,https://learning.oreilly.com/library/view/-/9781492046523/,https://learning.oreilly.com/library/view/-/9781492046523/ch09.html,https://learning.oreilly.com/library/view/-/9781492046523/ch09.html#cd2b8137-d8f8-4192-a55d-b0b4635b1029,"you can modify the set of labels on the sick Pod. Doing so will disassociate it from the ReplicaSet (and service) so that you can debug the Pod. The ReplicaSet controller will notice that a Pod is missing and create a new copy, but because the Pod is still running it is available to developers for interactive debugging, which is significantly more valuable than debugging from logs.",
"Kubernetes: Up and Running, 2nd Edition",9. ReplicaSets,2021-04-14,https://learning.oreilly.com/library/view/-/9781492046523/,https://learning.oreilly.com/library/view/-/9781492046523/ch09.html,https://learning.oreilly.com/library/view/-/9781492046523/ch09.html#4aa17e16-bc58-4257-9b30-29dd7bc88290,"because ReplicaSets are decoupled from the Pods they manage, you can simply create a ReplicaSet that will “adopt” the existing Pod, and scale out additional copies of those containers. In this way, you can seamlessly move from a single imperative Pod to a replicated set of Pods managed by a ReplicaSet.",
"Kubernetes: Up and Running, 2nd Edition",9. ReplicaSets,2021-04-14,https://learning.oreilly.com/library/view/-/9781492046523/,https://learning.oreilly.com/library/view/-/9781492046523/ch09.html,https://learning.oreilly.com/library/view/-/9781492046523/ch09.html#ef5b9c6c-48f9-449d-a6d9-3e170c6b8c0d,"ReplicaSets create and manage Pods, they do not own the Pods they create. ReplicaSets use label queries to identify the set of Pods they should be managing",
"Kubernetes: Up and Running, 2nd Edition",9. ReplicaSets,2021-04-14,https://learning.oreilly.com/library/view/-/9781492046523/,https://learning.oreilly.com/library/view/-/9781492046523/ch09.html,https://learning.oreilly.com/library/view/-/9781492046523/ch09.html#7e75250c-d73c-4876-a7fd-da13048f8c7a,"A ReplicaSet acts as a cluster-wide Pod manager, ensuring that the right types and number of Pods are running at all times.",
"Kubernetes: Up and Running, 2nd Edition",8. HTTP Load Balancing with Ingress,2021-04-13,https://learning.oreilly.com/library/view/-/9781492046523/,https://learning.oreilly.com/library/view/-/9781492046523/ch08.html,https://learning.oreilly.com/library/view/-/9781492046523/ch08.html#56981d8b-527e-4a1d-9d16-1d1ae77d11a1,The most popular generic Ingress controller is probably the open source NGINX ingress controller. Be aware that there is also a commercial controller based on the proprietary NGINX Plus. The open source controller essentially reads Ingress objects and merges them into an NGINX configuration file. It then signals to the NGINX process to restart with the new configuration (while responsibly serving existing in-flight connections),
"Kubernetes: Up and Running, 2nd Edition",8. HTTP Load Balancing with Ingress,2021-04-13,https://learning.oreilly.com/library/view/-/9781492046523/,https://learning.oreilly.com/library/view/-/9781492046523/ch08.html,https://learning.oreilly.com/library/view/-/9781492046523/ch08.html#b7368111-0440-418d-ab38-10981cf367d3,"When there are multiple paths on the same host listed in the Ingress system, the longest prefix matches. So, in this example, traffic starting with /a/ is forwarded to the alpaca service, while all other traffic (starting with /) is directed to the bandicoot service.",
"Kubernetes: Up and Running, 2nd Edition",8. HTTP Load Balancing with Ingress,2021-04-13,https://learning.oreilly.com/library/view/-/9781492046523/,https://learning.oreilly.com/library/view/-/9781492046523/ch08.html,https://learning.oreilly.com/library/view/-/9781492046523/ch08.html#440ee050-15b1-4b60-a51c-6ca30ebfc731,"While there are many available Ingress controllers, for the examples here we use an Ingress controller called Contour. This is a controller built to configure the open source (and CNCF project) load balancer called Envoy. Envoy is built to be dynamically configured via an API.",
"Kubernetes: Up and Running, 2nd Edition",8. HTTP Load Balancing with Ingress,2021-04-13,https://learning.oreilly.com/library/view/-/9781492046523/,https://learning.oreilly.com/library/view/-/9781492046523/ch08.html,https://learning.oreilly.com/library/view/-/9781492046523/ch08.html#f6cbc81c-e1de-4add-a291-06894cdf8e19,"While there are many available Ingress controllers, for the examples here we use an Ingress controller called Contour. This is a controller built to configure the open source (and CNCF project) load balancer called Envoy. Envoy is built to be dynamically configured via an API",
"Kubernetes: Up and Running, 2nd Edition",8. HTTP Load Balancing with Ingress,2021-04-13,https://learning.oreilly.com/library/view/-/9781492046523/,https://learning.oreilly.com/library/view/-/9781492046523/ch08.html,https://learning.oreilly.com/library/view/-/9781492046523/ch08.html#508d734a-9c2d-4c1c-8409-35a83e7efc4c,"Kubernetes calls its HTTP-based load-balancing system Ingress. Ingress is a Kubernetes-native way to implement the “virtual hosting” pattern we just discussed. One of the more complex aspects of the pattern is that the user has to manage the load balancer configuration file. In a dynamic environment and as the set of virtual hosts expands, this can be very complex. The Kubernetes Ingress system works to simplify this by (a) standardizing that configuration, (b) moving it to a standard Kubernetes object, and (c) merging multiple Ingress objects into a single config for the load balancer.",
"Kubernetes: Up and Running, 2nd Edition",8. HTTP Load Balancing with Ingress,2021-04-13,https://learning.oreilly.com/library/view/-/9781492046523/,https://learning.oreilly.com/library/view/-/9781492046523/ch08.html,https://learning.oreilly.com/library/view/-/9781492046523/ch08.html#049b333a-de7d-43d5-85f9-f47b7af65729,"virtual hosting.” This is a mechanism to host many HTTP sites on a single IP address. Typically, the user uses a load balancer or reverse proxy to accept incoming connections on HTTP (80) and HTTPS (443) ports. That program then parses the HTTP connection and, based on the Host header and the URL path that is requested, proxies the HTTP call to some other program. In this way, that load balancer or reverse proxy plays “traffic cop” for decoding and directing incoming connections to the right “upstream” server.",
"Kubernetes: Up and Running, 2nd Edition",7. Service Discovery,2021-04-12,https://learning.oreilly.com/library/view/-/9781492046523/,https://learning.oreilly.com/library/view/-/9781492046523/ch07.html,https://learning.oreilly.com/library/view/-/9781492046523/ch07.html#861110dc-fb97-442a-b648-c7cff774c00c,"There are also a variety of open source projects (for example, HashiCorp’s Consul) that can be used to manage connectivity between in-cluster and out-of-cluster resources.",
"Kubernetes: Up and Running, 2nd Edition",7. Service Discovery,2021-04-12,https://learning.oreilly.com/library/view/-/9781492046523/,https://learning.oreilly.com/library/view/-/9781492046523/ch07.html,https://learning.oreilly.com/library/view/-/9781492046523/ch07.html#67b17a17-ef99-40ca-a476-7fb69e8b5e6c,"Some applications (and the system itself) want to be able to use services without using a cluster IP. This is done with another type of object called an Endpoints object. For every Service object, Kubernetes creates a buddy Endpoints object that contains the IP addresses for that service",
"Kubernetes: Up and Running, 2nd Edition",7. Service Discovery,2021-04-12,https://learning.oreilly.com/library/view/-/9781492046523/,https://learning.oreilly.com/library/view/-/9781492046523/ch07.html,https://learning.oreilly.com/library/view/-/9781492046523/ch07.html#cddfaa1a-7822-4079-ba9c-9e7026791b8f,"Kubernetes provides a DNS service exposed to Pods running in the cluster. This Kubernetes DNS service was installed as a system component when the cluster was first created. The DNS service is, itself, managed by Kubernetes and is a great example of Kubernetes building on Kubernetes. The Kubernetes DNS service provides DNS names for cluster IPs.",
"Kubernetes: Up and Running, 2nd Edition",7. Service Discovery,2021-04-12,https://learning.oreilly.com/library/view/-/9781492046523/,https://learning.oreilly.com/library/view/-/9781492046523/ch07.html,https://learning.oreilly.com/library/view/-/9781492046523/ch07.html#62f3a555-d534-460e-a689-18f447933708,we can use kubectl expose to create a service,
"Kubernetes: Up and Running, 2nd Edition",7. Service Discovery,2021-04-12,https://learning.oreilly.com/library/view/-/9781492046523/,https://learning.oreilly.com/library/view/-/9781492046523/ch07.html,https://learning.oreilly.com/library/view/-/9781492046523/ch07.html#bb25f3cc-7d33-4b21-af50-c5944e7f9cf7,"Real service discovery in Kubernetes starts with a Service object.
A Service object is a way to create a named label selector",
"Kubernetes: Up and Running, 2nd Edition",6. Labels and Annotations,2021-04-12,https://learning.oreilly.com/library/view/-/9781492046523/,https://learning.oreilly.com/library/view/-/9781492046523/ch06.html,https://learning.oreilly.com/library/view/-/9781492046523/ch06.html#a23c2d0f-26ff-49ac-9658-e9f4160c4965,"In addition to enabling users to organize their infrastructure, labels play a critical role in linking various related Kubernetes objects. Kubernetes is a purposefully decoupled system. There is no hierarchy and all components operate independently. However, in many cases objects need to relate to one another, and these relationships are defined by labels and label selectors.",
"Kubernetes: Up and Running, 2nd Edition",6. Labels and Annotations,2021-04-12,https://learning.oreilly.com/library/view/-/9781492046523/,https://learning.oreilly.com/library/view/-/9781492046523/ch06.html,https://learning.oreilly.com/library/view/-/9781492046523/ch06.html#dfa4dfde-135e-4b4a-8b85-d3013e2dc675,"Labels are key/value pairs that can be attached to Kubernetes objects such as Pods and ReplicaSets. They can be arbitrary, and are useful for attaching identifying information to Kubernetes objects. Labels provide the foundation for grouping objects.
Annotations, on the other hand, provide a storage mechanism that resembles labels: annotations are key/value pairs designed to hold nonidentifying information that can be leveraged by tools and libraries.",
"Kubernetes: Up and Running, 2nd Edition",5. Pods,2021-04-09,https://learning.oreilly.com/library/view/-/9781492046523/,https://learning.oreilly.com/library/view/-/9781492046523/ch05.html,https://learning.oreilly.com/library/view/-/9781492046523/ch05.html#c97b05cf-901d-41b7-ac64-a3e3d2f093ae,"Pods represent the atomic unit of work in a Kubernetes cluster. Pods are comprised of one or more containers working together symbiotically. To create a Pod, you write a Pod manifest and submit it to the Kubernetes API server by using the command-line tool or (less frequently) by making HTTP and JSON calls to the server directly.
Once you’ve submitted the manifest to the API server, the Kubernetes scheduler finds a machine where the Pod can fit and schedules the Pod to that machine. Once scheduled, the kubelet daemon on that machine is responsible for creating the containers that correspond to the Pod, as well as performing any health checks defined in the Pod manifest.
Once a Pod is scheduled to a node, no rescheduling occurs if that node fails. Additionally, to create multiple replicas of the same Pod you have to create and name them manually.",
"Kubernetes: Up and Running, 2nd Edition",5. Pods,2021-04-09,https://learning.oreilly.com/library/view/-/9781492046523/,https://learning.oreilly.com/library/view/-/9781492046523/ch05.html,https://learning.oreilly.com/library/view/-/9781492046523/ch05.html#5b07682f-fcec-4a88-9cd1-b50dd58aad51,"To add a volume to a Pod manifest, there are two new stanzas to add to our configuration. The first is a new spec.volumes section. This array defines all of the volumes that may be accessed by containers in the Pod manifest. It’s important to note that not all containers are required to mount all volumes defined in the Pod. The second addition is the volumeMounts array in the container definition. This array defines the volumes that are mounted into a particular container, and the path where each volume should be mounted. Note that two different containers in a Pod can mount the same volume at different mount paths.",
"Kubernetes: Up and Running, 2nd Edition",5. Pods,2021-04-09,https://learning.oreilly.com/library/view/-/9781492046523/,https://learning.oreilly.com/library/view/-/9781492046523/ch05.html,https://learning.oreilly.com/library/view/-/9781492046523/ch05.html#13dd4dae-5b37-4603-af22-83f5cea86915,copying files into a container is an anti-pattern. You really should treat the contents of a container as immutable,
"Kubernetes: Up and Running, 2nd Edition",5. Pods,2021-04-09,https://learning.oreilly.com/library/view/-/9781492046523/,https://learning.oreilly.com/library/view/-/9781492046523/ch05.html,https://learning.oreilly.com/library/view/-/9781492046523/ch05.html#6b0e0fe6-ff6e-4a90-ad46-c95fb7c8d9ed,"It’s important to note that when you delete a Pod, any data stored in the containers associated with that Pod will be deleted as well. If you want to persist data across multiple instances of a Pod, you need to use PersistentVolumes,",
"Kubernetes: Up and Running, 2nd Edition",5. Pods,2021-04-09,https://learning.oreilly.com/library/view/-/9781492046523/,https://learning.oreilly.com/library/view/-/9781492046523/ch05.html,https://learning.oreilly.com/library/view/-/9781492046523/ch05.html#5fd05d35-3a12-400e-8c5b-c0788dff552d,"Use the kubectl apply command to launch a single instance of kuard:
$ kubectl apply -f kuard-pod.yaml",
"Kubernetes: Up and Running, 2nd Edition",5. Pods,2021-04-09,https://learning.oreilly.com/library/view/-/9781492046523/,https://learning.oreilly.com/library/view/-/9781492046523/ch05.html,https://learning.oreilly.com/library/view/-/9781492046523/ch05.html#2a958b89-d9ea-4c3c-a8b5-5f4fedbba206,"The simplest way to create a Pod is via the imperative kubectl run command. For example, to run our same kuard server, use:
$ kubectl run kuard --generator=run-pod/v1 \
--image=gcr.io/kuar-demo/kuard-amd64:blue",
"Kubernetes: Up and Running, 2nd Edition",5. Pods,2021-04-09,https://learning.oreilly.com/library/view/-/9781492046523/,https://learning.oreilly.com/library/view/-/9781492046523/ch05.html,https://learning.oreilly.com/library/view/-/9781492046523/ch05.html#3de30d52-3a5f-45f6-977f-5bd57e14f6fc,"In general, the right question to ask yourself when designing Pods is, “Will these containers work correctly if they land on different machines?” If the answer is “no,” a Pod is the correct grouping for the containers. If the answer is “yes,” multiple Pods is probably the correct solution",
"Kubernetes: Up and Running, 2nd Edition",5. Pods,2021-04-09,https://learning.oreilly.com/library/view/-/9781492046523/,https://learning.oreilly.com/library/view/-/9781492046523/ch05.html,https://learning.oreilly.com/library/view/-/9781492046523/ch05.html#ffa4f08f-fc49-48e9-8a95-89d9b706e9c8,A Pod represents a collection of application containers and volumes running in the same execution environment.,
"Kubernetes: Up and Running, 2nd Edition",4. Common kubectl Commands,2021-04-08,https://learning.oreilly.com/library/view/-/9781492046523/,https://learning.oreilly.com/library/view/-/9781492046523/ch04.html,https://learning.oreilly.com/library/view/-/9781492046523/ch04.html#4139e151-72e6-4fc1-a351-cff05305a8ad,"You can also use the exec command to execute a command in a running container:
$ kubectl exec -it <pod-name> -- bash",
"Kubernetes: Up and Running, 2nd Edition",4. Common kubectl Commands,2021-04-08,https://learning.oreilly.com/library/view/-/9781492046523/,https://learning.oreilly.com/library/view/-/9781492046523/ch04.html,https://learning.oreilly.com/library/view/-/9781492046523/ch04.html#fe6a9a15-2075-48cc-9343-9fb778b9ef50,kubectl delete <resource-name> <obj-name>,
"Kubernetes: Up and Running, 2nd Edition",4. Common kubectl Commands,2021-04-08,https://learning.oreilly.com/library/view/-/9781492046523/,https://learning.oreilly.com/library/view/-/9781492046523/ch04.html,https://learning.oreilly.com/library/view/-/9781492046523/ch04.html#5ca94c4e-2a04-4f04-830c-7de0d76600ba,"If you want to view the complete object, you can also view the objects as raw JSON or YAML using the -o json or -o yaml flag",
"Kubernetes: Up and Running, 2nd Edition",4. Common kubectl Commands,2021-04-08,https://learning.oreilly.com/library/view/-/9781492046523/,https://learning.oreilly.com/library/view/-/9781492046523/ch04.html,https://learning.oreilly.com/library/view/-/9781492046523/ch04.html#7c75996d-cdeb-41cd-8cff-6ea5729ae05a,"Everything contained in Kubernetes is represented by a RESTful resource. Throughout this book, we refer to these resources as Kubernetes objects. Each Kubernetes object exists at a unique HTTP path; for example, https://your-k8s.com/api/v1/namespaces/default/pods/my-pod",
"Kubernetes: Up and Running, 2nd Edition",4. Common kubectl Commands,2021-04-08,https://learning.oreilly.com/library/view/-/9781492046523/,https://learning.oreilly.com/library/view/-/9781492046523/ch04.html,https://learning.oreilly.com/library/view/-/9781492046523/ch04.html#85691cd5-0db7-43e5-9823-ecae193ba7e1,"If you want to change the default namespace more permanently, you can use a context. This gets recorded in a kubectl configuration file, usually located at $HOME/.kube/config. This configuration file also stores how to both find and authenticate to your cluster. For example, you can create a context with a different default namespace for your kubectl commands using:
$ kubectl config set-context my-context --namespace=mystuff
This creates a new context, but it doesn’t actually start using it yet. To use this newly created context, you can run:
$ kubectl config use-context my-context",
"Kubernetes: Up and Running, 2nd Edition",4. Common kubectl Commands,2021-04-08,https://learning.oreilly.com/library/view/-/9781492046523/,https://learning.oreilly.com/library/view/-/9781492046523/ch04.html,https://learning.oreilly.com/library/view/-/9781492046523/ch04.html#4239c4dd-963a-411a-9940-eeb41eb226a0,"Kubernetes uses namespaces to organize objects in the cluster. You can think of each namespace as a folder that holds a set of objects. By default, the kubectl command-line tool interacts with the default namespace. If you want to use a different namespace, you can pass kubectl the --namespace flag",
"Kubernetes: Up and Running, 2nd Edition",2. Creating and Running Containers,2021-04-08,https://learning.oreilly.com/library/view/-/9781492046523/,https://learning.oreilly.com/library/view/-/9781492046523/ch02.html,https://learning.oreilly.com/library/view/-/9781492046523/ch02.html#22223c17-40e6-4f2f-8195-22fe59cbde71,"A slightly more sophisticated approach is to set up a cron job to run an image garbage collector. For example, the docker-gc tool is a commonly used image garbage collector that can easily run as a recurring cron job, once per day or once per hour, depending on how many images you are creating.",
"Kubernetes: Up and Running, 2nd Edition",2. Creating and Running Containers,2021-04-08,https://learning.oreilly.com/library/view/-/9781492046523/,https://learning.oreilly.com/library/view/-/9781492046523/ch02.html,https://learning.oreilly.com/library/view/-/9781492046523/ch02.html#689825c4-346c-4eea-a7a9-4a19a55f953f,"Though generally in Kubernetes containers are launched by a daemon on each node called the kubelet, it’s easier to get started with containers using the Docker command-line tool",
"Kubernetes: Up and Running, 2nd Edition",2. Creating and Running Containers,2021-04-08,https://learning.oreilly.com/library/view/-/9781492046523/,https://learning.oreilly.com/library/view/-/9781492046523/ch02.html,https://learning.oreilly.com/library/view/-/9781492046523/ch02.html#b4ec096c-c4f0-43aa-96f7-695dab03c253,"In general, you want to order your layers from least likely to change to most likely to change in order to optimize the image size for pushing and pulling. This is why, in Example 2-4, we copy the package*.json files and install dependencies before copying the rest of the program files. A developer is going to update and change the program files much more often than the dependencies.",
"Kubernetes: Up and Running, 2nd Edition",2. Creating and Running Containers,2021-04-08,https://learning.oreilly.com/library/view/-/9781492046523/,https://learning.oreilly.com/library/view/-/9781492046523/ch02.html,https://learning.oreilly.com/library/view/-/9781492046523/ch02.html#f978184b-5f11-4720-ae78-9a2ebf0ee2f3,"Containers fall into two main categories:
System containers
Application containers",
"Kubernetes: Up and Running, 2nd Edition",1. Introduction,2021-04-08,https://learning.oreilly.com/library/view/-/9781492046523/,https://learning.oreilly.com/library/view/-/9781492046523/ch01.html,https://learning.oreilly.com/library/view/-/9781492046523/ch01.html#2b4f88ec-7fef-4e99-9be2-f2c246101ad8,"Kubernetes provides numerous abstractions and APIs that make it easier to build these decoupled microservice architectures:
Pods, or groups of containers, can group together container images developed by different teams into a single deployable unit.
Kubernetes services provide load balancing, naming, and discovery to isolate one microservice from another.
Namespaces provide isolation and access control, so that each microservice can control the degree to which other services interact with it.
Ingress objects provide an easy-to-use frontend that can combine multiple microservices into a single externalized API surface area.",
"Kubernetes: Up and Running, 2nd Edition",1. Introduction,2021-04-08,https://learning.oreilly.com/library/view/-/9781492046523/,https://learning.oreilly.com/library/view/-/9781492046523/ch01.html,https://learning.oreilly.com/library/view/-/9781492046523/ch01.html#9e276ecc-1192-4fc9-b6e4-a9fabfccbbd0,The idea of storing declarative configuration in source control is often referred to as “infrastructure as code.”,
"Kubernetes: Up and Running, 2nd Edition",1. Introduction,2021-04-08,https://learning.oreilly.com/library/view/-/9781492046523/,https://learning.oreilly.com/library/view/-/9781492046523/ch01.html,https://learning.oreilly.com/library/view/-/9781492046523/ch01.html#62bcf631-461c-4794-819a-315b2c0a7982,"Kubernetes can provide the tools that you need to move quickly, while staying available. The core concepts that enable this are:
Immutability
Declarative configuration
Online self-healing systems",
Kubernetes in Action,Chapter 2. First steps with Docker and Kubernetes,2021-04-04,https://learning.oreilly.com/library/view/-/9781617293726/,https://learning.oreilly.com/library/view/-/9781617293726/Text/02.html,https://learning.oreilly.com/library/view/-/9781617293726/Text/02.html#2f343302-f984-475d-877b-0d8c76716474,"The main and most important component in your system is the pod. It contains only a single container, but generally a pod can contain as many containers as you want",
Kubernetes in Action,Chapter 2. First steps with Docker and Kubernetes,2021-04-04,https://learning.oreilly.com/library/view/-/9781617293726/,https://learning.oreilly.com/library/view/-/9781617293726/Text/02.html,https://learning.oreilly.com/library/view/-/9781617293726/Text/02.html#4019ba3e-59d4-4921-8157-4f45b82f4b26,The next component is the kubia ReplicationController. It makes sure there’s always exactly one instance of your pod running.,
Kubernetes in Action,Chapter 2. First steps with Docker and Kubernetes,2021-04-04,https://learning.oreilly.com/library/view/-/9781617293726/,https://learning.oreilly.com/library/view/-/9781617293726/Text/02.html,https://learning.oreilly.com/library/view/-/9781617293726/Text/02.html#dd3eaad0-8d4e-4a8a-b8ae-6bc1a74f112b,The third component of your system is the kubia-http service,
Kubernetes in Action,Chapter 2. First steps with Docker and Kubernetes,2021-04-04,https://learning.oreilly.com/library/view/-/9781617293726/,https://learning.oreilly.com/library/view/-/9781617293726/Text/02.html,https://learning.oreilly.com/library/view/-/9781617293726/Text/02.html#0b9b1b6d-7b5d-47a0-8906-a1f0a9c3759c,"When a service is created, it gets a static IP, which never changes during the lifetime of the service. Instead of connecting to pods directly, clients should connect to the service through its constant IP address. The service makes sure one of the pods receives the connection, regardless of where the pod is currently running (and what its IP address is).",
Kubernetes in Action,Chapter 2. First steps with Docker and Kubernetes,2021-04-04,https://learning.oreilly.com/library/view/-/9781617293726/,https://learning.oreilly.com/library/view/-/9781617293726/Text/02.html,https://learning.oreilly.com/library/view/-/9781617293726/Text/02.html#e133128f-df2c-4c1a-853b-0e8b842bb6be,"The term scheduling means assigning the pod to a node. The pod is run immediately, not at a time in the future as the term might lead you to believ",
Kubernetes in Action,Chapter 2. First steps with Docker and Kubernetes,2021-04-04,https://learning.oreilly.com/library/view/-/9781617293726/,https://learning.oreilly.com/library/view/-/9781617293726/Text/02.html,https://learning.oreilly.com/library/view/-/9781617293726/Text/02.html#bc5b99d0-1b13-4e4a-a103-d79f37b5b29d,"A pod is a group of one or more tightly related containers that will always run together on the same worker node and in the same Linux namespace(s). Each pod is like a separate logical machine with its own IP, hostname, processes, and so on, running a single application. The application can be a single process, running in a single container, or it can be a main application process and additional supporting processes, each running in its own container. All the containers in a pod will appear to be running on the same logical machine, whereas containers in other pods, even if they’re running on the same worker node, will appear to be running on a different one.",
Kubernetes in Action,Chapter 2. First steps with Docker and Kubernetes,2021-04-04,https://learning.oreilly.com/library/view/-/9781617293726/,https://learning.oreilly.com/library/view/-/9781617293726/Text/02.html,https://learning.oreilly.com/library/view/-/9781617293726/Text/02.html#93ccdc45-44b5-4c6e-8f5b-3c719dd33be2,the concept of multiple co-located containers. This group of containers is called a Pod.,
Kubernetes in Action,Chapter 1. Introducing Kubernetes,2021-04-04,https://learning.oreilly.com/library/view/-/9781617293726/,https://learning.oreilly.com/library/view/-/9781617293726/Text/01.html,https://learning.oreilly.com/library/view/-/9781617293726/Text/01.html#c0632a32-1ddc-40ee-a0ea-431f0ff557a6,"The kube-proxy will make sure connections to the service are load balanced across all the containers that provide the service. The IP address of the service stays constant, so clients can always connect to its containers, even when they’re moved around the cluster.",
Kubernetes in Action,Chapter 1. Introducing Kubernetes,2021-04-04,https://learning.oreilly.com/library/view/-/9781617293726/,https://learning.oreilly.com/library/view/-/9781617293726/Text/01.html,https://learning.oreilly.com/library/view/-/9781617293726/Text/01.html#5a0b6601-5ce2-4684-81f9-ffeeae997378,"To allow clients to easily find containers that provide a specific service, you can tell Kubernetes which containers provide the same service and Kubernetes will expose all of them at a single static IP address and expose that address to all applications running in the cluster.",
Kubernetes in Action,Chapter 1. Introducing Kubernetes,2021-04-04,https://learning.oreilly.com/library/view/-/9781617293726/,https://learning.oreilly.com/library/view/-/9781617293726/Text/01.html,https://learning.oreilly.com/library/view/-/9781617293726/Text/01.html#0c1a7991-eb35-462d-813e-aebab8f82909,"The Control Plane is what controls the cluster and makes it function. It consists of multiple components that can run on a single master node or be split across multiple nodes and replicated to ensure high availability. These components are
The Kubernetes API Server, which you and the other Control Plane components communicate with
The Scheduler, which schedules your apps (assigns a worker node to each deployable component of your application)
The Controller Manager, which performs cluster-level functions, such as replicating components, keeping track of worker nodes, handling node failures, and so on
etcd, a reliable distributed data store that persistently stores the cluster configuration",
Kubernetes in Action,Chapter 1. Introducing Kubernetes,2021-04-04,https://learning.oreilly.com/library/view/-/9781617293726/,https://learning.oreilly.com/library/view/-/9781617293726/Text/01.html,https://learning.oreilly.com/library/view/-/9781617293726/Text/01.html#54f39cce-ecbb-4a58-b423-c959e15b0692,"The worker nodes are the machines that run your containerized applications. The task of running, monitoring, and providing services to your applications is done by the following components:
Docker, rkt, or another container runtime, which runs your containers
The Kubelet, which talks to the API server and manages containers on its node
The Kubernetes Service Proxy (kube-proxy), which load-balances network traffic between application components",
Kubernetes in Action,Chapter 1. Introducing Kubernetes,2021-04-04,https://learning.oreilly.com/library/view/-/9781617293726/,https://learning.oreilly.com/library/view/-/9781617293726/Text/01.html,https://learning.oreilly.com/library/view/-/9781617293726/Text/01.html#00ffc1a7-5a54-4b5e-939b-f967308bcc8f,"Kubernetes to provide these services. This includes things such as service discovery, scaling, load-balancing, self-healing, and even leader election. Application developers can therefore focus on implementing the actual features of the applications and not waste time figuring out how to integrate them with the infrastructure.",
Kubernetes in Action,Chapter 1. Introducing Kubernetes,2021-04-04,https://learning.oreilly.com/library/view/-/9781617293726/,https://learning.oreilly.com/library/view/-/9781617293726/Text/01.html,https://learning.oreilly.com/library/view/-/9781617293726/Text/01.html#71b405da-536b-4e7e-a586-f603b4414ac8,"Kubernetes enables you to run your software applications on thousands of computer nodes as if all those nodes were a single, enormous computer",
Kubernetes in Action,Chapter 1. Introducing Kubernetes,2021-04-03,https://learning.oreilly.com/library/view/-/9781617293726/,https://learning.oreilly.com/library/view/-/9781617293726/Text/01.html,https://learning.oreilly.com/library/view/-/9781617293726/Text/01.html#fe571b61-4981-4631-93b0-faa643ff671a,"A big difference between Docker-based container images and VM images is that container images are composed of layers, which can be shared and reused across multiple images. This means only certain layers of an image need to be downloaded if the other layers were already downloaded previously when running a different container image that also contains the same layers.",
Kubernetes in Action,Chapter 1. Introducing Kubernetes,2021-04-03,https://learning.oreilly.com/library/view/-/9781617293726/,https://learning.oreilly.com/library/view/-/9781617293726/Text/01.html,https://learning.oreilly.com/library/view/-/9781617293726/Text/01.html#e99e0f9f-d3e5-440e-a3f3-e01527c839d9,"because each VM runs its own Linux kernel, while containers all call out to the same kernel, which can clearly pose a security risk.",
Kubernetes in Action,Chapter 1. Introducing Kubernetes,2021-04-03,https://learning.oreilly.com/library/view/-/9781617293726/,https://learning.oreilly.com/library/view/-/9781617293726/Text/01.html,https://learning.oreilly.com/library/view/-/9781617293726/Text/01.html#3d6039ee-cdfb-4d03-8986-bb6a0e709fad,"each VM runs its own set of system services, while containers don’t, because they all run in the same OS. That also means that to run a container, nothing needs to be booted up, as is the case in VMs. A process run in a container starts up immediately.",
Kubernetes in Action,Chapter 1. Introducing Kubernetes,2021-04-03,https://learning.oreilly.com/library/view/-/9781617293726/,https://learning.oreilly.com/library/view/-/9781617293726/Text/01.html,https://learning.oreilly.com/library/view/-/9781617293726/Text/01.html#32c9aa92-bf1b-4cec-9e01-dff9c915c962,"Containers, on the other hand, all perform system calls on the exact same kernel running in the host OS",Voy diagram
Kubernetes in Action,Chapter 1. Introducing Kubernetes,2021-04-03,https://learning.oreilly.com/library/view/-/9781617293726/,https://learning.oreilly.com/library/view/-/9781617293726/Text/01.html,https://learning.oreilly.com/library/view/-/9781617293726/Text/01.html#088187f9-e5f4-4363-86a0-54fce00a2464,"Containers, on the other hand, all perform system calls on the exact same kernel running in the host OS.",
Kubernetes in Action,Chapter 1. Introducing Kubernetes,2021-04-03,https://learning.oreilly.com/library/view/-/9781617293726/,https://learning.oreilly.com/library/view/-/9781617293726/Text/01.html,https://learning.oreilly.com/library/view/-/9781617293726/Text/01.html#e37a3d7c-0c05-46a0-87a1-07cc429760bc,"A container, on the other hand, is nothing more than a single isolated process running in the host OS, consuming only the resources that the app consumes and without the overhead of any additional processes.",
Kubernetes in Action,Chapter 1. Introducing Kubernetes,2021-04-03,https://learning.oreilly.com/library/view/-/9781617293726/,https://learning.oreilly.com/library/view/-/9781617293726/Text/01.html,https://learning.oreilly.com/library/view/-/9781617293726/Text/01.html#5c966b45-3634-4517-84ae-6b836d7e1b71,"Kubernetes enables us to achieve all of this. By abstracting away the actual hardware and exposing it as a single platform for deploying and running apps, it allows developers to configure and deploy their applications without any help from the sysadmins and allows the sysadmins to focus on keeping the underlying infrastructure up and running, while not having to know anything about the actual applications running on top of it.",
Kubernetes in Action,Chapter 1. Introducing Kubernetes,2021-04-03,https://learning.oreilly.com/library/view/-/9781617293726/,https://learning.oreilly.com/library/view/-/9781617293726/Text/01.html,https://learning.oreilly.com/library/view/-/9781617293726/Text/01.html#e6eefc32-4500-460b-8ef5-e816902dd3cf,"Microservices also bring other problems, such as making it hard to debug and trace execution calls, because they span multiple processes and machines. Luckily, these problems are now being addressed with distributed tracing systems such as Zipkin.",
Kubernetes in Action,Chapter 1. Introducing Kubernetes,2021-04-03,https://learning.oreilly.com/library/view/-/9781617293726/,https://learning.oreilly.com/library/view/-/9781617293726/Text/01.html,https://learning.oreilly.com/library/view/-/9781617293726/Text/01.html#bcce8faa-902f-47dd-b319-abf29ddd3d9f,"Kubernetes enables developers to deploy their applications themselves and as often as they want, without requiring any assistance from the operations (ops) team. But Kubernetes doesn’t benefit only developers. It also helps the ops team by automatically monitoring and rescheduling those apps in the event of a hardware failure. The focus for system administrators (sysadmins) shifts from supervising individual apps to mostly supervising and managing Kubernetes and the rest of the infrastructure, while Kubernetes itself takes care of the apps.",
Operational Excellence: Journey to Creating Sustainable Value,CHAPTER 5: BUSINESS AND FINANCIAL ELEMENTS,2020-10-09,https://learning.oreilly.com/library/view/-/9781118990148/,https://learning.oreilly.com/library/view/-/9781118990148/c05.xhtml,https://learning.oreilly.com/library/view/-/9781118990148/c05.xhtml#46e84fa9-6504-4795-a2f5-c5d2ebfac1fc,"Show me the money” leads to another concept: the advantages of shifting from a cost-centered, manage to budget constraint, to the profit-centered, manage to value mindset. To repeat for emphasis, within a profit-center, investments and added costs are evaluated from the standpoint of value and return. A profit center mentality promotes initiative, agility, optimization, ownership, and investment for improvement. This mentality will clearly produce superior results in a complex operating or production enterprise. In contrast, a cost center contains no systemic incentives to optimize or improve.",
Operational Excellence: Journey to Creating Sustainable Value,CHAPTER 3: FOUNDATION PRINCIPLES,2020-10-09,https://learning.oreilly.com/library/view/-/9781118990148/,https://learning.oreilly.com/library/view/-/9781118990148/c03.xhtml,https://learning.oreilly.com/library/view/-/9781118990148/c03.xhtml#7dd8bfcc-5e4d-49e1-8195-fad871983164,Six phases of Operational Excellence.,Copy
Operational Excellence: Journey to Creating Sustainable Value,CHAPTER 3: FOUNDATION PRINCIPLES,2020-10-09,https://learning.oreilly.com/library/view/-/9781118990148/,https://learning.oreilly.com/library/view/-/9781118990148/c03.xhtml,https://learning.oreilly.com/library/view/-/9781118990148/c03.xhtml#4e30c4c7-6a10-4276-a860-84710cd9731a,"Consider the six D's listed in the following section as the Operational Excellence equivalent of 5S. All will be addressed and expanded in greater detail in subsequent sections in this and the following chapters:
Driven by opportunities to deliver greatest value to the enterprise—safely and sustainably
Demands strong, engaged leadership—clear vision, business/mission objectives and strategy, visible drive and enthusiasm, encouragement, and commitment to success
Defines program strategy and plan—meet all SHE (Safety, Health, and Environment), business/mission objectives, legal, regulatory, and community requirements
Develops and sustains working culture committed to honesty, integrity, mutual trust, excellence, persistence, and continuous improvement—organizational and individual commitment, pride, ownership, mutual support, empowerment, intolerance for deficiencies, and accountability
Depends on reliability—consistency, structure, standardization, minimizing risk, and variation
Directed with accurate data and information—identify and value opportunities for improvement, demonstrate results, and increased value",
Operational Excellence: Journey to Creating Sustainable Value,CHAPTER 3: FOUNDATION PRINCIPLES,2020-10-09,https://learning.oreilly.com/library/view/-/9781118990148/,https://learning.oreilly.com/library/view/-/9781118990148/c03.xhtml,https://learning.oreilly.com/library/view/-/9781118990148/c03.xhtml#afe7b3b4-87cf-4111-9499-0131e39a941c,"The Steering Team establishes overall objectives and sets the positive, supportive example for the Operational Excellence program. It approves improvement initiatives and monitors results for compliance with objectives. The Steering Team is a key ingredient to assure the success of Operational Excellence.",
Operational Excellence: Journey to Creating Sustainable Value,CHAPTER 2: APPLICATION OF OPERATIONAL EXCELLENCE,2020-10-09,https://learning.oreilly.com/library/view/-/9781118990148/,https://learning.oreilly.com/library/view/-/9781118990148/c02.xhtml,https://learning.oreilly.com/library/view/-/9781118990148/c02.xhtml#fca730ea-2d03-4df9-9707-d70e8976f0a6,Strategic and tactical elements of producing value.,Copy
Operational Excellence: Journey to Creating Sustainable Value,CHAPTER 1: OPERATIONAL EXCELLENCE—THE IMPERATIVE,2020-10-09,https://learning.oreilly.com/library/view/-/9781118990148/,https://learning.oreilly.com/library/view/-/9781118990148/c01.xhtml,https://learning.oreilly.com/library/view/-/9781118990148/c01.xhtml#15992117-f5ad-4301-bac2-65d3bc50dc38,Safely creating sustainable value.”,
Operational Excellence: Journey to Creating Sustainable Value,CHAPTER 1: OPERATIONAL EXCELLENCE—THE IMPERATIVE,2020-10-09,https://learning.oreilly.com/library/view/-/9781118990148/,https://learning.oreilly.com/library/view/-/9781118990148/c01.xhtml,https://learning.oreilly.com/library/view/-/9781118990148/c01.xhtml#e6065707-e0fc-4506-9dd4-f91720d4f8e8,"Operational refers to an operating enterprise, one that uses some physical means to produce and/or deliver a product and comply with a mission.",
Redefining Operational Excellence,Chapter 10: Getting Technology Out of Your Way,2020-10-09,https://learning.oreilly.com/library/view/-/9780814433973/,https://learning.oreilly.com/library/view/-/9780814433973/xhtml/chapter10.html,https://learning.oreilly.com/library/view/-/9780814433973/xhtml/chapter10.html#e82c9493-3a78-4b0c-9c41-1158951c68df,"ORGANIZATIONS NEED TO IMPROVE OPERATIONS BEFORE THEY IMPLEMENT NEW TECHNOLOGY. OTHERWISE THEY WILL AUTOMATE BAD PROCESSES, WHICH ONLY FACILITIES THE ABILITY TO MAKE OPERATIONAL MISTAKES AND BAD DECISIONS FASTER.",
Redefining Operational Excellence,Chapter 9: Industry Perspectives,2020-10-09,https://learning.oreilly.com/library/view/-/9780814433973/,https://learning.oreilly.com/library/view/-/9780814433973/xhtml/chapter09.html,https://learning.oreilly.com/library/view/-/9780814433973/xhtml/chapter09.html#00c0932a-6d5c-447e-b00b-c2c923127ba3,"IN ADDITION TO COMPETITIVE PRICING, RETAIL ORGANIZATIONS NEED TO PROVIDE SOMETHING CONSUMERS CAN’T GET ONLINE OR IN OTHER STORES–VALIDATION THAT THEY ARE MAKING THE RIGHT PURCHASE BASED ON THEIR UNIQUE SET OF CIRCUMSTANCES. MAKE CUSTOMERS FEEL COMFORTABLE ABOUT THEIR PURCHASES, AND THEY WILL COME BACK.",
Redefining Operational Excellence,Chapter 8: Centers of Excellence: Not So Much,2020-10-09,https://learning.oreilly.com/library/view/-/9780814433973/,https://learning.oreilly.com/library/view/-/9780814433973/xhtml/chapter08.html,https://learning.oreilly.com/library/view/-/9780814433973/xhtml/chapter08.html#ce23d0c2-eba1-4c63-8160-2baec49499ee,"Let’s get rid of the term center of excellence. It sounds great, but it has no practical application. We can talk in terms of centralizing functions where that makes sense, but we should no longer be talking about centers of excellence. We should be talking in terms of excellence across an entire organization.",
Redefining Operational Excellence,Chapter 7: Optimizing Speed Maximizes Profitability,2020-10-08,https://learning.oreilly.com/library/view/-/9780814433973/,https://learning.oreilly.com/library/view/-/9780814433973/xhtml/chapter07.html,https://learning.oreilly.com/library/view/-/9780814433973/xhtml/chapter07.html#d4ca3621-af10-46a4-abac-b467e5efdef2,"The most successful organizations are those that are able to move at their optimal speed at all times, recognizing that the organization’s optimal speed changes depending on the situation.",
Redefining Operational Excellence,Chapter 7: Optimizing Speed Maximizes Profitability,2020-10-08,https://learning.oreilly.com/library/view/-/9780814433973/,https://learning.oreilly.com/library/view/-/9780814433973/xhtml/chapter07.html,https://learning.oreilly.com/library/view/-/9780814433973/xhtml/chapter07.html#15b9be7b-1bb5-49c5-88c2-c15353d80797,"How fast are you going now?
How fast could you go (what is your potential top speed)?
What would happen if you were to achieve that top speed?
What are the key indicators you should use to determine when to slow down and when to speed up?
What plan do you need to put in place to maintain optimal speed?",
Redefining Operational Excellence,Chapter 7: Optimizing Speed Maximizes Profitability,2020-10-08,https://learning.oreilly.com/library/view/-/9780814433973/,https://learning.oreilly.com/library/view/-/9780814433973/xhtml/chapter07.html,https://learning.oreilly.com/library/view/-/9780814433973/xhtml/chapter07.html#62b54ea2-c68c-4cbc-881b-702ee9a46c52,Organizations that use their metrics as signals for governing their pace can achieve what I call responsible speed.,
Redefining Operational Excellence,Chapter 7: Optimizing Speed Maximizes Profitability,2020-10-08,https://learning.oreilly.com/library/view/-/9780814433973/,https://learning.oreilly.com/library/view/-/9780814433973/xhtml/chapter07.html,https://learning.oreilly.com/library/view/-/9780814433973/xhtml/chapter07.html#66b978d8-4a75-4704-9d8e-cc31b3e6a1bf,"Look at the different areas of your business—product commercialization, strategy development, customer acquisition, employee hiring, and any others that are important for your organization—and ask yourself whether you have achieved optimal speed.",
Redefining Operational Excellence,Chapter 7: Optimizing Speed Maximizes Profitability,2020-10-08,https://learning.oreilly.com/library/view/-/9780814433973/,https://learning.oreilly.com/library/view/-/9780814433973/xhtml/chapter07.html,https://learning.oreilly.com/library/view/-/9780814433973/xhtml/chapter07.html#dc2c7325-38f4-41b6-ae3b-438d2a9349db,optimal enterprise velocity and demonstrates why it’s important to manage the speed at which your organization does business in order to maximize profitability and performance.,
Redefining Operational Excellence,Chapter 6: Acquiring and Keeping the Customers You Want,2020-10-08,https://learning.oreilly.com/library/view/-/9780814433973/,https://learning.oreilly.com/library/view/-/9780814433973/xhtml/chapter06.html,https://learning.oreilly.com/library/view/-/9780814433973/xhtml/chapter06.html#fb49c055-e6d6-45c5-8adb-d013947b058a,Figure 6-1. The Exponential Value of Customer Retention,Copy
Redefining Operational Excellence,Chapter 6: Acquiring and Keeping the Customers You Want,2020-10-08,https://learning.oreilly.com/library/view/-/9780814433973/,https://learning.oreilly.com/library/view/-/9780814433973/xhtml/chapter06.html,https://learning.oreilly.com/library/view/-/9780814433973/xhtml/chapter06.html#d9b252fd-8120-4bc8-9d16-24891c2e8c5a,Figure 6-1. The Exponential Value of Customer Retention,
Redefining Operational Excellence,Chapter 3: Attracting and Retaining Top Talent: Don’t Settle for Second Best,2020-10-08,https://learning.oreilly.com/library/view/-/9780814433973/,https://learning.oreilly.com/library/view/-/9780814433973/xhtml/chapter03.html,https://learning.oreilly.com/library/view/-/9780814433973/xhtml/chapter03.html#3830f497-e23d-43ee-84a5-304aa90e2ab0,"There is a time for hiring and a time for recruiting. The difference is that when an organization recruits, it is targeting a specific person or people, whereas hiring is when there is an open position and anyone can apply.",
Redefining Operational Excellence,Chapter 3: Attracting and Retaining Top Talent: Don’t Settle for Second Best,2020-10-08,https://learning.oreilly.com/library/view/-/9780814433973/,https://learning.oreilly.com/library/view/-/9780814433973/xhtml/chapter03.html,https://learning.oreilly.com/library/view/-/9780814433973/xhtml/chapter03.html#454e4ebb-3d46-4fd2-a363-30a8c28111a8,"IF YOU WANT TO BECOME A GREAT LEADER, WORK ON BEING ADAPTABLE, PERCEPTIVE, DECISIVE, AND HUMBLE. REMEMBER: MANY OF THE GREAT LEADERS IN AN ORGANIZATION AREN’T IN THE EXECUTIVE SUITE.",
Redefining Operational Excellence,Chapter 2: Making Operational Excellence Happen,2020-10-08,https://learning.oreilly.com/library/view/-/9780814433973/,https://learning.oreilly.com/library/view/-/9780814433973/xhtml/chapter02.html,https://learning.oreilly.com/library/view/-/9780814433973/xhtml/chapter02.html#b6e1c177-54b1-4920-965f-484ea03e365e,Figure 2-3. The Four Phases of Operational Excellence,
Redefining Operational Excellence,Chapter 1: The Need for a New Definition,2020-10-08,https://learning.oreilly.com/library/view/-/9780814433973/,https://learning.oreilly.com/library/view/-/9780814433973/xhtml/chapter01.html,https://learning.oreilly.com/library/view/-/9780814433973/xhtml/chapter01.html#014adc82-0f09-4f7e-914e-f5e681561951,"Operational excellence is a mind-set, not a tool. It helps increase profitability, productivity, retention, engagement, empowerment, innovation, and many other drivers of an organization.",
Redefining Operational Excellence,Chapter 1: The Need for a New Definition,2020-10-08,https://learning.oreilly.com/library/view/-/9780814433973/,https://learning.oreilly.com/library/view/-/9780814433973/xhtml/chapter01.html,https://learning.oreilly.com/library/view/-/9780814433973/xhtml/chapter01.html#65014b32-11ce-432a-866d-512a4ba00da6,"Operational excellence is the constant pursuit of improved performance and profitability in all areas of your organization. It is about managing talent, driving innovation, aligning strategy and tactics, and enhancing customer engagement",
Redefining Operational Excellence,Chapter 1: The Need for a New Definition,2020-10-08,https://learning.oreilly.com/library/view/-/9780814433973/,https://learning.oreilly.com/library/view/-/9780814433973/xhtml/chapter01.html,https://learning.oreilly.com/library/view/-/9780814433973/xhtml/chapter01.html#e39b356e-1a88-45e6-beca-7490ad609090,Operational excellence comes from the ability to relentlessly pursue improvements in performance and profitability by focusing on value for the customer,
Redefining Operational Excellence,Chapter 1: The Need for a New Definition,2020-10-08,https://learning.oreilly.com/library/view/-/9780814433973/,https://learning.oreilly.com/library/view/-/9780814433973/xhtml/chapter01.html,https://learning.oreilly.com/library/view/-/9780814433973/xhtml/chapter01.html#b3ec29c6-e575-4d61-8fe0-0eddf1ad0c53,"Lean is an effective way to increase productivity for repeatable tasks, but it doesn’t help develop new ideas or strategies.",
Redefining Operational Excellence,Chapter 1: The Need for a New Definition,2020-10-08,https://learning.oreilly.com/library/view/-/9780814433973/,https://learning.oreilly.com/library/view/-/9780814433973/xhtml/chapter01.html,https://learning.oreilly.com/library/view/-/9780814433973/xhtml/chapter01.html#b5a891cf-f4bb-46ab-a83d-3a898e00d2e7,"The limitation with Lean is that it focuses on the removal of waste and the preservation of value, but not on the actual creation of value.",
Redefining Operational Excellence,Chapter 1: The Need for a New Definition,2020-10-08,https://learning.oreilly.com/library/view/-/9780814433973/,https://learning.oreilly.com/library/view/-/9780814433973/xhtml/chapter01.html,https://learning.oreilly.com/library/view/-/9780814433973/xhtml/chapter01.html#43692619-d742-4570-a88a-b9c6715124a8,"The old connotation of operational excellence—focused on manufacturing throughput, standardizing processes, and eliminating waste—is a relic",
Redefining Operational Excellence,Introduction,2020-10-08,https://learning.oreilly.com/library/view/-/9780814433973/,https://learning.oreilly.com/library/view/-/9780814433973/xhtml/introduction.html,https://learning.oreilly.com/library/view/-/9780814433973/xhtml/introduction.html#c116ef79-4ae8-47cd-81ce-e97a5273eb7b,"To achieve dramatic results, you must create a different culture for your organization—a culture that questions current operating models and focuses on adding value and optimizing speed.",
Redefining Operational Excellence,Introduction,2020-10-08,https://learning.oreilly.com/library/view/-/9780814433973/,https://learning.oreilly.com/library/view/-/9780814433973/xhtml/introduction.html,https://learning.oreilly.com/library/view/-/9780814433973/xhtml/introduction.html#bc8c00c1-b1ab-4ade-b399-4b2f371dde02,OPERATIONAL EXCELLENCE IS THE RELENTLESS PURSUIT of doing things better.,
The Five Dysfunctions of a Team: A Leadership Fable,43. TEAM ASSESSMENT,2020-08-16,https://learning.oreilly.com/library/view/-/9780787960759/,https://learning.oreilly.com/library/view/-/9780787960759/ch43.html,https://learning.oreilly.com/library/view/-/9780787960759/ch43.html#b085b550-6d1c-4c23-9e9a-5b3fa9aa4cd6,"___ 1. Team members are passionate and unguarded in their discussion of issues.___2. Team members call out one another's deficiencies or unproductive behaviors.___3. Team members know what their peers are working on and how they contribute to the collective good of the team.___4. Team members quickly and genuinely apologize to one another when they say or do something inappropriate or possibly damaging to the team.___5. Team members willingly make sacrifices (such as budget, turf, head count) in their departments or areas of expertise for the good of the team.___6. Team members openly admit their weaknesses and mistakes.___7. Team meetings are compelling, and not boring.___8. Team members leave meetings confident that their peers are completely committed to the decisions that were agreed on, even if there was initial disagreement.___9. Morale is significantly affected by the failure to achieve team goals.___10. During team meetings, the most important—and difficult—issues are put on the table to be resolved.___11. Team members are deeply concerned about the prospect of letting down their peers.___12. Team members know about one another's personal lives and are comfortable discussing them.___13. Team members end discussions with clear and specific resolutions and calls to action.___14. Team members challenge one another about their plans and approaches.___15. Team members are slow to seek credit for their own contributions, but quick to point out those of others.",
"Flask Web Development, 2nd Edition",14. Application Programming Interfaces,2020-07-27,https://learning.oreilly.com/library/view/-/9781491991725/,https://learning.oreilly.com/library/view/-/9781491991725/ch14.html,https://learning.oreilly.com/library/view/-/9781491991725/ch14.html#d5674edd-a9ae-4b85-bcf9-7389a531eea4,"def create_app(config_name):
# ...
from .api import api as api_blueprint
app.register_blueprint(api_blueprint, url_prefix='/api/v1')
# ...",
"Flask Web Development, 2nd Edition",14. Application Programming Interfaces,2020-07-27,https://learning.oreilly.com/library/view/-/9781491991725/,https://learning.oreilly.com/library/view/-/9781491991725/ch14.html,https://learning.oreilly.com/library/view/-/9781491991725/ch14.html#3d155262-d8c0-4a99-a9cb-386c4ec1a500,"The routes associated with a RESTful API form a self-contained subset of the application, so putting them in their own blueprint is the best way to keep them well organized.",
"Flask Web Development, 2nd Edition",7. Large Application Structure,2020-07-27,https://learning.oreilly.com/library/view/-/9781491991725/,https://learning.oreilly.com/library/view/-/9781491991725/ch07.html,https://learning.oreilly.com/library/view/-/9781491991725/ch07.html#56c6498f-677a-49b5-a233-f0eb7442c4b2,"When you need to build a perfect replica of the virtual environment, you can create a new virtual environment and run the following command on it:
(venv) $ pip install -r requirements.txt",
"Flask Web Development, 2nd Edition",7. Large Application Structure,2020-07-27,https://learning.oreilly.com/library/view/-/9781491991725/,https://learning.oreilly.com/library/view/-/9781491991725/ch07.html,https://learning.oreilly.com/library/view/-/9781491991725/ch07.html#ad9e1062-f186-4d62-9f49-3649976d42f6,"is a good practice for applications to include a requirements.txt file that records all the package dependencies, with the exact version numbers. This is important in case the virtual environment needs to be regenerated on a different machine, such as the machine on which the application will be deployed for production use. This file can be generated automatically by pip with the following command:
(venv) $ pip freeze >requirements.txt",
"Flask Web Development, 2nd Edition",7. Large Application Structure,2020-07-27,https://learning.oreilly.com/library/view/-/9781491991725/,https://learning.oreilly.com/library/view/-/9781491991725/ch07.html,https://learning.oreilly.com/library/view/-/9781491991725/ch07.html#3c49d1e2-da8d-46af-84e6-b9a67b3c2b60,"The url_for() function also supports a shorter format for endpoints in blueprints in which the blueprint name is omitted, such as url_for('.index'). With this notation, the blueprint name for the current request is used to complete the endpoint name. This effectively means that redirects within the same blueprint can use the shorter form, while redirects across blueprints must use the fully qualified endpoint name that includes the blueprint name.",
"Flask Web Development, 2nd Edition",7. Large Application Structure,2020-07-27,https://learning.oreilly.com/library/view/-/9781491991725/,https://learning.oreilly.com/library/view/-/9781491991725/ch07.html,https://learning.oreilly.com/library/view/-/9781491991725/ch07.html#ea8fced8-1de9-4125-919e-b46c0111a63a,"The difference with blueprints is that Flask applies a namespace to all the endpoints defined in a blueprint, so that multiple blueprints can define view functions with the same endpoint names without collisions. The namespace is the name of the blueprint (the first argument to the Blueprint constructor) and is separated from the endpoint name with a dot. The index() view function is then registered with endpoint name main.index and its URL can be obtained with url_for('main.index').",
"Flask Web Development, 2nd Edition",7. Large Application Structure,2020-07-27,https://learning.oreilly.com/library/view/-/9781491991725/,https://learning.oreilly.com/library/view/-/9781491991725/ch07.html,https://learning.oreilly.com/library/view/-/9781491991725/ch07.html#61da6382-1fb2-44d0-a778-c951bcc6cb3f,The blueprint is registered with the application inside the create_app() factory function,
"Flask Web Development, 2nd Edition",7. Large Application Structure,2020-07-27,https://learning.oreilly.com/library/view/-/9781491991725/,https://learning.oreilly.com/library/view/-/9781491991725/ch07.html,https://learning.oreilly.com/library/view/-/9781491991725/ch07.html#1dbc49b0-fb4d-41f4-8013-39552ae52d5d,"def create_app(config_name):
# ...
from .main import main as main_blueprint
app.register_blueprint(main_blueprint)
return app",
"Flask Web Development, 2nd Edition",7. Large Application Structure,2020-07-27,https://learning.oreilly.com/library/view/-/9781491991725/,https://learning.oreilly.com/library/view/-/9781491991725/ch07.html,https://learning.oreilly.com/library/view/-/9781491991725/ch07.html#488a2a9a-14cd-438a-ab25-e485b6634549,"from flask import Blueprint
main = Blueprint('main', __name__)
from . import views, errors",
"Flask Web Development, 2nd Edition",7. Large Application Structure,2020-07-27,https://learning.oreilly.com/library/view/-/9781491991725/,https://learning.oreilly.com/library/view/-/9781491991725/ch07.html,https://learning.oreilly.com/library/view/-/9781491991725/ch07.html#9db9b8dd-deaf-4b58-9ca2-dba615f48cae,"The routes of the application are stored in an app/main/views.py module inside the package, and the error handlers are in app/main/errors.py. Importing these modules causes the routes and error handlers to be associated with the blueprint. It is important to note that the modules are imported at the bottom of the app/main/__init__.py script to avoid errors due to circular dependencies. In this particular example the problem is that app/main/views.py and app/main/errors.py in turn are going to import the main blueprint object, so the imports are going to fail unless the circular reference occurs after main is defined.",
"Flask Web Development, 2nd Edition",7. Large Application Structure,2020-07-27,https://learning.oreilly.com/library/view/-/9781491991725/,https://learning.oreilly.com/library/view/-/9781491991725/ch07.html,https://learning.oreilly.com/library/view/-/9781491991725/ch07.html#0479fd34-267a-40f6-8cd4-9e153bb95320,"Blueprints are created by instantiating an object of class Blueprint. The constructor for this class takes two required arguments: the blueprint name and the module or package where the blueprint is located. As with applications, Python’s __name__ variable is in most cases the correct value for the second argument.",
"Flask Web Development, 2nd Edition",7. Large Application Structure,2020-07-27,https://learning.oreilly.com/library/view/-/9781491991725/,https://learning.oreilly.com/library/view/-/9781491991725/ch07.html,https://learning.oreilly.com/library/view/-/9781491991725/ch07.html#f23138aa-e6b1-4ca0-85d4-0f8c78a2c456,"A blueprint is similar to an application in that it can also define routes and error handlers. The difference is that when these are defined in a blueprint they are in a dormant state until the blueprint is registered with an application, at which point they become part of it. Using a blueprint defined in the global scope, the routes and error handlers of the application can be defined in almost the same way as in the single-script application.",
"Flask Web Development, 2nd Edition",3. Templates,2020-07-27,https://learning.oreilly.com/library/view/-/9781491991725/,https://learning.oreilly.com/library/view/-/9781491991725/ch03.html,https://learning.oreilly.com/library/view/-/9781491991725/ch03.html#55dfaeac-e0f5-4574-950c-e7cbb605309f,"Variables can be modified with filters, which are added after the variable name with a pipe character as separator. For example, the following template shows the name variable capitalized:
Hello, {{ name|capitalize }}",
"Flask Web Development, 2nd Edition",2. Basic Application Structure,2020-07-27,https://learning.oreilly.com/library/view/-/9781491991725/,https://learning.oreilly.com/library/view/-/9781491991725/ch02.html,https://learning.oreilly.com/library/view/-/9781491991725/ch02.html#949eacaf-4bae-4957-ae0a-468092a24c7d,"Request hooks are implemented as decorators. These are the four hooks supported by Flask:
before_request
Registers a function to run before each request.
before_first_request
Registers a function to run only before the first request is handled. This can be a convenient way to add server initialization tasks.
after_request
Registers a function to run after each request, but only if no unhandled exceptions occurred.
teardown_request
Registers a function to run after each request, even if unhandled exceptions occurred.",
"Flask Web Development, 2nd Edition",2. Basic Application Structure,2020-07-27,https://learning.oreilly.com/library/view/-/9781491991725/,https://learning.oreilly.com/library/view/-/9781491991725/ch02.html,https://learning.oreilly.com/library/view/-/9781491991725/ch02.html#1bb65c6f-3400-4be0-a662-bdb5374ed408,Contexts enable Flask to make certain variables globally accessible to a thread without interfering with the other threads.,
"Flask Web Development, 2nd Edition",2. Basic Application Structure,2020-07-27,https://learning.oreilly.com/library/view/-/9781491991725/,https://learning.oreilly.com/library/view/-/9781491991725/ch02.html,https://learning.oreilly.com/library/view/-/9781491991725/ch02.html#0d2b6c0d-7da9-47a9-ba20-1d03c2e70158,"(venv) $ export FLASK_APP=hello.py
(venv) $ export FLASK_DEBUG=1
(venv) $ flask run",
"Flask Web Development, 2nd Edition",2. Basic Application Structure,2020-07-27,https://learning.oreilly.com/library/view/-/9781491991725/,https://learning.oreilly.com/library/view/-/9781491991725/ch02.html,https://learning.oreilly.com/library/view/-/9781491991725/ch02.html#c3aa9f2f-ecc6-487b-b065-e73cf20a596c,"By default, debug mode is disabled. To enable it, set a FLASK_DEBUG=1 environment variable before invoking flask run:",
"Flask Web Development, 2nd Edition",2. Basic Application Structure,2020-07-27,https://learning.oreilly.com/library/view/-/9781491991725/,https://learning.oreilly.com/library/view/-/9781491991725/ch02.html,https://learning.oreilly.com/library/view/-/9781491991725/ch02.html#82eaddad-be97-4a94-8542-bcf1e6333873,"@app.route('/user/<name>')
def user(name):
return '<h1>Hello, {}!</h1>'.format(name)",
"Flask Web Development, 2nd Edition",2. Basic Application Structure,2020-07-27,https://learning.oreilly.com/library/view/-/9781491991725/,https://learning.oreilly.com/library/view/-/9781491991725/ch02.html,https://learning.oreilly.com/library/view/-/9781491991725/ch02.html#f1d788e9-f148-4d68-ae79-5022b75dff9f,Functions like index() that handle application URLs are called view functions.,
"Flask Web Development, 2nd Edition",2. Basic Application Structure,2020-07-27,https://learning.oreilly.com/library/view/-/9781491991725/,https://learning.oreilly.com/library/view/-/9781491991725/ch02.html,https://learning.oreilly.com/library/view/-/9781491991725/ch02.html#16c9901c-ee02-42bc-8254-11303be6449d,"def index():
return '<h1>Hello World!</h1>'
app.add_url_rule('/', 'index', index)",
"Flask Web Development, 2nd Edition",1. Installation,2020-07-27,https://learning.oreilly.com/library/view/-/9781491991725/,https://learning.oreilly.com/library/view/-/9781491991725/ch01.html,https://learning.oreilly.com/library/view/-/9781491991725/ch01.html#1f00e85c-d017-4162-9b50-9b1f015e5d4e,"Flask has three main dependencies. The routing, debugging, and Web Server Gateway Interface (WSGI) subsystems come from Werkzeug; the template support is provided by Jinja2; and the command-line integration comes from Click. These dependencies are all authored by Armin Ronacher, the author of Flask.",
Kotlin in Action,Chapter 11. DSL construction,2020-07-10,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_022.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_022.html#b4041525-718c-4533-9ef8-aeaa02cde820,wo new features of Kotlin that can help you build DSLs: lambdas with receivers and the invoke convention,
Kotlin in Action,Chapter 11. DSL construction,2020-07-10,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_022.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_022.html#5a1063e7-1d76-43ab-95d4-4e9d51bbc441,"The invoke method isn’t restricted to any specific signature. You can define it with any number of parameters and with any return type,
or even define multiple overloads of invoke with different parameter types",
Kotlin in Action,Chapter 11. DSL construction,2020-07-10,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_022.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_022.html#24efb0e5-ca83-4fc8-9a3f-014793e4ab67,"the invoke convention does the same thing, except that the brackets are replaced with parentheses. A class for which the invoke method with an operator modifier is defined can be called as a function",
Kotlin in Action,Chapter 11. DSL construction,2020-07-10,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_022.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_022.html#8fa570f5-7a94-41b7-87b7-6afbc4d670b2,"we call this an internal
DSL: the code intended to accomplish a specific task (building SQL queries) is implemented as a library in a general-purpose
language (Kotlin).",
Kotlin in Action,Chapter 11. DSL construction,2020-07-10,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_022.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_022.html#89ea298d-0522-42d7-b50c-1dd62387bc46,"The external DSL you’re going to use is SQL; the internal one is provided by the Exposed framework
(https://github.com/JetBrains/Exposed), which is a Kotlin framework for database access.",
Kotlin in Action,Chapter 11. DSL construction,2020-07-10,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_022.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_022.html#9048fe25-767d-4371-a13b-b414e6c96765,"Another important point is that DSLs tend to be declarative, as opposed to general-purpose languages, most of which are imperative.
Whereas an imperative language describes the exact sequence of steps required to perform an operation, a declarative language describes the desired result and leaves the execution details to the engine that interprets it",
Kotlin in Action,Chapter 10. Annotations and reflection,2020-07-09,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_021.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_021.html#dadbe404-5fc5-4fe2-b4a4-0be808d24387,"The KFunction and KProperty interfaces both extend KCallable, which provides the generic call method.
The KCallable.callBy method can be used to invoke methods with default parameter values",
Kotlin in Action,Chapter 10. Annotations and reflection,2020-07-09,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_021.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_021.html#85b3d438-eab2-4ec3-8088-31080a042ee7,Hierarchy of interfaces in the Kotlin reflection API,copy image
Kotlin in Action,Chapter 10. Annotations and reflection,2020-07-09,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_021.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_021.html#2ac53015-fecc-439d-bd96-06bc6d42f456,"KCallable is a superinterface for functions and properties. It declares the call method, which allows you to call the corresponding function or the getter of the property",
Kotlin in Action,Chapter 10. Annotations and reflection,2020-07-09,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_021.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_021.html#e606929b-4a14-47e8-be72-78144612c6bc,"Whenever JKid reads a nested company object for a Person instance, it creates and deserializes an instance of CompanyImpl and stores it in the company property. To specify this, you use CompanyImpl::class as an argument of the @DeserializeInterface annotation. In general, to refer to a class, you use its name followed by the ::class keyword.",
Kotlin in Action,Chapter 10. Annotations and reflection,2020-07-09,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_021.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_021.html#6950792b-3e1b-4ebf-99eb-aecc4cf2cd38,"interface Company {
val name: String
}
data class CompanyImpl(override val name: String) : Company
data class Person(
val name: String,
@DeserializeInterface(CompanyImpl::class) val company: Company
)",
Kotlin in Action,Chapter 10. Annotations and reflection,2020-07-09,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_021.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_021.html#42b83d69-82b3-4f0a-87a4-dca17031373b,"data class Person(
@JsonName(""alias"") val firstName: String,
@JsonExclude val age: Int? = null
)",
Kotlin in Action,Chapter 10. Annotations and reflection,2020-07-09,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_021.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_021.html#cfcdd07a-944e-4adf-b0f4-9b041ea5b09b,"The @JsonExclude annotation is used to mark a property that should be excluded from serialization and deserialization.
The @JsonName annotation lets you specify that the key in the key/value pair representing the property should be the given string, not
the name of the property.",
Kotlin in Action,Chapter 10. Annotations and reflection,2020-07-09,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_021.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_021.html#62f06386-0d6d-4ac3-a75e-45b82d1803d0,"const val TEST_TIMEOUT = 100L
@Test(timeout = TEST_TIMEOUT) fun testMethod() { ... }",
Kotlin in Action,Chapter 10. Annotations and reflection,2020-07-09,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_021.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_021.html#9592ba6f-5446-46de-8431-a2bebd3c6fb6,"To use a property
as an annotation argument, you need to mark it with a const modifier",
Kotlin in Action,Chapter 10. Annotations and reflection,2020-07-09,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_021.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_021.html#142d39b6-d8ae-4ad3-b046-c1e6f5d63dd8,An annotation allows you to associate additional metadata with a declaration,
Kotlin in Action,Chapter 10. Annotations and reflection,2020-07-09,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_021.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_021.html#b55814fe-cdbc-4378-a8c3-2a9194e35d08,"You
can use annotations to assign library-specific semantics to those classes; and reflection allows you to analyze the structure
of the classes at runtime.",
Kotlin in Action,Chapter 9. Generics,2020-07-08,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_020.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_020.html#92b71547-8820-428b-82a0-a8f4fa4f671f,"the special star-projection syntax you can use to indicate that you have no information about a generic argument. For example, a list of elements of an unknown type is expressed using that syntax as List<*>.",
Kotlin in Action,Chapter 9. Generics,2020-07-08,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_020.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_020.html#6f063563-4510-4aae-afcc-beb63c62d29b,"You can specify a variance modifier on any usage of a type parameter in a type declaration: for a parameter type (as in listing 9.16), local variable type, function return type, and so on. What happens here is called type projection: we say that source isn’t a regular MutableList, but a projected (restricted) one. You can only call methods that return the generic type parameter or, strictly speaking, use it in the out position only.",
Kotlin in Action,Chapter 9. Generics,2020-07-08,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_020.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_020.html#3639b36c-7a92-4372-b071-c3a8ac30fdce,The out keyword on a type parameter of the class requires that all methods using T have T only in out positions and not in in positions,
Kotlin in Action,Chapter 9. Generics,2020-07-08,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_020.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_020.html#14bc5184-3d22-464c-ae4a-97fbed460f15,"In Kotlin, to declare the class to be covariant on a certain type parameter, you put the out keyword before the name of the type parameter:","interface Producer<out T> {
fun produce(): T
}"
Kotlin in Action,Chapter 9. Generics,2020-07-08,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_020.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_020.html#cb3033c6-101b-4f55-b92a-d701e043296d,"The term supertype is the opposite of subtype. If A is a subtype of B, then B is a supertype of A.",
Kotlin in Action,Chapter 9. Generics,2020-07-08,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_020.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_020.html#7de69044-e922-4965-a7d2-b6e85d1d7130,A type B is a subtype of a type A if you can use the value of the type B whenever a value of the type A is required.,
Kotlin in Action,Chapter 9. Generics,2020-07-08,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_020.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_020.html#359ccc0b-0099-4a78-a6af-87dacba5eb35,"The concept of variance describes how types with the same base type and different type arguments relate to each other: for example, List<String> and List<Any>.",
Kotlin in Action,Chapter 9. Generics,2020-07-08,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_020.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_020.html#188c26a3-2117-48be-9a79-5f292d5d3614,"Type parameters of inline
functions can be reified, which means you can refer to actual type arguments at runtime.",
Kotlin in Action,Chapter 9. Generics,2020-07-08,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_020.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_020.html#802d0f23-6cc9-41a0-9b88-ad85a91e98a9,"In the previous example, you check whether a value is a List, and you don’t get any information about its element type.",
Kotlin in Action,Chapter 9. Generics,2020-07-08,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_020.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_020.html#96e95a59-bfce-4ff4-baeb-47859d221604,"As we stated earlier, Kotlin doesn’t let you use a generic type without specifying type arguments. Thus you may wonder how
to check that the value is a list, rather than a set or another object. You can do that by using the special star projection syntax:
if (value is List<*>) { ... }",
Kotlin in Action,Chapter 9. Generics,2020-07-08,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_020.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_020.html#32184a98-12a8-4dfa-9cb6-30a83f8105ea,"As you probably know, generics on the JVM are normally implemented through type erasure, meaning the type arguments of an instance of a generic class aren’t preserved at runtime.",
Kotlin in Action,Chapter 9. Generics,2020-07-08,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_020.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_020.html#6e4813d4-5f3c-4b3d-978e-d93af0447c72,"If you want to guarantee that a non-null type will always be substituted for a type parameter, you can achieve this by specifying a constraint. If you don’t have
any restrictions other than nullability, you can use Any as the upper bound, replacing the default Any?",
Kotlin in Action,Chapter 9. Generics,2020-07-08,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_020.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_020.html#7c60a644-6f3b-4fd0-ad87-ab0b9d7b0d0f,"To specify a constraint, you put a colon after the type parameter name, followed by the type that’s the upper bound for the
type parameter; see figure 9.2. In Java, you use the keyword extends to express the same concept: <T extends Number> T sum(List<T> list).",fun <T: number> List<T>.sum(): T
Kotlin in Action,Chapter 9. Generics,2020-07-08,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_020.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_020.html#af545041-9bc7-41cd-9579-e854ee5f20e4,"Type parameter constraints let you restrict the types that can be used as type arguments for a class or function. For example, consider a function that
calculates the sum of elements in a list. It can be used on a List<Int> or a List<Double>, but not, for example, a List<String>.",
Kotlin in Action,Chapter 9. Generics,2020-07-08,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_020.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_020.html#d056c167-c52d-4ec1-b796-ddd6908adad8,the lambda parameter has a generic type T,
Kotlin in Action,Chapter 9. Generics,2020-07-08,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_020.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_020.html#230e5015-d1b2-40dc-863d-35ca925a5b43,The function’s type parameter T is used in the receiver type and in the return type; both of them are List<T>,Use of generics
Kotlin in Action,Chapter 9. Generics,2020-07-08,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_020.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_020.html#c336a6e1-6137-4ca4-b3bd-8e7c6885c1dc,"If you’re going to write a function that works with a list, and you want it to work with any list (a generic one), not a list
of elements of a specific type, you need to write a generic function. A generic function has type parameters of its own. These type parameters must be replaced with the specific type arguments
on each function invocation.",
Kotlin in Action,Chapter 8. Higher-order functions: lambdas as parameters and return values,2020-07-08,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_019.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_019.html#b5f4ef54-b6d6-4393-a421-11e83ce40831,"The rule is simple: return returns from the closest function declared using the fun keyword. Lambda expressions don’t use the fun keyword, so a return in a lambda returns from the outer function.",
Kotlin in Action,Chapter 8. Higher-order functions: lambdas as parameters and return values,2020-07-08,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_019.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_019.html#3e51eebb-7010-4ff0-bd84-fd7e8657a764,people.filter(fun (person) = person.age < 30),
Kotlin in Action,Chapter 8. Higher-order functions: lambdas as parameters and return values,2020-07-08,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_019.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_019.html#4209c7f8-1169-4640-b6e6-1819eaf4afcb,"people.filter(fun (person): Boolean {
return person.age < 30
})
Anonymous functions follow the same rules as regular functions for specifying the return type. Anonymous functions with a
block body, such as the one in listing 8.23, require the return type to be specified explicitly. If you use an expression body, you can omit the return type.",
Kotlin in Action,Chapter 8. Higher-order functions: lambdas as parameters and return values,2020-07-08,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_019.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_019.html#f8586765-1359-4bef-989d-3f1001ad05ce,"Alternatively, the name of the function that takes this lambda as an argument can be used as a label",
Kotlin in Action,Chapter 8. Higher-order functions: lambdas as parameters and return values,2020-07-08,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_019.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_019.html#0663c674-a195-4674-a01c-0fd47689315e,"To label a lambda expression, put the label name (which can be any identifier), followed by the @ character, before the opening curly brace of the lambda. To return from a lambda, put the @ character followed by the label name after the return keyword.",
Kotlin in Action,Chapter 8. Higher-order functions: lambdas as parameters and return values,2020-07-08,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_019.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_019.html#3cce60e7-1114-4c0d-8291-32f8b0f98ba8,"You can write a local return from a lambda expression as well. A local return in a lambda is similar to a break expression in a for loop. It stops the execution of the lambda and continues execution of the code from which the lambda was invoked. To distinguish a local return from a non-local
one, you use labels.",
Kotlin in Action,Chapter 8. Higher-order functions: lambdas as parameters and return values,2020-07-08,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_019.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_019.html#dd044b40-ee8a-4934-952b-afc5bd9696bd,"If you use the return keyword in a lambda, it returns from the function in which you called the lambda, not just from the lambda itself. Such a return statement is called a non-local return, because it returns from a larger block than the block containing the return statement.",
Kotlin in Action,Chapter 8. Higher-order functions: lambdas as parameters and return values,2020-07-08,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_019.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_019.html#87a5141e-d403-488a-9237-27c1a5b3a6bb,"The use function is an extension function called on a closable resource; it receives a lambda as an argument. The function calls
the lambda and ensures that the resource is closed, regardless of whether the lambda completes normally or throws an exception.
Of course, the use function is inlined, so its use doesn’t incur any performance overhead.",
Kotlin in Action,Chapter 8. Higher-order functions: lambdas as parameters and return values,2020-07-08,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_019.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_019.html#e1258c9c-3597-46f5-b1fe-a40af66bff16,"The Kotlin standard library defines another function called withLock, which has a more idiomatic API for the same task: it’s an extension function on the Lock interface",
Kotlin in Action,Chapter 8. Higher-order functions: lambdas as parameters and return values,2020-07-08,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_019.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_019.html#a0bdfe61-957f-433b-b0ab-be81b795b7d6,"Using the inline keyword is likely to improve performance only with functions that take lambdas as arguments; all other cases require additional
measuring and investigation.",
Kotlin in Action,Chapter 8. Higher-order functions: lambdas as parameters and return values,2020-07-08,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_019.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_019.html#23768452-fa10-4ee4-bfd3-6ca612e3852e,"If the number of elements to process is large, and the overhead of an intermediate collection becomes a concern, you can use
a sequence instead, by adding an as-Sequence call to the chain. But as you saw in the previous section, lambdas used to process a sequence aren’t inlined. Each intermediate
sequence is represented as an object storing a lambda in its field, and the terminal operation causes a chain of calls through
each intermediate sequence to be performed. Therefore, even though operations on sequences are lazy, you shouldn’t strive
to insert an asSequence call into every chain of collection operations in your code. This helps only for large collections; smaller ones can be processed
nicely with regular collection operations.",
Kotlin in Action,Chapter 8. Higher-order functions: lambdas as parameters and return values,2020-07-08,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_019.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_019.html#5604332e-6b49-48ea-9020-d3a7243dd13a,"println(people.filter { it.age > 30 }
... .map(Person::name))
[Bob]
This example uses a lambda expression and a member reference. Once again, both filter and map are declared as inline, so their bodies are inlined, and no extra classes or objects are created. But the code creates an intermediate collection
to store the result of filtering the list. The code generated from the filter function adds elements to that collection, and the code generated from map reads from it.",
Kotlin in Action,Chapter 8. Higher-order functions: lambdas as parameters and return values,2020-07-08,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_019.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_019.html#022cfca5-be74-4512-940d-e79b57cb8cb0,"f you have a function that expects two or more lambdas as arguments, you may choose to inline only some of them. This makes
sense when one of the lambdas is expected to contain a lot of code or is used in a way that doesn’t allow inlining. You can
mark the parameters that accept such non-inlineable lambdas with the noinline modifier:
inline fun foo(inlined: () -> Unit, noinline notInlined: () -> Unit) {
// ...
}",
Kotlin in Action,Chapter 8. Higher-order functions: lambdas as parameters and return values,2020-07-08,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_019.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_019.html#37ceef27-b114-4e90-a548-6abaeaf757b5,"When you declare a function as inline, its body is inlined—in other words, it’s substituted directly into places where the function is called instead of being
invoked normally",
Kotlin in Action,Chapter 8. Higher-order functions: lambdas as parameters and return values,2020-07-08,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_019.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_019.html#703f6f93-8784-445a-b887-5998599eaf68,"If you mark a function with
the inline modifier, the compiler won’t generate a function call when this function is used and instead will replace every call to the
function with the actual code implementing the function",
Kotlin in Action,Chapter 8. Higher-order functions: lambdas as parameters and return values,2020-07-08,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_019.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_019.html#995b6df7-b5d5-4435-b652-52b506cf25c7,a higher-order function is a function that takes another function as an argument or returns one,
Kotlin in Action,Chapter 7. Operator overloading and other conventions,2020-07-07,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_018.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_018.html#b75fc8c6-9049-41de-93db-236283df6545,"class Person(
val name: String, age: Int, salary: Int
) : PropertyChangeAware() {
var age: Int by ObservableProperty(age, changeSupport)
var salary: Int by ObservableProperty(salary, changeSupport)
}
Through the by keyword, the Kotlin compiler does automatically what you did manually in the previous version of the code. Compare this code
to the previous version of the Person class: the generated code when you use delegated properties is very similar. The object to the right of by is called the delegate. Kotlin automatically stores the delegate in a hidden property and calls getValue and setValue on the delegate when you access or modify the main property.",
Kotlin in Action,Chapter 7. Operator overloading and other conventions,2020-07-07,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_018.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_018.html#993ef69b-cc50-4e7c-b05b-8ab86fb02da8,"class Person(val name: String) {
val emails by lazy { loadEmails(this) }
}
The lazy function returns an object that has a method called getValue with the proper signature, so you can use it together with the by keyword to create a delegated property. The argument of lazy is a lambda that it calls to initialize the value. The lazy function is thread-safe by default; and if you need to, you can specify additional options to tell it which lock to use or
to bypass the synchronization entirely if the class is never used in a multithreaded environment.",
Kotlin in Action,Chapter 7. Operator overloading and other conventions,2020-07-07,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_018.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_018.html#75df2f24-3bb3-4dde-959f-a49ad1dea24b,"delegated properties. This feature lets you easily implement properties that work in a more complex way than storing values in backing fields,
without duplicating the logic in each accessor",
Kotlin in Action,Chapter 7. Operator overloading and other conventions,2020-07-07,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_018.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_018.html#e52128f4-3595-4308-be05-e347f97e6f23,"The foundation for this feature is delegation: a design pattern where an object, instead of performing a task, delegates that task to another helper object. The helper
object is called a delegate.",
Kotlin in Action,Chapter 7. Operator overloading and other conventions,2020-07-07,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_018.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_018.html#c52571be-6a23-413b-9b66-4f3178746445,"A simpler way to return multiple values from a function is to use the Pair and Triple classes from the standard library. It’s less expressive, because those classes don’t make it clear what’s contained in the
returned object, but it requires less code because you don’t need to define your own class.",
Kotlin in Action,Chapter 7. Operator overloading and other conventions,2020-07-07,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_018.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_018.html#c93f3fa7-f720-47f2-8cf4-a93ac1c1a47b,One of the main use cases where destructuring declarations are helpful is returning multiple values from a function,
Kotlin in Action,Chapter 7. Operator overloading and other conventions,2020-07-07,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_018.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_018.html#60996b4a-36b4-4ca0-ab60-194e2dc764f5,"Now that you’re familiar with the principle of conventions,
we can look at the final feature: destructuring declarations. This feature allows you to unpack a single composite value and use it to initialize several separate variables.",
Kotlin in Action,Chapter 7. Operator overloading and other conventions,2020-07-07,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_018.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_018.html#5c4cf066-29a8-4df4-be35-b1d4fadcf8bf,The .. operator is a concise way to call the rangeTo function,
Kotlin in Action,Chapter 7. Operator overloading and other conventions,2020-07-07,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_018.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_018.html#40f7ce23-e4e3-4d7d-98e9-414d1476ab5e,"To create a range, you use the .. syntax: for instance, 1..10",
Kotlin in Action,Chapter 7. Operator overloading and other conventions,2020-07-07,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_018.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_018.html#c02685d0-9c2c-4c3b-af55-5228ce1a1921,An open range is a range that doesn’t include its ending point.,
Kotlin in Action,Chapter 7. Operator overloading and other conventions,2020-07-07,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_018.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_018.html#f9483f7f-a1a7-4899-9409-4757f384a682,"In the implementation of Rectangle.contains, you use the until standard library function to build an open range and then you use the in operator on a range to check that a point belongs to it.",
Kotlin in Action,Chapter 7. Operator overloading and other conventions,2020-07-07,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_018.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_018.html#064fc2ee-add7-4f48-8ecb-70449304f125,"One other operator supported by collections is the in operator, which is used to check whether an object belongs to a collection. The corresponding function is called contains.",
Kotlin in Action,Chapter 7. Operator overloading and other conventions,2020-07-07,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_018.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_018.html#5898cace-55a6-4dba-8022-3c94c21e88de,"To get or set an element
by index, you use the syntax a[b] (called the index operator). The in operator can be used to check whether an element is in a collection or range and also to iterate over a collection. You can
add those operations for your own classes that act as collections",
Kotlin in Action,Chapter 7. Operator overloading and other conventions,2020-07-07,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_018.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_018.html#749313b3-89ab-45c7-a8ff-864eb4a52d28,"All Java classes that implement the Comparable interface can be compared in Kotlin using the concise operator syntax:
>>> println(""abc"" < ""bac"")
true
You don’t need to add any extensions to make that work.",
Kotlin in Action,Chapter 7. Operator overloading and other conventions,2020-07-07,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_018.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_018.html#4336a305-a429-4d1c-a026-d0fbd5d2d452,"Kotlin supports not only the + operation but += as well. Operators such as +=, -=, and so on are called compound assignment operators.",
Kotlin in Action,Chapter 7. Operator overloading and other conventions,2020-07-07,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_018.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_018.html#7a13f4c6-9b52-48ab-9b48-95ab5c02fb27,Kotlin operators don’t automatically support commutativity (the ability to swap the left and right sides of an operator).,
Kotlin in Action,Chapter 7. Operator overloading and other conventions,2020-07-07,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_018.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_018.html#500beb01-81e9-4357-9ab6-a6453e1ca73b,"operator fun Point.plus(other: Point): Point {
return Point(x + other.x, y + other.y)
}",
Kotlin in Action,Chapter 7. Operator overloading and other conventions,2020-07-07,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_018.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_018.html#f188e78e-f798-44b9-94be-d3d97a7b9d86,"As an alternative to declaring the operator as a member, you can define the operator as an extension function",
Kotlin in Action,Chapter 7. Operator overloading and other conventions,2020-07-07,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_018.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_018.html#a31b0e97-d7c4-4bda-9b78-97a5f0975412,"Note how you use the operator keyword to declare the plus function. All functions used to overload operators need to be marked with that keyword. This makes it explicit that you intend
to use the function as an implementation of the corresponding convention",
Kotlin in Action,Chapter 7. Operator overloading and other conventions,2020-07-07,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_018.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_018.html#781e487a-3437-4498-865e-0584fa502b68,"if your class defines a special method named plus, then, by convention, you can use the + operator on instances of this class. Because of that, in Kotlin we refer to this technique as conventions.",
Kotlin in Action,Chapter 6. The Kotlin type system,2020-07-06,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_016.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_016.html#1b43ea82-74b2-4166-9853-81c18654f967,Table 6.1. Collection-creation functions,copy table
Kotlin in Action,Chapter 6. The Kotlin type system,2020-07-06,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_016.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_016.html#5f3463b2-3910-45b1-a2e1-b3206ac15265,"List<Int?> is a list that can hold values of type Int?: in other words, Int or null",
Kotlin in Action,Chapter 6. The Kotlin type system,2020-07-06,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_016.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_016.html#f6f117db-9ebe-4876-a84f-6b00d09745d5,isEmptyOrNull and isBlankOrNull can be called with a receiver of type String?.,
Kotlin in Action,Chapter 6. The Kotlin type system,2020-07-06,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_016.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_016.html#0ccb6509-a139-430a-809d-bbaf97f02f1a,"isEmpty and isBlank, defined as extensions of String in the Kotlin standard library",
Kotlin in Action,Chapter 6. The Kotlin type system,2020-07-06,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_016.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_016.html#e96cd17a-2987-469a-b454-45575bf26fd4,Another constructor takes a size and a lambda used to initialize each element.,
Kotlin in Action,Chapter 6. The Kotlin type system,2020-07-06,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_016.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_016.html#8caa753a-deaf-4f49-a05d-ce35405d8de6,"The factory function (intArrayOf for IntArray, and so on for other array types)",
Kotlin in Action,Chapter 6. The Kotlin type system,2020-07-06,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_016.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_016.html#31ffa76f-955d-4134-9997-302b81161ec2,The constructor of the type takes a size parameter and returns an array initialized with default values for the corresponding primitive type (usually zeros).,
Kotlin in Action,Chapter 6. The Kotlin type system,2020-07-06,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_016.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_016.html#e77ed5e9-6637-4cde-82e6-3098dad30b40,"To create an array of a primitive type, you have the following options:",
Kotlin in Action,Chapter 6. The Kotlin type system,2020-07-06,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_016.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_016.html#8322db41-38ed-40e6-b33c-8a91ffa6117e,"The Array constructor takes the size of the array and a lambda, and initializes each array element by calling the lambda",
Kotlin in Action,Chapter 6. The Kotlin type system,2020-07-06,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_016.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_016.html#28ff43cc-cd29-44b6-82d6-a41f6adb494e,The arrayOfNulls function,
Kotlin in Action,Chapter 6. The Kotlin type system,2020-07-06,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_016.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_016.html#4283152f-99c8-4ff7-a5aa-199186053dc8,The arrayOf function,
Kotlin in Action,Chapter 6. The Kotlin type system,2020-07-06,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_016.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_016.html#9d3fe5cb-1592-41fd-b8a1-811bd9c558b4,"To create an array in Kotlin, you have the following possibilities:",
Kotlin in Action,Chapter 6. The Kotlin type system,2020-07-06,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_016.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_016.html#9acf6c04-43c5-40f6-9cf6-a1fcf1bc80e9,every Java collection interface has two representations in Kotlin: a read-only one and a mutable one,
Kotlin in Action,Chapter 6. The Kotlin type system,2020-07-06,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_016.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_016.html#636a65e5-7bf5-4609-b0e7-e11f3973bdb9,"If a function takes a parameter that is a Collection but not a MutableCollection, you know it’s not going to modify the collection, but only read data from it.",
Kotlin in Action,Chapter 6. The Kotlin type system,2020-07-06,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_016.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_016.html#6a9c1462-eb47-46a2-852d-87dc57e7c8a9,fun f(): Unit { ... },
Kotlin in Action,Chapter 6. The Kotlin type system,2020-07-06,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_016.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_016.html#b83752bd-2af1-47d5-9eb5-2de25eac904e,The Unit type in Kotlin fulfills the same function as void in Java.,
Kotlin in Action,Chapter 6. The Kotlin type system,2020-07-06,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_016.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_016.html#69566e53-bbac-4d21-a34c-c2a8fc700102,"Note that Any is a non-nullable type, so a variable of the type Any can’t hold the value null. If you need a variable that can hold any possible value in Kotlin, including null, you must use the Any? type.",
Kotlin in Action,Chapter 6. The Kotlin type system,2020-07-06,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_016.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_016.html#1c1edb3a-1030-41e8-944c-626a072e86b0,"In Kotlin, Any is a supertype of all types, including the primitive types such as Int.",
Kotlin in Action,Chapter 6. The Kotlin type system,2020-07-06,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_016.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_016.html#05836fd1-281a-40a5-9edd-9e6b1ded2e9e,"Conversion functions are defined for every primitive type (except Boolean): toByte(), toShort(), toChar() and so on. The functions support converting in both directions: extending a smaller type to a larger one, like Int.toLong(), and truncating a larger type to a smaller one, like Long.toInt().",
Kotlin in Action,Chapter 6. The Kotlin type system,2020-07-06,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_016.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_016.html#28da7cc2-5de7-49ed-9e3a-ece0ad8a69f1,"Kotlin doesn’t distinguish between primitive types and wrapper types. You always use the same type (for example, Int):",
Kotlin in Action,Chapter 6. The Kotlin type system,2020-07-06,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_016.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_016.html#b1a5586b-bd03-479e-85d0-b0881d8f0a5d,Java provides special wrapper types (such as java.lang.Integer) that encapsulate primitive types in situations when an object is needed.,
Kotlin in Action,Chapter 6. The Kotlin type system,2020-07-06,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_016.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_016.html#ced8f248-c5a9-4392-839e-7022c74bb19d,"operators for safe operations (safe call ?., Elvis operator ?:, and safe cast as?), as well as the operator for unsafe dereference (the not-null assertion !!). You’ve seen how the library function let can help you accomplish concise non-null checks and how extensions for nullable types can help move a not-null check into a function",
Kotlin in Action,Chapter 6. The Kotlin type system,2020-07-06,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_016.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_016.html#3345dd4e-28c6-40e2-a86d-c3e6cda64ccd,"By default, all type parameters of functions and classes in Kotlin are nullable.",
Kotlin in Action,Chapter 6. The Kotlin type system,2020-07-06,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_016.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_016.html#36fde5e5-0d90-40e8-ac91-e5b265027212,"A common use case for lateinit properties is dependency injection. In that scenario, the values of lateinit properties are set externally by a dependency-injection framework",
Kotlin in Action,Chapter 6. The Kotlin type system,2020-07-06,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_016.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_016.html#a5701af6-d4a1-4859-855c-8df21370e182,"After using the short syntax, the autogenerated name it, the result is much shorter: email?.let { sendEmailTo(it) }",
Kotlin in Action,Chapter 6. The Kotlin type system,2020-07-06,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_016.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_016.html#47debeaf-b525-474c-a141-38776107ea1b,"The let function makes it easier to deal with nullable expressions. Together with a safe-call operator, it allows you to evaluate an expression, check the result for null, and store the result in a variable, all in a single, concise expression.",
Kotlin in Action,Chapter 6. The Kotlin type system,2020-07-06,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_016.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_016.html#f9ed4b2d-5a09-4a3d-9a50-e671d78991b0,The not-null assertion is the simplest and bluntest tool Kotlin gives you for dealing with a value of a nullable type. It’s represented by a double exclamation mark and converts any value to a non-null type,
Kotlin in Action,Chapter 6. The Kotlin type system,2020-06-30,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_016.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_016.html#34a71522-590b-40c2-b6ce-5ea9b045b276,The as? operator tries to cast a value to the specified type and returns null if the value doesn’t have the proper type,
Kotlin in Action,Chapter 6. The Kotlin type system,2020-06-30,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_016.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_016.html#e85b4a4a-bd12-4442-b609-0fbd98eaa2db,Kotlin has a handy operator to provide default values instead of null. It’s called the Elvis operator (or the null-coalescing operator,
Kotlin in Action,Chapter 6. The Kotlin type system,2020-06-30,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_016.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_016.html#d9b8f935-6ac2-42db-97ff-8b9fede6d650,"If you have an object graph in which multiple properties have nullable types, it’s often convenient to use multiple safe calls in the same expression",
Kotlin in Action,Chapter 6. The Kotlin type system,2020-06-30,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_016.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_016.html#c74e8cc6-2af8-4034-a0c8-5ea64138ad86,"One of the most useful tools in Kotlin’s arsenal is the safe-call operator: ?., which allows you to combine a null check and a method call into a single operation",
Kotlin in Action,Chapter 6. The Kotlin type system,2020-06-30,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_016.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_016.html#1ac3b0d1-09da-4c92-b344-c2bbb6cbd34a,"Even if you do use Optional everywhere in your own code, you’ll still need to deal with null values returned from methods of the JDK, the Android framework, and other third-party libraries",
Kotlin in Action,Chapter 6. The Kotlin type system,2020-06-30,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_016.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_016.html#be4232a0-4e12-443a-8572-8b261c56df43,"If you want to allow the use of this function with all arguments, including those that can be null, you need to mark it explicitly by putting a question mark ",
Kotlin in Action,Chapter 6. The Kotlin type system,2020-06-30,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_016.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_016.html#0d517bbd-2201-4713-a705-0563c6268ce1,Nullability is a feature of the Kotlin type system that helps you avoid NullPointer-Exception errors.,
Kotlin in Action,Chapter 5. Programming with lambdas,2020-06-30,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_015.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_015.html#bf0b3158-9953-4abf-8df8-64c22a76adc1,"The with standard library function allows you to call multiple methods on the same object without repeating the reference to the object.
apply lets you construct and initialize any object using a builder-style API.",
Kotlin in Action,Chapter 5. Programming with lambdas,2020-06-30,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_015.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_015.html#8623ec9c-8e79-421d-95e0-27b25f5447e5,"The apply function works almost exactly the same as with; the only difference is that apply always returns the object passed to it as an argument (in other words, the receiver object).",
Kotlin in Action,Chapter 5. Programming with lambdas,2020-06-30,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_015.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_015.html#5863067b-43b0-46de-b86c-9d265ed5c000,"The with structure looks like a special construct, but it’s a function that takes two arguments: stringBuilder, in this case, and a lambda. The convention of putting the lambda outside of the parentheses works here, and the entire invocation
looks like a built-in feature of the language. Alternatively, you could write this as with(stringBuilder, { ... }), but it’s less readable.",
Kotlin in Action,Chapter 5. Programming with lambdas,2020-06-30,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_015.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_015.html#8cfdb7b8-7dd1-421a-90da-b70f6a0e52ef,"a unique feature of Kotlin’s lambdas that isn’t available with Java: the ability to call methods of a
different object in the body of a lambda without any additional qualifiers. Such lambdas are called lambdas with receivers. Let’s begin by looking at the with function, which uses a lambda with a receiver.",
Kotlin in Action,Chapter 5. Programming with lambdas,2020-06-30,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_015.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_015.html#1202579c-f4c4-4b7b-8071-a1699cbc9701,"Note that there’s no this in a lambda as there is in an anonymous object: there’s no way to refer to the anonymous class instance into which the lambda
is converted. From the compiler’s point of view, the lambda is a block of code, not an object, and you can’t refer to it as
an object. The this reference in a lambda refers to a surrounding class.
If your event listener needs to unsubscribe itself while handling an event, you can’t use a lambda for that. Use an anonymous
object to implement a listener, instead. In an anonymous object, the this keyword refers to the instance of that object, and you can pass it to the API that removes the listener.",
Kotlin in Action,Chapter 5. Programming with lambdas,2020-06-30,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_015.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_015.html#4f4a2523-40a4-438f-95ea-80dfbf87cbe3,"This works because the OnClickListener interface has only one abstract method. Such interfaces are called functional interfaces, or SAM interfaces, where SAM stands for single abstract method",
Kotlin in Action,Chapter 5. Programming with lambdas,2020-06-30,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_015.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_015.html#12b4d5f0-05ed-48a4-a020-dccb6df73463,Another possibility is to use the generateSequence function. This function calculates the next element in a sequence given the previous one.,
Kotlin in Action,Chapter 5. Programming with lambdas,2020-06-30,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_015.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_015.html#962d6e8b-c4d3-4b19-83f3-70f09bf38bea,"If you’re familiar with Java 8 streams, you’ll see that sequences are exactly the same concept",
Kotlin in Action,Chapter 5. Programming with lambdas,2020-06-30,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_015.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_015.html#a55aee91-bb29-4282-bd80-dbe406bbd661,"With sequences, the lazy approach means you can skip processing some of the elements.
Figure 5.8 illustrates the difference between evaluating this code in an eager (using collections) and lazy (using sequences) manner.",
Kotlin in Action,Chapter 5. Programming with lambdas,2020-06-30,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_015.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_015.html#4dc5627e-e45a-4c3d-abdd-cd271898f988,"For sequences, all operations are applied to each element sequentially: the first
element is processed (mapped, then filtered), then the second element is processed, and so on.",
Kotlin in Action,Chapter 5. Programming with lambdas,2020-06-30,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_015.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_015.html#76b2eddf-9fd2-4532-ab4e-a63e4055e06e,The terminal operation causes all the postponed computations to be performed.,
Kotlin in Action,Chapter 5. Programming with lambdas,2020-06-30,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_015.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_015.html#09add8fa-a8aa-436f-a705-4c66b77141dc,"Operations on a sequence are divided into two categories: intermediate and terminal. An intermediate operation returns another sequence, which knows how to transform the elements of the original sequence. A terminal operation returns a result, which may be a collection, an element, a number, or any other object that’s somehow obtained by the sequence
of transformations of the initial collection",
Kotlin in Action,Chapter 5. Programming with lambdas,2020-06-30,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_015.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_015.html#845499b0-e8d3-45f7-812a-f79b2c906e84,"if the collection contains a large number of elements, the intermediate rearranging of elements costs a lot, so lazy evaluation
is preferable.",
Kotlin in Action,Chapter 5. Programming with lambdas,2020-06-30,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_015.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_015.html#71db58b9-f932-46b4-ad40-5b07d0074cdd,"The entry point for lazy collection operations in Kotlin is the Sequence interface. The interface represents just that: a sequence of elements that can be enumerated one by one. Sequence provides only one method, iterator, that you can use to obtain the values from the sequence.
The strength of the Sequence interface is in the way operations on it are implemented. The elements in a sequence are evaluated lazily. Therefore, you
can use sequences to efficiently perform chains of operations on elements of a collection without creating collections to
hold intermediate results of the processing.
You can convert any collection to a sequence by calling the extension function asSequence. You call toList for backward conversion.",
Kotlin in Action,Chapter 5. Programming with lambdas,2020-06-30,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_015.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_015.html#14debb96-d8c4-40a9-a79c-8a457a2c0d4c,"map and filter. These functions create intermediate collections eagerly, meaning the intermediate result of each step is stored in a temporary list. Sequences give you an alternative way to perform such computations that avoids the creation of intermediate temporary objects.",
Kotlin in Action,Chapter 5. Programming with lambdas,2020-06-30,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_015.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_015.html#9808e497-ad18-4a2f-b728-15b225ebdd79,"Note that if you don’t
need to transform anything and just need to flatten such a collection, you can use the flatten function: listOfLists.flatten().",
Kotlin in Action,Chapter 5. Programming with lambdas,2020-06-30,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_015.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_015.html#e49e7532-9d50-4539-b9d5-34d76dd40cc0,The toSet call removes duplicates from the resulting collection,
Kotlin in Action,Chapter 5. Programming with lambdas,2020-06-30,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_015.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_015.html#3f8624f9-ca8c-4148-beab-425db42c8666,"The flatMap function does two things: At first it transforms (or maps) each element to a collection according to the function given as an argument, and then it combines (or flattens) several lists into one.",
Kotlin in Action,Chapter 5. Programming with lambdas,2020-06-30,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_015.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_015.html#0bc4a2df-6a3f-4d6d-be3c-c39df62f6c97,"Another common task is checking whether all elements in a collection match a certain condition (or, as a variation, whether
any elements match). In Kotlin, this is expressed through the all and any functions. The count function checks how many elements satisfy the predicate, and the find function returns the first matching element.",
Kotlin in Action,Chapter 5. Programming with lambdas,2020-06-30,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_015.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_015.html#33d0a5c8-2e3a-4fbc-80f4-db495081fab1,"There are separate functions to handle keys and values. filterKeys and mapKeys filter and transform the keys of a map, respectively, where as filterValues and mapValues filter and transform the corresponding values.",
Kotlin in Action,Chapter 5. Programming with lambdas,2020-06-30,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_015.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_015.html#fc198d75-8887-4e6f-a8c4-23c6e35de3b9,"The filter function can remove unwanted elements from a collection, but it doesn’t change the elements. Transforming elements is where
map comes into play.",
Kotlin in Action,Chapter 5. Programming with lambdas,2020-06-30,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_015.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_015.html#f8a19a40-a7b8-4374-bb64-ebb976852c4c,"In Kotlin 1.0, when you take a reference to a method or property of a class, you always need to provide an instance of that
class when you call the reference. Support for bound member references, which allow you to use the member-reference syntax
to capture a reference to the method on a specific object instance, is planned for Kotlin 1.1",
Kotlin in Action,Chapter 5. Programming with lambdas,2020-06-30,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_015.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_015.html#9eb1580b-1738-44e1-8315-a725ccec163c,"A member reference has the same type as a lambda that calls that function, so you can use the two interchangeably:
people.maxBy(Person::age)",
Kotlin in Action,Chapter 5. Programming with lambdas,2020-06-30,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_015.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_015.html#0ac0a5fb-2c7e-4bcc-9240-3e1a9223d62f,"val getAge = Person::age
This expression is called member reference, and it provides a short syntax for creating a function value that calls exactly one method or accesses a property. A double
colon separates the name of a class from the name of the member you need to reference (a method or property)",
Kotlin in Action,Chapter 5. Programming with lambdas,2020-06-30,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_015.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_015.html#18519240-30dc-416e-b534-3bc578662b29,"External variables accessed
from a lambda, such as prefix, clientErrors, and serverErrors in these examples, are said to be captured by the lambda.",
Kotlin in Action,Chapter 5. Programming with lambdas,2020-06-30,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_015.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_015.html#a4c20294-8f13-41fa-9757-2298db41b138,"If you store a lambda in a variable, there’s no context from which to infer the parameter types, so you have to specify them
explicitly:
>>> val getAge = { p: Person -> p.age }
>>> people.maxBy(getAge)",
Kotlin in Action,Chapter 5. Programming with lambdas,2020-06-30,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_015.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_015.html#41463a65-fd0f-4f32-9f24-221669838b2c,This default name is generated only if you don’t specify the argument name explicitly,
Kotlin in Action,Chapter 5. Programming with lambdas,2020-06-30,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_015.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_015.html#0302f760-c11e-43ef-ab34-e7ad6b4c6568,"The last simplification you can make in this example is to replace a parameter with the default parameter name: it. This name is generated if the context expects a lambda with only one argument, and its type can be inferred.",
Kotlin in Action,Chapter 5. Programming with lambdas,2020-06-30,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_015.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_015.html#d2e1acda-4f39-4842-a244-adeeb3740166,"To convert one syntactic form to the other, you can use the actions: “Move lambda expression out of parentheses” and “Move
lambda expression into parentheses.”",
Kotlin in Action,Chapter 5. Programming with lambdas,2020-06-30,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_015.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_015.html#c6a5f605-5683-43b8-83b6-8a2886888b4a,"A lambda expression in Kotlin is always surrounded by curly braces. Note that there are no parentheses around the arguments.
The arrow separates the argument list from the body of the lambda.",
Kotlin in Action,Chapter 5. Programming with lambdas,2020-06-30,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_015.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_015.html#20e88b68-637b-408c-8078-c4e62c540995,"Lambda expressions, or simply lambdas, are essentially small chunks of code that can be passed to other functions",
Kotlin in Action,"Chapter 4. Classes, objects, and interfaces",2020-06-29,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_014.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_014.html#8f86727e-d15d-438e-9ec4-6be04f54eee9,"Object expressions are Kotlin’s replacement for Java’s anonymous inner classes, with added power such as the ability to implement
multiple interfaces and to modify the variables defined in the scope where the object is created.",
Kotlin in Action,"Chapter 4. Classes, objects, and interfaces",2020-06-29,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_014.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_014.html#469fdbd9-7a21-430f-a304-d6ddfcb0a822,Companion objects (along with package-level functions and properties) replace Java’s static method and field definitions,
Kotlin in Action,"Chapter 4. Classes, objects, and interfaces",2020-06-29,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_014.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_014.html#87e5213f-27b6-46c2-b94c-18edc5cedf77,"A companion object is a regular object that is declared in a class. It can be named, implement an interface, or have extension
functions or properties.",
Kotlin in Action,"Chapter 4. Classes, objects, and interfaces",2020-06-29,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_014.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_014.html#736ead4f-79b4-4355-b5e8-97ae33cf48b9,"The object keyword comes up in Kotlin in a number of cases, but they all share the same core idea: the keyword defines a class and creates
an instance (in other words, an object) of that class at the same time.",
Kotlin in Action,"Chapter 4. Classes, objects, and interfaces",2020-06-29,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_014.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_014.html#b131146f-c04f-4095-b643-50296be20d69,A secondary constructor is introduced using the constructor keyword. You can declare as many secondary constructors as you need.,
Kotlin in Action,"Chapter 4. Classes, objects, and interfaces",2020-06-29,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_014.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_014.html#b2e8437c-3216-46cd-a058-b8ef9c5dc9f2,"If you inherit the Button class and don’t provide any constructors, you have to explicitly invoke the constructor of the superclass even if it doesn’t
have any parameters:
class RadioButton: Button()",
Kotlin in Action,"Chapter 4. Classes, objects, and interfaces",2020-06-29,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_014.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_014.html#95ae4e94-726e-407a-9a77-78e08c2072cb,"If your class has a superclass, the primary constructor also needs to initialize the superclass. You can do so by providing
the superclass constructor parameters after the superclass reference in the base class list:
open class User(val nickname: String) { ... }
class TwitterUser(nickname: String) : User(nickname) { ... }",
Kotlin in Action,"Chapter 4. Classes, objects, and interfaces",2020-06-29,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_014.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_014.html#8073966e-db95-458d-942b-4fdc04e338fe,"The underscore in the constructor parameter _nickname serves to distinguish the name of the property from the name of the constructor parameter. An alternative possibility is
to use the same name and write this to remove the ambiguity, as is commonly done in Java: this.nickname = nickname",
Kotlin in Action,"Chapter 4. Classes, objects, and interfaces",2020-06-29,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_014.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_014.html#2c58ba49-8f48-402a-8b50-b367d6674456,"In this example, you see two new Kotlin keywords: constructor and init. The constructor keyword begins the declaration of a primary or secondary constructor. The init keyword introduces an initializer block. Such blocks contain initialization code that’s executed when the class is created, and are intended to be used together
with primary constructors.",copy code
Kotlin in Action,"Chapter 4. Classes, objects, and interfaces",2020-06-29,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_014.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_014.html#b23e3687-d0e1-47b1-81d8-cd98253d8cab,"class User(val nickname: String)
Normally, all the declarations in a class go inside curly braces. You may wonder why this class has no curly braces and instead
has only a declaration in parentheses. This block of code surrounded by parentheses is called a primary constructor",
Kotlin in Action,"Chapter 4. Classes, objects, and interfaces",2020-06-29,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_014.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_014.html#ee4bbe47-649c-4c24-b076-1c9da928ab9b,"otlin is similar, with one additional change: it makes
a distinction between a primary constructor (which is usually the main, concise way to initialize a class and is declared outside of the class body) and
a secondary constructor (which is declared in the class body). It also allows you to put additional initialization logic in initializer blocks.",
Kotlin in Action,"Chapter 4. Classes, objects, and interfaces",2020-06-29,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_014.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_014.html#2328d0c5-eef2-4dfb-8e2f-a500195d2286,"If you handle all subclasses of a sealed class in a when expression, you don’t need to provide the default branch.",
Kotlin in Action,"Chapter 4. Classes, objects, and interfaces",2020-06-29,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_014.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_014.html#f7434086-2d0f-490b-9f09-98f5dfc14657,"You mark a superclass with the sealed modifier, and that restricts the possibility of creating subclasses. All the direct subclasses must be nested in the superclass",
Kotlin in Action,"Chapter 4. Classes, objects, and interfaces",2020-06-29,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_014.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_014.html#9337f1e7-8d7b-463e-b24e-adc726c30b29,"A nested class in Kotlin with no explicit modifiers is the same as a static nested class in Java. To turn it into an inner class so that it contains a reference to an outer class, you use the inner modifier",
Kotlin in Action,"Chapter 4. Classes, objects, and interfaces",2020-06-29,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_014.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_014.html#9bc053af-b54c-4944-8432-4f927dd14a03,"Kotlin offers a new visibility modifier, internal, which means “visible inside a module.” A module is a set of Kotlin files compiled together.",
Kotlin in Action,"Chapter 4. Classes, objects, and interfaces",2020-06-29,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_014.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_014.html#22f7aa0f-778a-4d83-8b7b-5fe388f77386,"Note that if you override a member of a base class or interface, the overriding member will also be open by default. If you want to change this and forbid the subclasses of your class from overriding your implementation, you can
explicitly mark the overriding member as final.",
Kotlin in Action,"Chapter 4. Classes, objects, and interfaces",2020-06-29,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_014.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_014.html#b93f4828-6cdf-408e-b6e5-38b0f0476d09,"If you want to allow the creation of subclasses of a class, you need to mark the class with the open modifier. In addition, you need to add the open modifier to every property or method that can be overridden.",
Kotlin in Action,"Chapter 4. Classes, objects, and interfaces",2020-06-29,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_014.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_014.html#05eb642a-59bf-4012-94c5-ceea46ffce28,"Whereas in Java you can put the base type name before
the super keyword, as in Clickable.super.showOff(), in Kotlin you put the base type name in angle brackets: super<Clickable>.showOff().",
Kotlin in Action,"Chapter 4. Classes, objects, and interfaces",2020-06-29,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_014.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_014.html#aeee2a36-dba7-4de0-bf86-7593e0fb2c5c,using the override modifier is mandatory in Kotlin,
Kotlin in Action,"Chapter 4. Classes, objects, and interfaces",2020-06-29,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_014.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_014.html#0d56a7d7-e456-4dd0-bcd0-5674a8ed0d32,"The object keyword can be used not only for declaring named singleton-like objects, but also for declaring anonymous objects. Anonymous objects replace Java’s use of anonymous inner classes",
Kotlin in Action,"Chapter 4. Classes, objects, and interfaces",2020-06-29,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_014.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_014.html#487d9cfa-1eac-4e38-b402-60a27c2d5fef,Replacing secondary constructors with factory methods,Copy code
Kotlin in Action,"Chapter 4. Classes, objects, and interfaces",2020-06-29,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_014.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_014.html#8771a700-cc81-42fd-954c-1e5a9cf72dc5,"class A {
companion object {
fun bar() {
println(""Companion object called"")
}
}
}",
Kotlin in Action,"Chapter 4. Classes, objects, and interfaces",2020-06-29,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_014.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_014.html#fa7627ab-d10b-431d-bd1e-80b7a429e47a,"One of the objects defined in a class can be marked with a special keyword: companion. If you do that, you gain the ability to access the methods and properties of that object directly through the name of the containing class, without specifying the name of the object explicitly.",
Kotlin in Action,"Chapter 4. Classes, objects, and interfaces",2020-06-29,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_014.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_014.html#32562c00-b1fe-43c7-9db2-c9e8d93c5afe,"if you need to write a function that can be called without having a class instance but needs access to the internals of a class, you can write it as a member of an object declaration inside that class. An example of such a function would be a factory method.",
Kotlin in Action,"Chapter 4. Classes, objects, and interfaces",2020-06-29,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_014.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_014.html#ffa1b4aa-a1d0-49d5-9fd6-0ed62b1d3cc1,Kotlin provides first-class language support for this using the object declaration feature. The object declaration combines a class declaration and a declaration of a single instance of that class.,
Kotlin in Action,"Chapter 4. Classes, objects, and interfaces",2020-06-29,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_014.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_014.html#0561afe1-8cc1-422d-84f6-b211631d687c,"Whenever you’re implementing an interface, you can say that you’re delegating the implementation of the interface to another object, using the by keyword. Here’s how you can use this approach to rewrite the previous example:
class DelegatingCollection<T>(
innerList: Collection<T> = ArrayList<T>()
) : Collection<T> by innerList {}",
Kotlin in Action,"Chapter 4. Classes, objects, and interfaces",2020-06-29,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_014.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_014.html#ad025349-217b-4445-878c-a312fce76bb6,"data class Client(val name: String, val postalCode: Int)",
Kotlin in Action,"Chapter 4. Classes, objects, and interfaces",2020-06-29,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_014.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_014.html#837c1c4a-cbdc-45f4-94e8-24d7bb5636f3,"If you want your class to be a convenient holder for your data, you need to override these methods: toString, equals, and hashCode",
Kotlin in Action,"Chapter 4. Classes, objects, and interfaces",2020-06-29,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_014.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_014.html#fb6c166b-f71c-4b91-8ae0-bf58e55b03c3,"If you add the modifier data to your class, the necessary methods are automatically generated for you.",
Kotlin in Action,"Chapter 4. Classes, objects, and interfaces",2020-06-29,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_014.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_014.html#4d200091-e035-453b-acad-b01f21cd00e7,the is check in Kotlin is the analogue of instanceof in Java,
Kotlin in Action,"Chapter 4. Classes, objects, and interfaces",2020-06-29,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_014.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_014.html#fe5c36eb-4132-4d5f-9706-82af331d02ac,"In the body of the setter, you use the special identifier field to access the value of the backing field. In a getter, you can only read the value; and in a setter, you can both read and modify it.",
Kotlin in Action,Chapter 3. Defining and calling functions,2020-06-29,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_013.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_013.html#a9b228e0-1acb-4b15-afc0-00b647d83bc9,A secondary constructor is introduced using the constructor keyword. You can declare as many secondary constructors as you need.,
Kotlin in Action,Chapter 3. Defining and calling functions,2020-06-29,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_013.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_013.html#0d30130e-b2dc-4a9e-b552-e0ccfaa0afcd,"If you want to ensure that your class can’t be instantiated by other code, you have to make the constructor private.",Code
Kotlin in Action,Chapter 3. Defining and calling functions,2020-06-29,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_013.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_013.html#a8c579a4-b2ff-4a6c-b62c-9d84134c60f2,"open class User(val nickname: String) { ... }
class TwitterUser(nickname: String) : User(nickname) { ... }",
Kotlin in Action,Chapter 3. Defining and calling functions,2020-06-29,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_013.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_013.html#affbd564-dbb8-406a-a2d1-03b8b74b17a9,"If your class has a superclass, the primary constructor also needs to initialize the superclass.",
Kotlin in Action,Chapter 3. Defining and calling functions,2020-06-29,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_013.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_013.html#55e8a4c5-a41c-4fbc-ac5c-ab8a115ffcbf,the code can be simplified by adding the val keyword before the parameter.,Code
Kotlin in Action,Chapter 3. Defining and calling functions,2020-06-29,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_013.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_013.html#5b2d27b8-174c-45e8-ad3c-4c7c4954d543,"In this example, you don’t need to place the initialization code in the initializer block, because it can be combined with the declaration of the nickname property",Code
Kotlin in Action,Chapter 3. Defining and calling functions,2020-06-29,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_013.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_013.html#1f1d118d-7c13-475c-b75c-54b23f6407ed,"distinction between a primary constructor (which is usually the main, concise way to initialize a class and is declared outside of the class body) and a secondary constructor (which is declared in the class body)",
Kotlin in Action,Chapter 3. Defining and calling functions,2020-06-29,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_013.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_013.html#0246825d-f04f-4cbf-a608-9966bfd360b8,"two new Kotlin keywords: constructor and init. The constructor keyword begins the declaration of a primary or secondary constructor. The init keyword introduces an initializer block. Such blocks contain initialization code that’s executed when the class is created, and are intended to be used together with primary constructors.",
Kotlin in Action,Chapter 3. Defining and calling functions,2020-06-29,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_013.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_013.html#d9b756f9-a7d0-49bf-800c-d727f380faa9,"Kotlin provides a solution to this problem: sealed classes. You mark a superclass with the sealed modifier, and that restricts the possibility of creating subclasses. All the direct subclasses must be nested in the superclass",
Kotlin in Action,Chapter 3. Defining and calling functions,2020-06-29,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_013.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_013.html#91fa8624-6689-4be2-8cd4-945441de9060,"A nested class in Kotlin with no explicit modifiers is the same as a static nested class in Java. To turn it into an inner class so that it contains a reference to an outer class, you use the inner modifier.",
Kotlin in Action,Chapter 3. Defining and calling functions,2020-06-29,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_013.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_013.html#1ef2afb7-fc02-4461-a6f4-d3748f1177ca,"Kotlin offers a new visibility modifier, internal, which means “visible inside a module.” A module is a set of Kotlin files compiled together. It may be an IntelliJ IDEA module, an Eclipse project, a Maven or Gradle project, or a set of files compiled with an invocation of the Ant task.",
Kotlin in Action,Chapter 3. Defining and calling functions,2020-06-29,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_013.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_013.html#04094a7e-23bd-408a-a48f-14c2e8e11558,"For a class, this means smart casts can only be used with a class property that is a val and that doesn’t have a custom accessor. This requirement means the property has to be final, because otherwise a subclass could override the property and define a custom accessor, breaking the key requirement of smart casts",
Kotlin in Action,Chapter 3. Defining and calling functions,2020-06-29,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_013.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_013.html#a75774d6-c325-45df-bb7e-40ae8d6c9a68,"An abstract class usually contains abstract members that don’t have implementations and must be overridden in subclasses. Abstract members are always open, so you don’t need to use an explicit open modifier",
Kotlin in Action,Chapter 3. Defining and calling functions,2020-06-29,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_013.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_013.html#46c980c0-03d6-4536-a21a-550988ed4c9e,"If you want to allow the creation of subclasses of a class, you need to mark the class with the open modifier. In addition, you need to add the open modifier to every property or method that can be overridden.",
Kotlin in Action,Chapter 3. Defining and calling functions,2020-06-29,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_013.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_013.html#3305bcb7-cfdf-4d49-82ff-249a8e14dd2f,all classes and methods that aren’t specifically intended to be overridden in subclasses ought to be explicitly marked as final.,
Kotlin in Action,Chapter 2. Kotlin basics,2020-06-27,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_012.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_012.html#5236ebc8-38eb-4190-b4cd-5e7bbea01588,"The .. syntax to create a range works not only for numbers, but also for characters. Here you use it to iterate over all characters
from A up to and including F.",
Kotlin in Action,Chapter 3. Defining and calling functions,2020-06-26,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_013.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_013.html#3d28e53f-e9ec-4277-be82-e76ad320cfbb,"Extension functions can also be declared as local functions, so you could go even further and put User.validateBeforeSave as a local function in saveUser. But deeply nested local functions are usually fairly hard to read; so, as a general rule, we don’t recommend using more than one level of nesting.",
Kotlin in Action,Chapter 3. Defining and calling functions,2020-06-26,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_013.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_013.html#a76392b6-f406-42e5-a631-f20bbb082b88,Extracting a piece of code into an extension function turns out to be surprisingly useful,
Kotlin in Action,Chapter 3. Defining and calling functions,2020-06-26,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_013.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_013.html#78dff9e0-db63-4418-99d9-d2b55d2ec94c,"infix fun Any.to(other: Any) = Pair(this, other)",
Kotlin in Action,Chapter 3. Defining and calling functions,2020-06-26,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_013.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_013.html#3cf39069-fb59-4ce3-a4eb-d29f11e1f07c,"Infix calls can be used with regular methods and extension functions that have one required parameter. To allow a function to be called using the infix notation, you need to mark it with the infix modifier.",
Kotlin in Action,Chapter 3. Defining and calling functions,2020-06-26,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_013.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_013.html#d69c4414-3260-4b53-a5f4-d4d03bec3b01,"val map = mapOf(1 to ""one"", 7 to ""seven"", 53 to ""fifty-three"")",
Kotlin in Action,Chapter 3. Defining and calling functions,2020-06-26,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_013.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_013.html#1dfdd009-6654-43de-a853-267b1a81bf62,"In an infix call, the method name is placed immediately between the target object name and the parameter, with no extra separators",
Kotlin in Action,Chapter 3. Defining and calling functions,2020-06-26,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_013.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_013.html#9643291b-d39e-4c1f-b590-efb8ef2217e8,"Kotlin requires you to explicitly unpack the array, so that every array element becomes a separate argument to the function being called. Technically, this feature is called using a spread operator, but in practice it’s as simple as putting the * character before the corresponding argument:",Code
Kotlin in Action,Chapter 3. Defining and calling functions,2020-06-26,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_013.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_013.html#d17eaaaa-63e4-4253-9549-916b2badf406,varargs: a feature that allows you to pass an arbitrary number of values to a method by packing them in an array,
Kotlin in Action,Chapter 3. Defining and calling functions,2020-06-26,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_013.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_013.html#6a9914ac-7abd-4c2d-9854-1615d5ae2130,"val String.lastChar: Char
get() = get(length - 1)
You can see that, just as with functions, an extension property looks like a regular property with a receiver type added. The getter must always be defined, because there’s no backing field and therefore no default getter implementation",
Kotlin in Action,Chapter 3. Defining and calling functions,2020-06-26,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_013.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_013.html#b9c4efbd-d98e-48ba-aba3-3ec7bf3396cb,overriding doesn’t apply to extension functions: Kotlin resolves them statically.,
Kotlin in Action,Chapter 3. Defining and calling functions,2020-06-26,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_013.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_013.html#871caf4d-deab-425f-a06e-99b06a1a5cf4,"Because extension functions are effectively syntactic sugar over static method calls, you can use a more specific type as a receiver type, not only a class.",
Kotlin in Action,Chapter 3. Defining and calling functions,2020-06-26,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_013.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_013.html#88271a07-f1ff-4cae-8ebf-74a21143cbbd,"It doesn’t even matter whether String is written in Java, Kotlin, or some other JVM language, such as Groovy. As long as it’s compiled to a Java class, you can add your own extensions to that class.",
Kotlin in Action,Chapter 3. Defining and calling functions,2020-06-26,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_013.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_013.html#5d8529fb-aa57-4111-b651-b92107ba318a,"println(""Kotlin"".lastChar())
n
In this example, String is the receiver type, and ""Kotlin"" is the receiver object.",
Kotlin in Action,Chapter 3. Defining and calling functions,2020-06-26,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_013.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_013.html#13a7a292-fb93-4b27-b63e-62ca1b56bfc8,"Conceptually, an extension function is a simple thing: it’s a function that can be called as a member of a class but is defined outside of it. To demonstrate that, let’s add a method for computing the last character of a string:
package strings
fun String.lastChar(): Char = this.get(this.length - 1)
All you need to do is put the name of the class or interface that you’re extending before the name of the function you’re adding. This class name is called the receiver type; the value on which you’re calling the extension function is called the receiver object.",
Kotlin in Action,Chapter 3. Defining and calling functions,2020-06-26,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_013.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_013.html#7120e84b-7f7f-4593-b939-d36a8ab67061,"To change the name of the generated class that contains Kotlin top-level functions, you add a @JvmName annotation to the file. Place it at the beginning of the file, before the package name",
Kotlin in Action,Chapter 3. Defining and calling functions,2020-06-26,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_013.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_013.html#e7f1b69b-861a-4d52-87e4-66d870f04811,"If you frequently need to call a function from Java and want to make it easier to use for Java callers, you can annotate it with @Jvm-Overloads. This instructs the compiler to generate Java overloaded methods, omitting each of the parameters one by one, starting from the last one.",
Kotlin in Action,Chapter 3. Defining and calling functions,2020-06-26,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_013.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_013.html#2db7c395-4bba-4b96-b26e-f7c731a1825c,"In Kotlin, you can often avoid creating overloads because you can specify default values for parameters in a function declaration",
Kotlin in Action,Chapter 3. Defining and calling functions,2020-06-26,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_013.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_013.html#6ca166e0-31f1-4173-8cfb-660a4e43863f,"joinToString(collection, separator = "" "", prefix = "" "", postfix = ""."")
When calling a function written in Kotlin, you can specify the names of some arguments that you’re passing to the function. If you specify the name of an argument in a call, you should also specify the names for all the arguments after that, to avoid confusion.",
Kotlin in Action,Chapter 2. Kotlin basics,2020-06-25,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_012.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_012.html#ff534eb2-626e-4fdf-899f-c0197ce24b58,"You use the in operator to check whether a value is in a range, or its opposite, !in, to check whether a value isn’t in a range",
Kotlin in Action,Chapter 2. Kotlin basics,2020-06-25,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_012.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_012.html#1b793f03-37f7-47f0-9e73-7b70f7b985fe,"fun isLetter(c: Char) = c in 'a'..'z' || c in 'A'..'Z'
fun isNotDigit(c: Char) = c !in '0'..'9'
>>> println(isLetter('q'))
true
>>> println(isNotDigit('x'))
true",
Kotlin in Action,Chapter 2. Kotlin basics,2020-06-25,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_012.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_012.html#ddbf92d0-5c9b-4dde-b3d8-f9c9dfb9200a,for (x in 0 until size) is equivalent to for (x in 0..size-1),
Kotlin in Action,Chapter 2. Kotlin basics,2020-06-25,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_012.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_012.html#4b4e19bf-1057-4109-9f04-3cb6e28ce063,"for (i in 100 downTo 1 step 2) {
... print(fizzBuzz(i))
... }
Buzz 98 Fizz 94 92 FizzBuzz 88 ...",
Kotlin in Action,Chapter 2. Kotlin basics,2020-06-25,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_012.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_012.html#67e29ca4-2535-4df5-9253-6d3ea617f95c,"you can iterate over all the values in a range, such a range is called a progression.",
Kotlin in Action,Chapter 2. Kotlin basics,2020-06-25,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_012.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_012.html#b98bd19f-aa77-49e4-bb6b-88ee177e8e5d,"A range is essentially just an interval between two values, usually numbers: a start and an end. You write it using the .. operator:
val oneToTen = 1..10
Note that ranges in Kotlin are closed or inclusive, meaning the second value is always a part of the range.",
Kotlin in Action,Chapter 2. Kotlin basics,2020-06-25,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_012.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_012.html#19b52fb9-6a31-4296-8bf0-bff1c8da3a25,"The while loop is identical to the one in Java, so it deserves only a brief mention in the beginning of this section. The for loop exists in only one form, which is equivalent to Java’s for-each loop. It’s written for <item> in <elements>, as in C#",
Kotlin in Action,Chapter 2. Kotlin basics,2020-06-25,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_012.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_012.html#9193bb59-9966-411b-8382-152a2e7728c9,"Both if and when can have blocks as branches. In this case, the last expression in the block is the result.",
Kotlin in Action,Chapter 2. Kotlin basics,2020-06-25,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_012.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_012.html#64557419-05d9-4f99-8426-b4e972a4047e,"In Kotlin, there is no ternary operator, because, unlike in Java, the if expression returns a value",
Kotlin in Action,Chapter 2. Kotlin basics,2020-06-25,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_012.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_012.html#dd3aa719-bc69-4e28-aecf-e1f7c383fdc2,"When you’re using a smart cast with a property of a class, as in this example, the property has to be a val and it can’t have a custom accessor. Otherwise, it would not be possible to verify that every access to the property would return the same value.",
Kotlin in Action,Chapter 2. Kotlin basics,2020-06-25,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_012.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_012.html#65d595b1-51a5-4d02-935e-bce747c11aff,The Kotlin standard library contains a function setOf that creates a Set containing the objects specified as its arguments. A set is a collection for which the order of items doesn’t matter; two sets are equal if they contain the same items,
Kotlin in Action,Chapter 2. Kotlin basics,2020-06-25,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_012.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_012.html#b5ab7f9f-3992-4f45-874d-be9b06f388cd,"fun getWarmth(color: Color) = when(color) {
Color.RED, Color.ORANGE, Color.YELLOW -> ""warm""
Color.GREEN -> ""neutral""
Color.BLUE, Color.INDIGO, Color.VIOLET -> ""cold""
}
>>> println(getWarmth(Color.ORANGE))
warm",
Kotlin in Action,Chapter 2. Kotlin basics,2020-06-25,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_012.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_012.html#04f66d34-3f6e-4ec5-bb85-19e3cc4c7625,The property isSquare doesn’t need a field to store its value. It only has a custom getter with the implementation provided. The value is computed every time the property is accessed.,Code
Kotlin in Action,Chapter 2. Kotlin basics,2020-06-25,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_012.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_012.html#94bb2f3d-41d0-43a3-b651-2c19eaf0521d,"fun main(args: Array<String>) {
println(""Hello, ${if (args.size > 0) args[0] else ""someone""}!"")
}",
Kotlin in Action,Chapter 2. Kotlin basics,2020-06-25,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_012.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_012.html#bc38bdb3-d78d-434d-bdc4-0d8546f1da5e,Kotlin allows you to refer to local variables in string literals by putting the $ character in front of the variable name,
Kotlin in Action,Chapter 2. Kotlin basics,2020-06-25,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_012.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_012.html#08fd2c2f-d9e0-4956-bfd6-408bcc41fcdb,"There are two keywords to declare a variable:
val (from value)—Immutable reference. A variable declared with val can’t be reassigned after it’s initialized. It corresponds to a final variable in Java.
var (from variable)—Mutable reference. The value of such a variable can be changed. This declaration corresponds to a regular (non-final) Java variable.",
Kotlin in Action,Chapter 2. Kotlin basics,2020-06-25,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_012.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_012.html#7d820123-cc55-448f-a142-091221a6feaa,"Note that omitting the return type is allowed only for functions with an expression body. For functions with a block body that return a value, you have to specify the return type and write the return statements explicitly.",
Kotlin in Action,Chapter 2. Kotlin basics,2020-06-25,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_012.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_012.html#6ac7c592-1032-40a1-8843-6ac8e5fd7d5c,"the compiler can analyze the expression used as the body of the function and use its type as the function return type, even when it’s not spelled out explicitly. This type of analysis is usually called type inference.",
Kotlin in Action,Chapter 2. Kotlin basics,2020-06-25,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_012.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_012.html#6b001325-5159-4d83-94d9-98aed9c111db,"The difference between a statement and an expression is that an expression has a value, which can be used as part of another expression, whereas a statement is always a top-level element in its enclosing block and doesn’t have its own value",
Kotlin in Action,Chapter 2. Kotlin basics,2020-06-25,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_012.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_012.html#d4b9d3ba-2653-4e09-be0a-3dcc7f622a3e,"If a function is written with its body in curly braces, we say that this function has a block body. If it returns an expression directly, it has an expression body.",
Kotlin in Action,Chapter 1. Kotlin: what and why,2020-06-25,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_011.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_011.html#bc4f567d-0b3f-43d2-b02e-a09f4109f1d0,"The easiest way to try Kotlin doesn’t require any installation or configuration. At http://try.kotl.in, you can find an online playground where you can write, compile, and run small Kotlin programs.",
Kotlin in Action,Chapter 1. Kotlin: what and why,2020-06-25,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_011.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_011.html#173a4692-9ddc-4a54-8cc7-f62f633e8317,"Kotlin’s type system tracks values that can and can’t be null and forbids operations that can lead to a NullPointer-Exception at runtime. The additional cost required for this is minimal: marking a type as nullable takes only a single character, a question mark at the end",
Kotlin in Action,Chapter 1. Kotlin: what and why,2020-06-25,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_011.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_011.html#af62e8e0-94d7-4dd3-a8e8-9496f7b118fc,Kotlin doesn’t enforce using any particular programming style or para-digm,
Kotlin in Action,Chapter 1. Kotlin: what and why,2020-06-25,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_011.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_011.html#91ed1742-0a2a-49bf-a908-e3ea947b3149,"Kotlin has a rich set of features to support functional programming from the get-go. These include the following:
Function types, allowing functions to receive other functions as parameters or return other functions
Lambda expressions, letting you pass around blocks of code with minimum boilerplate
Data classes, providing a concise syntax for creating immutable value objects
A rich set of APIs in the standard library for working with objects and collections in the functional style",
Kotlin in Action,Chapter 1. Kotlin: what and why,2020-06-25,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_011.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_011.html#c77b2af4-e71d-4e4d-b710-ef65c3559400,"The second benefit of functional code is safe multithreading. One of the biggest sources of errors in multithreaded programs is modification of the same data from multiple threads without proper synchronization. If you use immutable data structures and pure functions, you can be sure that such unsafe modifications won’t happen, and you don’t need to come up with complicated synchronization schemes.",
Kotlin in Action,Chapter 1. Kotlin: what and why,2020-06-25,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_011.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_011.html#46009540-5dab-40c4-b0f3-a1943d7d7f2a,"What benefits can you gain from writing code in the functional style? First, conciseness",
Kotlin in Action,Chapter 1. Kotlin: what and why,2020-06-25,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_011.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_011.html#c6fe8a30-e71f-4276-8839-e460cdab129a,"The key concepts of functional programming are as follows:
First-class functions— You work with functions (pieces of behavior) as values. You can store them in variables, pass them as parameters, or return them from other functions.
Immutability— You work with immutable objects, which guarantees that their state can’t change after their creation.
No side effects— You use pure functions that return the same result given the same inputs and don’t modify the state of other objects or interact with the outside world.",
Kotlin in Action,Chapter 1. Kotlin: what and why,2020-06-25,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_011.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_011.html#3550d149-7ec8-49b6-8020-c5565b157958,"Kotlin’s support for nullable types, which lets you write more reliable programs by detecting possible null pointer exceptions at compile time.",
Kotlin in Action,Chapter 1. Kotlin: what and why,2020-06-25,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_011.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_011.html#58578bd3-a50b-4f79-9036-66461f682cb0,"This is in contrast to dynamically typed programming languages, which are represented on the JVM by, among others, Groovy and JRuby",
Kotlin in Action,Chapter 1. Kotlin: what and why,2020-06-25,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_011.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_011.html#16c1cd3e-c6f7-4263-8221-2f51d16f3e0b,"Kotlin is a statically typed programming language. This means the type of every expression in a program is known at compile time, and the compiler can validate that the methods and fields you’re trying to access exist on the objects you’re using.",
Kotlin in Action,Chapter 1. Kotlin: what and why,2020-06-25,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_011.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_011.html#75cdb418-332a-4707-a58f-86146efb2b31,"Kotlin can be compiled to JavaScript, allowing you to run Kotlin code in the browser",
Kotlin in Action,Chapter 1. Kotlin: what and why,2020-06-25,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_011.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_011.html#7b4c0211-5dd7-4fbb-ab96-5a081c7a2e9b,"But Kotlin works in other contexts as well. For example, you can use the Intel Multi-OS Engine (https://software.intel.com/en-us/multi-os-engine) to run Kotlin code on iOS devices. To build desktop applications, you can use Kotlin together with TornadoFX (https://github.com/edvin/tornadofx) and JavaFX.[",
Kotlin in Action,Chapter 1. Kotlin: what and why,2020-06-24,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_011.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_011.html#d867b9aa-d6f4-4fce-b344-af0efb130fe6,"The Elvis operator (?:) returns zero if age is null. Because Alice’s age isn’t specified, the Elvis operator replaces it with zero",
Kotlin in Action,Foreword,2020-06-24,https://learning.oreilly.com/library/view/-/9781617293290/,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_004.html,https://learning.oreilly.com/library/view/-/9781617293290/kindle_split_004.html#0a2534f7-40b9-48b4-b0b8-fd3498dfa1c2,"two new target platforms are being developed: Kotlin is now running on JavaScript VMs enabling full-stack web development, and it will soon be able to compile directly to native code and run without any VM at all, if necessary.",
"Learning React, 2nd Edition",5. React with JSX,2020-06-18,https://learning.oreilly.com/library/view/-/9781492051718/,https://learning.oreilly.com/library/view/-/9781492051718/ch05.html,https://learning.oreilly.com/library/view/-/9781492051718/ch05.html#8a144e65-6f71-471d-a3e4-73f1a9714d54,"Fragments are a relatively new feature of React and do away with the
need for extra wrapper tags that can pollute the DOM.",
"Learning React, 2nd Edition",7. Enhancing Components with Hooks,2020-06-18,https://learning.oreilly.com/library/view/-/9781492051718/,https://learning.oreilly.com/library/view/-/9781492051718/ch07.html,https://learning.oreilly.com/library/view/-/9781492051718/ch07.html#e97e0422-65aa-4565-86bf-b561acf58641,"If you return a function from the effect, the function will be invoked when the component is removed from the tree",
"Learning React, 2nd Edition",6. React State Management,2020-06-18,https://learning.oreilly.com/library/view/-/9781492051718/,https://learning.oreilly.com/library/view/-/9781492051718/ch06.html,https://learning.oreilly.com/library/view/-/9781492051718/ch06.html#2f87fa75-4e21-473f-9136-f16824164514,"Using context still allows to us store state data in a single location, but
it doesn't require us to pass that data through a bunch of components
that don't need it",
"Learning React, 2nd Edition",6. React State Management,2020-06-18,https://learning.oreilly.com/library/view/-/9781492051718/,https://learning.oreilly.com/library/view/-/9781492051718/ch06.html,https://learning.oreilly.com/library/view/-/9781492051718/ch06.html#0c3f0618-23bd-462e-a3ac-202a983f7451,"The most important thing to remember about Hooks is that they can cause
the component they're hooked into to rerender. Every",
"Learning React, 2nd Edition",8. Incorporating Data,2020-06-18,https://learning.oreilly.com/library/view/-/9781492051718/,https://learning.oreilly.com/library/view/-/9781492051718/ch08.html,https://learning.oreilly.com/library/view/-/9781492051718/ch08.html#4c1b9c85-a26c-4305-bc17-a469674bf104,"renderEmpty is a render prop because it contains a component to render when a particular condition has been met. In this case, when the list is empty or the data property has not been provided.
We can send this component an actual array of data:
export default function App() {
return (
<List
data={tahoe_peaks}
renderEmpty={<p>This list is empty</p>}
/>
);
}",
"Learning React, 2nd Edition",7. Enhancing Components with Hooks,2020-06-18,https://learning.oreilly.com/library/view/-/9781492051718/,https://learning.oreilly.com/library/view/-/9781492051718/ch07.html,https://learning.oreilly.com/library/view/-/9781492051718/ch07.html#feb7dcf9-9111-47b3-a85a-2e903061fad4,"PureComponent is the same as React.memo, but PureComponent is only for class components. React.memo is only for function components.",
"Learning React, 2nd Edition",7. Enhancing Components with Hooks,2020-06-18,https://learning.oreilly.com/library/view/-/9781492051718/,https://learning.oreilly.com/library/view/-/9781492051718/ch07.html,https://learning.oreilly.com/library/view/-/9781492051718/ch07.html#bd6a6fa2-da0f-4ed4-9fe0-c09a7812fbb8,"const PureCat = memo(
Cat,
(prevProps, nextProps) => prevProps.name === nextProps.name
);
We can use the second argument to compare properties and decide if Cat should be re-rendered.",
"Learning React, 2nd Edition",7. Enhancing Components with Hooks,2020-06-18,https://learning.oreilly.com/library/view/-/9781492051718/,https://learning.oreilly.com/library/view/-/9781492051718/ch07.html,https://learning.oreilly.com/library/view/-/9781492051718/ch07.html#dfd39559-a294-44b1-a9f5-bb92110ad69f,"const RenderCatOnce = memo(Cat, () => true);
const AlwaysRenderCat = memo(Cat, () => false);
The second argument sent to the memo function is a predicate. A predicate is a function that only returns true or false. . This function decides whether to re-render a cat or not.",
"Learning React, 2nd Edition",7. Enhancing Components with Hooks,2020-06-18,https://learning.oreilly.com/library/view/-/9781492051718/,https://learning.oreilly.com/library/view/-/9781492051718/ch07.html,https://learning.oreilly.com/library/view/-/9781492051718/ch07.html#43c68305-d242-4b25-9d60-188dfb1c13cc,Refs persist between renders but don’t trigger re-renders,
"Learning React, 2nd Edition",7. Enhancing Components with Hooks,2020-06-18,https://learning.oreilly.com/library/view/-/9781492051718/,https://learning.oreilly.com/library/view/-/9781492051718/ch07.html,https://learning.oreilly.com/library/view/-/9781492051718/ch07.html#dd7433c7-dec9-4272-975e-f4f9da46faed,"we discussed useRef, a hook that’s often used to access the values of DOM nodes. These are particularly useful with form elements. If I need to submit the value of an input with a form, I can capture it with a ref:
const txtTitle = useRef();
Once I create the ref, I’ll add it to the input field:
<input ref={txtTitle} type=""text"" placeholder=""color title..."" required />
Then I can submit using the .current property:
const submit = e => {
e.preventDefault();
const title = txtTitle.current.value;
txtTitle.current.value = """";
};",
"Learning React, 2nd Edition",7. Enhancing Components with Hooks,2020-06-18,https://learning.oreilly.com/library/view/-/9781492051718/,https://learning.oreilly.com/library/view/-/9781492051718/ch07.html,https://learning.oreilly.com/library/view/-/9781492051718/ch07.html#81528387-11fd-41a8-abd2-8743618325c5,ave a good sense of what happens when we render a component. A component is simply a function that usually takes in state and/or props and always renders a user interface. Renders occur when the app first loads and when props and state values change. ,
"Learning React, 2nd Edition",6. React State Management,2020-06-18,https://learning.oreilly.com/library/view/-/9781492051718/,https://learning.oreilly.com/library/view/-/9781492051718/ch06.html,https://learning.oreilly.com/library/view/-/9781492051718/ch06.html#f36ddb7b-0803-4ad1-aa81-cd3ef89ffe87,"every single component. Having
state data distributed throughout too many of your components will make
it harder to track down bugs and make changes within your application.
This occurs because it is hard to keep track of where the state values
live within your component tree. It is easier to understand your
application's state, or state for a specific feature, if we were to
manage it from one location. There are several approaches to this
methodology and the first one we will analyze is storing state at the
root of you",
"Learning React, 2nd Edition",6. React State Management,2020-06-18,https://learning.oreilly.com/library/view/-/9781492051718/,https://learning.oreilly.com/library/view/-/9781492051718/ch06.html,https://learning.oreilly.com/library/view/-/9781492051718/ch06.html#ea744abf-59ac-416d-9135-2885db92356b,"It is not a great idea to use state in every single component. Having
state data distributed throughout too many of your components will make
it harder to track down bugs and make changes within your application.
This occurs because it is hard to keep track of where the state values
live within your component tree. It is easier to understand your
application's state, or state for a specific feature, if we were to
manage it from one location. There are several approaches to this",
"Learning React, 2nd Edition",6. React State Management,2020-06-18,https://learning.oreilly.com/library/view/-/9781492051718/,https://learning.oreilly.com/library/view/-/9781492051718/ch06.html,https://learning.oreilly.com/library/view/-/9781492051718/ch06.html#6ff86162-ccdc-42ad-b5fc-5a9f24531803,"The context provider can place an object into context, but it can't
mutate the values in context on its own. It needs some help from a
parent component. The trick is to create a stateful component that
renders a context provider. When the state of the stateful component
changes it will re-render the context provider with new context data.
Any of the context providers children will also be re-rendered with the
new context data.",
"Learning React, 2nd Edition",6. React State Management,2020-06-18,https://learning.oreilly.com/library/view/-/9781492051718/,https://learning.oreilly.com/library/view/-/9781492051718/ch06.html,https://learning.oreilly.com/library/view/-/9781492051718/ch06.html#646b90f2-e65f-48d6-b091-ea77e0207859,"Hooks provide software developers with the stimulation that they need to
stay motivated and enjoy front end programming. This is primarily
because they are an awesome tool for separating concerns. Now React
components only need to concern themselves with rendering other react
components and keeping the user interface up to data. React hooks can
concern themselves with the logic that is required to make the app work.
Both UI and hooks can be developed separately, tested separately, even
deployed separately.",
"Learning React, 2nd Edition",5. React with JSX,2020-06-18,https://learning.oreilly.com/library/view/-/9781492051718/,https://learning.oreilly.com/library/view/-/9781492051718/ch05.html,https://learning.oreilly.com/library/view/-/9781492051718/ch05.html#76dbae60-50d1-429b-9b57-f769f03b9ac5,"webpack is billed as a module bundler. A module bundler takes all of our
different files (JavaScript, LESS, CSS, JSX, ESNext, and so on) and
turns them into a single file. The two main benefits of bundling are
",
"Learning React, 2nd Edition",7. Enhancing Components with Hooks,2020-06-18,https://learning.oreilly.com/library/view/-/9781492051718/,https://learning.oreilly.com/library/view/-/9781492051718/ch07.html,https://learning.oreilly.com/library/view/-/9781492051718/ch07.html#56869651-2e66-4a40-9ef6-e8abe8018f79,"useReducer takes in the reducer function and the initial state, false",
"Learning React, 2nd Edition",7. Enhancing Components with Hooks,2020-06-18,https://learning.oreilly.com/library/view/-/9781492051718/,https://learning.oreilly.com/library/view/-/9781492051718/ch07.html,https://learning.oreilly.com/library/view/-/9781492051718/ch07.html#356a6e3a-5deb-43a2-a1f8-c02646f27030,"Instead of useState in the component, we’ll use useReducer",
"Learning React, 2nd Edition",7. Enhancing Components with Hooks,2020-06-18,https://learning.oreilly.com/library/view/-/9781492051718/,https://learning.oreilly.com/library/view/-/9781492051718/ch07.html,https://learning.oreilly.com/library/view/-/9781492051718/ch07.html#87a03278-c010-496b-b6c7-86222108e982,A reducer function’s most simple definition is that it takes in the current state and returns a new state,
"Learning React, 2nd Edition",7. Enhancing Components with Hooks,2020-06-18,https://learning.oreilly.com/library/view/-/9781492051718/,https://learning.oreilly.com/library/view/-/9781492051718/ch07.html,https://learning.oreilly.com/library/view/-/9781492051718/ch07.html#bf05873d-ecf6-4470-b6cd-e9bfacdf4dfc,"If you’re using create-react-app, there is an ESLint plugin included called eslint-plugin-react-hooks that provides warning hints if you’re in violation of these rules.",
"Learning React, 2nd Edition",7. Enhancing Components with Hooks,2020-06-18,https://learning.oreilly.com/library/view/-/9781492051718/,https://learning.oreilly.com/library/view/-/9781492051718/ch07.html,https://learning.oreilly.com/library/view/-/9781492051718/ch07.html#898095c8-b3c1-4261-a5dc-b84ba1f5aba5,"A quick look at the React docs will point out that there’s another type of effect hook: useLayoutEffect.
render
useLayoutEffect is called
Browser Paint: the time when the component’s elements are actually added to the DOM
useEffect is called",
"Learning React, 2nd Edition",7. Enhancing Components with Hooks,2020-06-18,https://learning.oreilly.com/library/view/-/9781492051718/,https://learning.oreilly.com/library/view/-/9781492051718/ch07.html,https://learning.oreilly.com/library/view/-/9781492051718/ch07.html#f293b00a-e2bd-4768-914a-d5039e7e95e6,"Start by wrapping the function with useCallback:
const fn = useCallback(() => {
console.log(""hello"");
console.log(""world"");
}, []);
useEffect(() => {
console.log(""fresh render"");
fn();
}, [fn]);
useCallback memoizes the function value for fn. Just like useMemo and useEffect, it also expects a dependency array as the second argument. In this case, we create the memoized callback once becuase the dependency array is empty.",
"Learning React, 2nd Edition",7. Enhancing Components with Hooks,2020-06-18,https://learning.oreilly.com/library/view/-/9781492051718/,https://learning.oreilly.com/library/view/-/9781492051718/ch07.html,https://learning.oreilly.com/library/view/-/9781492051718/ch07.html#d96d7434-935c-41f4-a4c3-96a6a7809a70,"Also in the realm of performance optimization Hooks is useCallback. useCallback can be used like useMemo, but it memoizes functions instead of values. For example:",
"Learning React, 2nd Edition",7. Enhancing Components with Hooks,2020-06-18,https://learning.oreilly.com/library/view/-/9781492051718/,https://learning.oreilly.com/library/view/-/9781492051718/ch07.html,https://learning.oreilly.com/library/view/-/9781492051718/ch07.html#0ad279e4-0fc4-4e71-a90e-947b2a5e1138,useMemo will only recalculate that value when one of the dependencies has changed,
"Learning React, 2nd Edition",7. Enhancing Components with Hooks,2020-06-18,https://learning.oreilly.com/library/view/-/9781492051718/,https://learning.oreilly.com/library/view/-/9781492051718/ch07.html,https://learning.oreilly.com/library/view/-/9781492051718/ch07.html#26302ce5-6e9c-4354-be9c-4b0d07f7d4f3,"The useMemo hook is a great function to understand when you’re creating React applications. Performance optimization tools are great to have in your belt, but it’s important to avoid premature optimizations. Look to useMemo only when you really need it.",
"Learning React, 2nd Edition",7. Enhancing Components with Hooks,2020-06-18,https://learning.oreilly.com/library/view/-/9781492051718/,https://learning.oreilly.com/library/view/-/9781492051718/ch07.html,https://learning.oreilly.com/library/view/-/9781492051718/ch07.html#18e91441-dae5-4d62-8d08-fd6a70ce3611,This means that you can use useEffect for setup and teardown,
"Learning React, 2nd Edition",7. Enhancing Components with Hooks,2020-06-18,https://learning.oreilly.com/library/view/-/9781492051718/,https://learning.oreilly.com/library/view/-/9781492051718/ch07.html,https://learning.oreilly.com/library/view/-/9781492051718/ch07.html#2c0efb4a-c562-450a-871e-0ea46493c6be,It’s also possible to supply an empty array as the second argument to a useEffect function. An empty dependency array causes the effect to only be invoked once after the initial render,
"Learning React, 2nd Edition",7. Enhancing Components with Hooks,2020-06-18,https://learning.oreilly.com/library/view/-/9781492051718/,https://learning.oreilly.com/library/view/-/9781492051718/ch07.html,https://learning.oreilly.com/library/view/-/9781492051718/ch07.html#354f49ba-155f-4543-b4df-abdbac0117a8,"We do not want every effect to be invoked on every render. We should just see what the user is typing, not the information about the saved phrase. To solve this problem, we can incorporate the dependency array. The dependency array can be used to control when an effect is invoked:
useEffect(() => {
console.log(`typing ""${val}""`);
}, [val]);
useEffect(() => {
console.log(`saved phrase: ""${phrase}""`);
}, [phrase]);",
"Learning React, 2nd Edition",7. Enhancing Components with Hooks,2020-06-18,https://learning.oreilly.com/library/view/-/9781492051718/,https://learning.oreilly.com/library/view/-/9781492051718/ch07.html,https://learning.oreilly.com/library/view/-/9781492051718/ch07.html#dc7e68a0-0559-4e71-9bc5-cd1fa98ad0e9,"Every time we render, useEffect has access to the latest values from that render: props, state, refs, etc.",
"Learning React, 2nd Edition",7. Enhancing Components with Hooks,2020-06-18,https://learning.oreilly.com/library/view/-/9781492051718/,https://learning.oreilly.com/library/view/-/9781492051718/ch07.html,https://learning.oreilly.com/library/view/-/9781492051718/ch07.html#c475862c-736e-42ab-846d-f6bb00d5a9b4,"export const Checkbox = () => {
const [checked, setChecked] = useState(false);
useEffect(() => {
alert(`checked: ${checked.toString()}`);
});
return (
<>
<input
type=""checkbox""
value={checked}
onChange={() => setChecked(checked => !checked)}
/>
{checked ? ""checked"" : ""not checked""}
</>
);
};
We use useEffect when a render needs to cause side effects. Think of a side effect as something that a function does that isn’t part of the return.",
"Learning React, 2nd Edition",7. Enhancing Components with Hooks,2020-06-18,https://learning.oreilly.com/library/view/-/9781492051718/,https://learning.oreilly.com/library/view/-/9781492051718/ch07.html,https://learning.oreilly.com/library/view/-/9781492051718/ch07.html#8bb8287d-154a-4551-87ff-aa3fb2a7b55e,"Placing the alert inside of the useEffect function means that the function will be called after the render, as a side effect:",
"Learning React, 2nd Edition",6. React State Management,2020-06-18,https://learning.oreilly.com/library/view/-/9781492051718/,https://learning.oreilly.com/library/view/-/9781492051718/ch06.html,https://learning.oreilly.com/library/view/-/9781492051718/ch06.html#881ecf9e-0fcf-495f-8cb6-ee15285239ff,"Context is contained to
this module, yet exposed through a hook. This works because we return
context using the useContext hook which has access to the
ColorContext locally in this file. It is now appropriate to rename
this module color-hooks.js and distribute this functionality for wider
use by the community.",
"Learning React, 2nd Edition",6. React State Management,2020-06-18,https://learning.oreilly.com/library/view/-/9781492051718/,https://learning.oreilly.com/library/view/-/9781492051718/ch06.html,https://learning.oreilly.com/library/view/-/9781492051718/ch06.html#f53adf4e-b70b-4052-97f4-e856107b6243,"A context Provider does not always have to wrap an entire application.
It is not only ok to wrap specific sections component with a context
Provider, it can make your application more efficient. The Provider
will only provide context values to it’s children.",
"Learning React, 2nd Edition",6. React State Management,2020-06-18,https://learning.oreilly.com/library/view/-/9781492051718/,https://learning.oreilly.com/library/view/-/9781492051718/ch06.html,https://learning.oreilly.com/library/view/-/9781492051718/ch06.html#bb8a7e23-3655-4063-8cde-0387aa82c786,"In order to use context in React, we must first place some data in a
context provider and add that provider to our component tree. React
comes with a function called createContext that we can use to create a
new context object. This object contains two components: a context
Provider and a Consumer.",
"Learning React, 2nd Edition",6. React State Management,2020-06-18,https://learning.oreilly.com/library/view/-/9781492051718/,https://learning.oreilly.com/library/view/-/9781492051718/ch06.html,https://learning.oreilly.com/library/view/-/9781492051718/ch06.html#c1c698e0-4c57-4548-8dc0-46ca95c9641e,"The context
consumer is the React component that retrieves the data from context.",
"Learning React, 2nd Edition",6. React State Management,2020-06-18,https://learning.oreilly.com/library/view/-/9781492051718/,https://learning.oreilly.com/library/view/-/9781492051718/ch06.html,https://learning.oreilly.com/library/view/-/9781492051718/ch06.html#75eead2d-442b-49f6-b419-3e3c70268094,"In React, context is like jet setting for your data. You can place
data in React context by creating a context provider. A context
provider is a React component that you can wrap around your entire
component tree, or specific sections of your component tree.",
"Learning React, 2nd Edition",6. React State Management,2020-06-18,https://learning.oreilly.com/library/view/-/9781492051718/,https://learning.oreilly.com/library/view/-/9781492051718/ch06.html,https://learning.oreilly.com/library/view/-/9781492051718/ch06.html#fe9a56d9-161e-44a2-a721-ae069ecb012c,"import { useState } from ""react"";
export const useInput = initialValue => {
const [value, setValue] = useState(initialValue);
return [
{ value, onChange: e => setValue(e.target.value) },
() => setValue(initialValue)
];
};",
"Learning React, 2nd Edition",6. React State Management,2020-06-18,https://learning.oreilly.com/library/view/-/9781492051718/,https://learning.oreilly.com/library/view/-/9781492051718/ch06.html,https://learning.oreilly.com/library/view/-/9781492051718/ch06.html#5343286a-802e-4b87-b688-d552b0332065,"In controlled component the from values are managed by React and not
the DOM. They do not require us to use refs. They do not require us to
write imperative code. Adding features like robust form validation are
much easier when working with a controlled components",
"Learning React, 2nd Edition",6. React State Management,2020-06-18,https://learning.oreilly.com/library/view/-/9781492051718/,https://learning.oreilly.com/library/view/-/9781492051718/ch06.html,https://learning.oreilly.com/library/view/-/9781492051718/ch06.html#4e162b73-8abe-47d5-88c1-d08f889a4689,"When it is time to build a form component in React there are several
patterns available to you. One of these patterns involves accessing the
DOM node directly using a React feature called refs. In React, a ref
is an mutable object that stores values for the lifetime of a component.",
"Learning React, 2nd Edition",6. React State Management,2020-06-18,https://learning.oreilly.com/library/view/-/9781492051718/,https://learning.oreilly.com/library/view/-/9781492051718/ch06.html,https://learning.oreilly.com/library/view/-/9781492051718/ch06.html#818ef0ff-735d-4073-96ac-f9c62667d6ea,"This StarRating component has been modified. We’ve turned it into a
Pure Component. A Pure Component is a function component that does
not contain state and will render the same user interface given the same
props.",
"Learning React, 2nd Edition",5. React with JSX,2020-06-18,https://learning.oreilly.com/library/view/-/9781492051718/,https://learning.oreilly.com/library/view/-/9781492051718/ch05.html,https://learning.oreilly.com/library/view/-/9781492051718/ch05.html#394984ce-b270-43f6-9567-8cbc4bd179f5,"You can also use npx to run create-react-app without the need for a
global install. Simply run npx create-react-app my-project.",