jargon

Comparison

AssemblervsData transfer object

Assembler

one class exists purely to turn the domain object into the response shape, and neither of them knows about the other.

A dedicated object that converts between a domain object and a data transfer object. Putting the conversion here rather than on either side is what keeps the model from knowing about the wire format and the DTO from knowing about the model. It is tedious code that mapping libraries promise to remove, at the cost of a rename in the model silently changing your API.

Full entry →

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 →

Related comparisons