The data model has the responsibility to store data, whereas the domain model has the responsibility to handle business logic. An application can be considered CRUD only if there is no business logic around the data model. Even in this (rare) case, your data model is not your domain model. It just means that, as no business logics is involved, we don’t need any abstraction to manage it, and thus we have no domain model.Ouarzy, It Is Not Your Domain.
I really like this observation, in that it gives me some language to distinguish CRUD implementations, where we don't have any invariant to enforce, and anemic domains, where there is an invariant, but we don't keep the invariant and the state changing behavior in the same logical unit.
We probably need more variations here
- There is no invariant (CRUD)
- There is an invariant, but it is maintained by human beings -- the invariant is not present in the code
- There is an invariant in the code, but the code is arranged such that modification of state can happen without maintaining the invariant (anemic)
- There is an invariant in the code, and the code is arranged so that any change of state is checked against the invariant.
But if the software is any good, bypassing the domain model should be unusual enough that additional steps to disable the safeties is acceptable.
No comments:
Post a Comment