pure VO wrapped in a domain object

why do Viktor and many java data modelers prefer to break a domain object into a pure VO and a wrapper object hosting the behavior or api methods?

Here’s a pratical reason. There’s negligible downside but increasing benefit as the object gets bigger. The one-class design can present hundreds (for a large object) of fields and methods, some belong to the VO, some obviously not. Hard to read. At some point you end up splitting the class anyway, for maintainability and readability. Why not adopt a coding standard?

A purist design is to have the VO as a public inner class of the wrapper. Argument — the VO should never exist outside.

A bad design is to make the wrapper a factory. The wrapper should still be a domain model. One instance represents one real-world instance.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s