Domain Driven Design in Java - Turning all primitives into Value Objects? -


this question has answer here:

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

Popular posts from this blog

c# - Update a combobox from a presenter (MVP) -

How to understand 2 main() functions after using uftrace to profile the C++ program? -

How to put a lock and transaction on table using spring 4 or above using jdbcTemplate and annotations like @Transactional? -