Domain Driven Design in Java - Turning all primitives into Value Objects? -
this question has answer here:
- ddd - value objects cover every property 2 answers
does ddd in java mean turning every possible primitive that's part of domain value object? i've had discussion collegues today regarding stringly (as opposed strongly) typed code collegues today. i'm big fan of turning seperate value objects (well, isn't entity), overal sentiment in case of struct (like address, street, house number, etc), or when built-in validation relevant (like phone number). putting other things, example pet name separate wrapper class overkill (even frameworks lombok), or give big advantages aren't easy discover on first glance?
that's not rule, code should reflect business language as possible. it's idea change primitive values understandable business nouns. when value objects extremely simple (with single value property), it's easier reason them when named explicitly. besides that, objects can (and will) change during knowledge crunching of model/domain. it's possible, day single-value objects turn more complex structures, possibly complex validation. refactoring easier, when design value objects meaningful classes beginning. gain static type validation advantages, e.g. can't set pet name street address (which possible if modeled them simple strings).
Comments
Post a Comment