1 00:00:06,590 --> 00:00:09,140 - Alright, I just wanna sum up everything we just did 2 00:00:09,140 --> 00:00:11,350 in this composition around design, 3 00:00:11,350 --> 00:00:14,050 and just kind of hear the cliff notes of everything we did 4 00:00:14,050 --> 00:00:15,920 and things you should be thinking about 5 00:00:15,920 --> 00:00:19,170 when we start moving from the concrete into behavior. 6 00:00:19,170 --> 00:00:21,720 We start decoupling our concrete solutions. 7 00:00:21,720 --> 00:00:23,990 Now, interfaces are very, very powerful, right? 8 00:00:23,990 --> 00:00:25,530 I don't want pollution, 9 00:00:25,530 --> 00:00:27,160 but here's some really interesting things. 10 00:00:27,160 --> 00:00:30,010 Interfaces are gonna give our program structure. 11 00:00:30,010 --> 00:00:32,620 They're gonna encourage design by composition, 12 00:00:32,620 --> 00:00:35,200 and I showed you how that composition works. 13 00:00:35,200 --> 00:00:38,220 And they also allow us to enable 14 00:00:38,220 --> 00:00:40,890 and enforce these clean divisions between components, 15 00:00:40,890 --> 00:00:42,340 whether these, and a lot of times, 16 00:00:42,340 --> 00:00:44,270 these components are gonna be these packages. 17 00:00:44,270 --> 00:00:45,160 We're gonna start talking about 18 00:00:45,160 --> 00:00:46,960 package on design eventually, 19 00:00:46,960 --> 00:00:49,560 and we're gonna really talk about decoupling, 20 00:00:49,560 --> 00:00:52,400 and the interface can really help with decoupling. 21 00:00:52,400 --> 00:00:55,130 Because remember, I can define an interface 22 00:00:55,130 --> 00:00:57,950 that satisfies your concrete values. 23 00:00:57,950 --> 00:01:01,310 And you can define interfaces that, my concrete values, 24 00:01:01,310 --> 00:01:03,510 and therefore, these interfaces which are 25 00:01:03,510 --> 00:01:06,010 isolated defined within the packages themselves 26 00:01:06,010 --> 00:01:09,050 can create very clear divisions. 27 00:01:09,050 --> 00:01:11,850 And we have really nice layers of decoupling 28 00:01:11,850 --> 00:01:14,460 through convention, not configuration. 29 00:01:14,460 --> 00:01:16,760 Now again, when we talk about decoupling, 30 00:01:16,760 --> 00:01:18,960 we're really trying to reduce dependency. 31 00:01:18,960 --> 00:01:20,700 We're trying to decouple components 32 00:01:20,700 --> 00:01:23,250 and packages as much as we can. 33 00:01:23,250 --> 00:01:24,240 And that's always going to lead 34 00:01:24,240 --> 00:01:26,380 to correctness, quality, and performance. 35 00:01:26,380 --> 00:01:29,990 It's going to allow code base to grow over time 36 00:01:29,990 --> 00:01:32,230 and not suddenly come to a halt. 37 00:01:32,230 --> 00:01:33,350 And we've seen that already by 38 00:01:33,350 --> 00:01:36,720 some big projects in the Go community, okay. 39 00:01:36,720 --> 00:01:38,850 Remember when it comes to grouping, 40 00:01:38,850 --> 00:01:40,580 we don't want to group by what we are. 41 00:01:40,580 --> 00:01:42,430 We want to group by what we do. 42 00:01:42,430 --> 00:01:44,510 We don't want to talk about who we are. 43 00:01:44,510 --> 00:01:46,230 That's configuration, right. 44 00:01:46,230 --> 00:01:48,017 Our parents made us who we are. 45 00:01:48,017 --> 00:01:52,050 But we, individually, decide what we want to do. 46 00:01:52,050 --> 00:01:53,770 And that's how we want to group things. 47 00:01:53,770 --> 00:01:55,740 Or I want to be around people 48 00:01:55,740 --> 00:01:59,250 who are not necessarily like myself from a DNA perspective, 49 00:01:59,250 --> 00:02:01,860 but who like to do the same things that I do. 50 00:02:01,860 --> 00:02:03,240 We want to focus our code around 51 00:02:03,240 --> 00:02:05,770 that level of diversity, okay. 52 00:02:05,770 --> 00:02:06,920 Level of diversity. 53 00:02:06,920 --> 00:02:08,790 So that interface is going to help 54 00:02:08,790 --> 00:02:10,630 our code decouple from change. 55 00:02:10,630 --> 00:02:13,060 It's going allow our code to maintain decoupling 56 00:02:13,060 --> 00:02:14,943 between packages or components. 57 00:02:14,943 --> 00:02:17,340 Or anyway, we got to really do our best 58 00:02:17,340 --> 00:02:20,010 to understand what is going to change in our code 59 00:02:20,010 --> 00:02:21,550 and try to decouple that. 60 00:02:21,550 --> 00:02:22,830 And it really helps if you start 61 00:02:22,830 --> 00:02:24,800 with that concrete implementation. 62 00:02:24,800 --> 00:02:27,200 That same exercise we went to, okay. 63 00:02:27,200 --> 00:02:28,400 The same exercise. 64 00:02:28,400 --> 00:02:32,470 And if it's not clear what an interface is doing for us, 65 00:02:32,470 --> 00:02:35,000 the benefit is not clear, I want us to stop. 66 00:02:35,000 --> 00:02:35,970 I want us to learn more, 67 00:02:35,970 --> 00:02:38,080 and I want to question those things, okay. 68 00:02:38,080 --> 00:02:40,260 And the biggest thing here that we can do 69 00:02:40,260 --> 00:02:43,960 is really try to design code and write APIs 70 00:02:43,960 --> 00:02:48,040 that defend against fraud and not protect against accidents. 71 00:02:48,040 --> 00:02:51,240 To really focus on the idea 72 00:02:51,240 --> 00:02:55,550 that we want to design APIs that are hard to misuse. 73 00:02:55,550 --> 00:02:58,150 I mean, JBD from Google 74 00:02:58,150 --> 00:03:01,517 said these two things better than I ever could. 75 00:03:01,517 --> 00:03:04,640 "A good API is not just easy to use 76 00:03:04,640 --> 00:03:06,540 but also hard to misuse." 77 00:03:06,540 --> 00:03:11,263 And, "You can always embed but you cannot always decompose 78 00:03:12,390 --> 00:03:14,427 big interfaces once they are out there." 79 00:03:14,427 --> 00:03:16,440 "Keep interfaces small." 80 00:03:16,440 --> 00:03:19,130 Compose interfaces as you need them. 81 00:03:19,130 --> 00:03:22,240 This is really going to help you design better coding Go, 82 00:03:22,240 --> 00:03:24,483 not only today, but for tomorrow.