Vladimir Khorikov reflects on domain modeling:
This is an example of a rich domain model: all business rules (also known as domain logic) are located in the domain classes. There’s one such rule currently — that we can only assign to the user an email that belongs to the corporate domain of that user’s company. There’s no way for the client code to bypass this invariant — a hallmark of a highly encapsulated domain model.
We can also say that our domain model is complete. A complete domain model is a model that contains all the application’s domain logic. In other words, there’s no domain logic fragmentation.
Domain logic fragmentation is when the domain logic resides in layers other than the domain layer. In our example, the
UserController
(which belongs to the application services layer) doesn’t contain any such logic, it serves solely as a coordinator between the domain layer and the database.
Domain modeling doesn’t land on too many database administrators’ doorsteps, but I enjoyed the article.