Skip to content

Commit 1942db3

Browse files
committed
Finish ch5 notes
1 parent 978371b commit 1942db3

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

architecture-patterns-python/notes.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,3 +112,20 @@ Formal definition:
112112
- **Domain Service**: logic that belongs in the domain model, but doesn't sit naturally inside a stateful entity of value object
113113

114114
# 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
130+
131+
# Ch6. Unit of Work pattern

0 commit comments

Comments
 (0)