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
Software Design and Architecture is pretty much it's own field of study within the realm of computing, like DevOps or UX Design. Here's a map describing the breadth of software design and architecture, from clean code to microkernels.
Learn how to use DDD and object-oriented programming concepts to model complex Node.js backends.
Want to be notified when new content comes out?
Join 5000+ other developers learning about Domain-Driven Design and Enterprise Node.js.
I won't spam ya. 🖖 Unsubscribe anytime.