3 ms·
IMO invariants are better handled by a class who's sole responsibility is to enforce and validate said invariants, especially when you have dependencies involve
by vips7L 6y ago
IMO invariants are better handled by a class who's sole responsibility is to enforce and validate said invariants, especially when you have dependencies involved to enforce them (like making sure the Item actually exists in the db).
Value classes like @Entity shouldn't have the responsibility to enforce those business rules.
We can disagree on which way is more object oriented though.