How To Decide Where To Put Domain Logic | Domain Driven Design w/ TypeScript
The reason we use Domain-Driven Design is because when our applications get sufficiently complex, we need to figure out better ways to organize domain logic than how we normally do with MVC in RESTful CRUD applications.
During the process of figuring out our requirements and understanding the domain, sometimes we'll hear language being used that sounds similar to:
"when this, then do this" or "when this, do this only if this has this"
When we hear that, we should automatically think "Domain Events".
Domain events should be named in the form of
[Entity][Past Tense Verb]Event.
Some examples are:
Just the, it naturally signifies that the model will be responsible for the verb/method.
Vinyl.create(props: VinylProps, id?: UniqueEntityId).
And it just so happens that we would also create those domain events within those entity method invokations.
Validation and Invariant Logic => Value Objects & Entities
Liked this? Sing it loud and proud 👨🎤.
Stay in touch!
View more in Domain-Driven Design
You may also enjoy...
A few more related articles
Learn how to use DDD and object-oriented programming concepts to model complex Node.js backends.
In software, change is inevitable. The more complex the software, the more it should be enabled to be changed. The SOLID principles are a set of principles all developers should know about in order to design robust, maintainable, and flexible software.
Want to be notified when new content comes out?
Join 2000+ other developers learning about Domain-Driven Design and Enterprise Node.js.
I won't spam ya. 🖖 Unsubscribe anytime.