4 ms·
Is there a way to avoid anemic domain model? Or have a proper invariant entity class that is created using constructor?
by krzyk 3y ago
Is there a way to avoid anemic domain model? Or have a proper invariant entity class that is created using constructor?
- lmm 3y agoNo. I see that as a reflection of the reality of the database; if your database contains rows that violate your domain invariants, what would you expect to happen?
- ivan_gammel 3y agoIt may not be a bad idea to fail fast by ORM calling the constructor (same way as Jackson does it when parsing JSON). Broken invariants may propagate and cross system boundaries making things much worse (I have seen a case, when $200M transaction was rolled back in 19 systems because data was not properly validated at entry - it was a crazy day for everyone in production support).
- krzyk 3y agoI hope application to break as soon as possible so everyone will be on board to fix it.