[TYPO3-mvc] Blog Example and Value Object question

Jochen Rau jochen.rau at typoplanet.de
Mon Dec 28 09:38:11 CET 2009


Hi Martin.

schrieb Martin Kutschker:
> Michael Knoll schrieb:
>> without looking at the blog-code, I would say that "Tag" cannot be a
>> value object. Like written earlier in your last discussion, "sex" could
>> be a value object, as it has only two states "male", "female" that don't
>> change over time, need not be persisted etc.
>>
>> A tag has a "tag-word" as a state, so there are as many possible values
>> as there are words. So in my opinion it's no value object!
>
> I didn't want to discuss whether a tag (in the blob example) is an entity or a value object, but if
> a value object should have any setters at all. If it is immutable a constructor should be enough.

Yes. In case of the Tag setting the properties via the constructor would 
be the cleaner way.

> But to get back to your argument. I disagree, a tag is a value object because its value cannot
> change without changing its identity. So the choice is - as far as my limited understanding of DDD
> allows me to judge - correct.

You are right. A Tag is a value object. It has no concept of identity. I 
only care about its name "Fruit".  And I can pass it around without 
taking care which exact "Fruit"-object you have. It has no concept of 
uniqueness or identity.

Regards
Jochen

-- 
Every nit picked is a bug fixed



More information about the TYPO3-project-typo3v4mvc mailing list