sensorario
sensorario

Reputation: 21648

Are DTO anemic model/anemic value object?

An anemic model is a model without ...

"Anemic domain model is the use of a software domain model where the domain objects contain little or no business logic (validations, calculations, business rules etc.)."

Is a DTO an anemic model without business Logic? And, again, a balie object without its business Logic?

Upvotes: 4

Views: 1343

Answers (1)

Constantin Galbenu
Constantin Galbenu

Reputation: 17683

First of all let's split behavior in two: behavior for read and behavior for write so we speak the same language.

Is a DTO an anemic model without business Logic?

You cannot say that a DTO is anemic or not because a DTO is immutable and anemy makes sense only in the mutating/write side of an architecture (for example the Command side in CQRS) but if we force the term a little the yes, a DTO is anemic and has no behavior (neither read nor write) by definition: "DTO does not have any behavior except for storage and retrieval of its own data".

A Value object has behavior (behavior for read). For example, it implements the behavoir to test if two value objects are equal or not.

To extend the answer a little, Aggregate roots and nested Entities have behavior for the write side (all kinds of validations).

Upvotes: 5

Related Questions