codeliner / php-ddd-cargo-sample

PHP 7 Version of the cargo sample used in Eric Evans DDD book

Home Page:http://codeliner.github.io/php-ddd-cargo-sample/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Confusion between DTO and Value Object

jonathangreco opened this issue · comments

Hi,

I just read some classes in this repository and I found some DTO object that are in fact, to me, value objects.

A DTO is for me, just as stupid data container which is used to transport data between layers and tiers..It shouldn't contains any logic, nor assertions (berberleri/assert)
A value object have some logic inside, and is immutable, it should not contains any getter or setter and just return one primitive.

You have in this repository a mix between DTO and value object.

Is this wanted ? Is it my understanding of DTO or Value Object that is wrong ?

Hi,

DTOs were simple classes before this #47 by @pl-github
I've merged the change because immutability is always a good thing, but this does not mean that you have to design your DTOs the same way ;)

it should not contains any getter or setter and just return one primitive.

Value objects are compared by their value(s) instead of an identifier, see the RouteSpecification
This does NOT mean that they have to return ONE primitive.

Ok thanks for the answer