Comparison
Data transfer objectvsValue object
Data transfer object
the object crossing the boundary has fields matching the screen, not the model, and no behaviour at all.
A simple carrier of data across a process or layer boundary, shaped by what the consumer needs rather than by the domain. Its original purpose was to reduce the number of remote calls by batching everything the caller needed into one object, and its lasting purpose is to stop the domain model becoming a serialisation format. It looks like an anaemic domain object and is not one, because it was never meant to have behaviour.
Full entry →Value object
two of them with the same contents are interchangeable, so you never update one — you replace it.
An object defined entirely by its attributes, compared by value and, by convention, immutable: money, a date range, a coordinate, an email address. Immutability plus value equality means it can be shared freely, used as a map key and reasoned about without aliasing. Most of the practical benefit of domain modelling comes from making more things value objects, because each one takes a validation rule out of the calling code and puts it somewhere it cannot be skipped.
Full entry →