You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: architecture-patterns-python/notes.md
+17Lines changed: 17 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -112,3 +112,20 @@ Formal definition:
112
112
-**Domain Service**: logic that belongs in the domain model, but doesn't sit naturally inside a stateful entity of value object
113
113
114
114
# Ch5. TDD in high gear and low gear
115
+
- The service layer helps us clearly define our use cases and the workflow for each
116
+
- Tests: help us change our system fearlessly
117
+
- Don't write too many tests against the domain model: when you need to change the codebase you may need to update several unit tests
118
+
- Testing against the service layer: tests don't nteract directly with "private" methods/attributes on our model objects = easier to refactor them
119
+
120
+
> "Every line of code that we put in a test is like a **blob of glue**, holding the system in a particular shape. The more low-level tests we have, the harder it will be to change things."
121
+
122
+
-**"Listen to the code"**: when writing tests and find that the code is hard to use or some code smell = trigger to refactor and reconsider the design
123
+
- To improve the design of the code we must delete "sketch" tests that are to tightly coupled to a particular implementation
124
+
125
+
## High and low gear
126
+
- When starting a new project or gnarly problem: write tests against the domain model = better feedback
127
+
- When adding a new feature or fixing a bug (don't need to make extensive changes to the domain model): write tests against the services = lower coupling and higher coverage
128
+
-**Shifting gears metaphor**
129
+
- Mitigation: keep all domain dependencies in fixture functions
0 commit comments