|
1 |
| -## Exporting |
| 1 | +## Packaging / Exporting |
2 | 2 |
|
3 | 3 | Packages contain the basic unit of compiled code. They define a scope for the indentifiers that are declared within them. Learning how to package our code is vital because exported identifiers become part of the packages API. Stable and useable API's are incredibily important.
|
4 | 4 |
|
@@ -27,68 +27,67 @@ _I think that the real problem with C is that it doesn't give you enough mechani
|
27 | 27 |
|
28 | 28 | ## Package Design
|
29 | 29 |
|
30 |
| -**Sandi Metz : Less - The Path to Better Design:** |
31 |
| -https://vimeo.com/26330100 |
| 30 | +#### Mike Action : Data-Oriented Design and C++ |
| 31 | +https://www.youtube.com/watch?v=rX0ItVEVjHc |
32 | 32 |
|
33 | 33 | * If you don't understand the data you are working with, you don't understand the problem you are trying to solve.
|
34 | 34 |
|
35 |
| -* Every problem is a data transformation problem at heart and each function, method and workflow must focus on implementing their specific data transformation. |
36 |
| - |
37 |
| -* If your data is changing, your problem is changing. |
38 |
| - |
39 |
| -* When your problem is changing, the data transformations you have implemented need to change. |
40 |
| - |
41 |
| -* You must do your best to guess what data could change over time and consider how these changes will affect the software. |
42 |
| - |
43 |
| -* Uncertainty about the data is not a license to guess but a directive to decouple. |
44 |
| - |
45 |
| -* In many languages folders are used to organize code, in Go folders are used to organize API's (packages). |
46 |
| - |
47 |
| -* Packages in Go provide API boundaries that should focus on solving one specific problem or a highly focused group of problems. |
| 35 | +* If you don't understand the cost of solving the problem, you can't reason about the problem. |
48 | 36 |
|
49 |
| -* You must understand how changes to the data for a particular package affects the other packages that depend on it. |
| 37 | +* If you don't understand the hardware, you can't reason about the cost of solving the problem. |
50 | 38 |
|
51 |
| -* Recognizing and minimizing cascading changes across different packages is a way to architect adaptability and stability in your software. |
| 39 | +* Solving problems you don't have, creates more problems you now do. |
52 | 40 |
|
53 |
| -* When dependencies between packages are weakened and the coupling loosened, cascading changes are minimized and stability is improved. |
| 41 | +* Every problem is a data transformation problem at heart and each function, method and workflow must focus on implementing their specific data transformation. |
54 | 42 |
|
55 |
| -* Decoupling means reducing the amount of intimate knowledge packages must have about each other to be used together. |
| 43 | +* If your data is changing, your problem is changing. |
56 | 44 |
|
57 |
| -* Interfaces provide the highest form of decoupling when the concrete types used to implement them can remain opaque. |
| 45 | +* When your problem is changing, the data transformations you have implemented need to change. |
58 | 46 |
|
59 |
| -**Scott Myers : The Most Important Design Guideline:** |
| 47 | +#### Scott Myers : The Most Important Design Guideline |
60 | 48 | https://www.youtube.com/watch?v=5tg1ONG18H8
|
61 | 49 |
|
62 | 50 | * Make Interfaces easy to use correctly and hard to use incorrectly.
|
63 | 51 |
|
64 | 52 | * Principle of least astonishment.
|
65 |
| - |
66 | 53 | * Keep the expectation clear, allows users to guess correctly.
|
67 |
| - |
68 | 54 | * Take advantage of what people already know.
|
69 |
| - |
70 | 55 | * Behavior should maintain a level of expectation.
|
71 | 56 |
|
72 | 57 | * Choose good names.
|
73 |
| - |
74 | 58 | * Names are the interface.
|
75 |
| - |
76 | 59 | * Give a lot of thought to the names you use.
|
77 | 60 |
|
78 | 61 | * Be consistent.
|
79 | 62 |
|
80 | 63 | * Document before using.
|
81 |
| - |
82 | 64 | * Test driven design.
|
83 |
| - |
84 | 65 | * This is identify problems early on.
|
85 | 66 |
|
86 | 67 | * Try to minimize user mistakes with the API.
|
87 |
| - |
88 | 68 | * Trying to constrain values can create readability issues.
|
89 |
| - |
90 | 69 | * Minimize choices.
|
91 | 70 |
|
| 71 | +#### Decoupling Guidelines For Go |
| 72 | + |
| 73 | +* In many languages folders are used to organize code, in Go folders are used to organize API's (packages). |
| 74 | + |
| 75 | +* Packages in Go provide API boundaries that should focus on solving one specific problem or a highly focused group of problems. |
| 76 | + |
| 77 | +* You must do your best to guess what data could change over time and consider how these changes will affect the software. |
| 78 | + |
| 79 | +* Uncertainty about the data is not a license to guess but a directive to decouple. |
| 80 | + |
| 81 | +* You must understand how changes to the data for a particular package affects the other packages that depend on it. |
| 82 | + |
| 83 | +* Recognizing and minimizing cascading changes across different packages is a way to architect adaptability and stability in your software. |
| 84 | + |
| 85 | +* When dependencies between packages are weakened and the coupling loosened, cascading changes are minimized and stability is improved. |
| 86 | + |
| 87 | +* Decoupling means reducing the amount of intimate knowledge packages must have about each other to be used together. |
| 88 | + |
| 89 | +* Interfaces provide the highest form of decoupling when the concrete types used to implement them can remain opaque. |
| 90 | + |
92 | 91 | ## Code Review
|
93 | 92 |
|
94 | 93 | [Declare and access exported identifiers](example1/example1.go)
|
|
0 commit comments