Decoupling from infrastructure
Most application code freely mixes domain logic with infrastructural concerns. Models are directly tied to the relational database of the project, use cases are inseparable from their web controllers, and external services are used without an appropriate abstraction.
This limits your ability to design the application in a domain-driven, test-first way.
What we need is a way to separate core code from infrastructure code. And that’s surprisingly easy. All the design patterns have already been invented for that. Until we run out of time, we’ll keep (re)discovering patterns like Application Service, Entity, Read Model, Domain event, Event subscriber, and so on. These patterns can be used to establish a testable, portable application core, with a focus on behavior, instead of data.
- Write domain-driven, test-first code
- Use no frameworks and no databases until you really have to
- Learn about evergreen design patterns like commands, events, policies, read models, and so on!