[TYPO3-mvc] ValueObject against Entity

Philipp Gampe philipp.gampe at typo3.org
Thu Sep 6 00:17:42 CEST 2012


Hi Claus,

Claus Due wrote:

> Thank you so much for this thorough investigation!
> 
> Now, unfortunately, I have huge problems seeing the benefit of
> ValueObjects:
> 
> Compared to a UID relation that sort of multicolumn fulltext querying has
> truly horrible performance :/
> 
> I'm not sure I'll every use those objects. It doesn't seem to make much
> sense?

I guess the separation between value objects and entities are more academic 
than actual differences in the code.
To my knowledge - but I am not much into DDD - value objects are supposed to 
save resources during execution because they could be handled more simple.

Consider a simple model of an address with a street and a postal number. All 
postal numbers could be value objects. Postal numbers could then be stored 
unique in the database. In a perfect world, you can save much space in the 
database by using value objects.
On the real world you have to spend many resources to actually check whether 
a value object already exists and create it otherwise.

If you use localization or workspaces or anything alike, than you will not 
only have on value object, but you will end up with several versions of the 
value object or you have to use another kind of mapping between the 
theoretical unique value object and its many representations.
What happens if you delete a value object ... is it destroyed or marked as 
deleted. What happens if you create a new entity later that has this 
specific value object as property?

Looking at this from a more distant point of view, there does not seem so 
much differences between a value object and an entity that would justify the 
code duplication and additional maintenance need for this.

But also have a look at that article and its discussion:
http://blog.typoplanet.de/2012/04/19/difference-between-entity-and-
valueobject/

Cheers
-- 
Philipp Gampe – PGP-Key 0AD96065 – TYPO3 UG Bonn/Köln
Documentation – linkvalidator
TYPO3 .... inspiring people to share!



More information about the TYPO3-project-typo3v4mvc mailing list