Notes from - Writing idiomatic Go using Domain Driven Design, Damiano Petrungaro
Rough notes. Please watch the original presentation.
- DDD usually requires two approaches: Strategic Design and Tactical Design
- Artifacts should be grouped by (business) context rather than by kind
- When packages of different contexts need to communicate with each other, an Anti-Corruption layer can be introduced.
Tactical Design
- Value Type (Value Object)
- Repository Pattern
- A domain struct should not be created with invalid state, nor should it be allowed to have its state invalidated during runtime.
Value Type Pattern
A Value Type is equivalent to the Value Object pattern in OOP languages.
Repository Pattern
- Decouples the domain layer from the data layer. Should the data source change, the domain will not be impacted assuming it’s using this pattern.
- Facilitates testing without the need of a real database / service.