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 Controller, Application Service, Entity, Read Model, Domain event, and so on. These patterns can be used to establish a testable, portable application core, with a focus on behavior, instead of data.
- 0625/2020 Dutch PHP Conference (online edition) website feedback code
- 01/24/2020 PHP Benelux, Antwerp (Belgium) website feedback slides code