• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Patterns (PoEAA): Difference between Value Object and Dependent?

 
Peter Merker
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi!

In Martin Fowler's "Patterns of Enterprise Application Architecture" I'm reading about the patterns Dependent Mapping and Embedded Value. Dependent Mapping is for objects that are Dependents, whereas Embedded Value is for Value Objects. Both object types have in common that they depend on the existence of an owning object (UML: composition) and don't have their own identifier, other than Entities. Let's call them both dependent objects for a moment. One thing I understand is that you can have a collection of dependent objects which leads to the need of an own table for those objects (= Dependent Mapping) whereas if you only have a "to-one" reference, you can store the dependent object in the owner object's table (= Embedded Value). What I don't get is the difference between them. Fowler writes:

Dependents are in many ways like Value Objects, although they often don't need the full mechanics that you use in making something a Value Object (such as overriding equals). The main difference is that there's nothing special about them from a purely in-memory point of view. The dependent nature of the objects is only really due to the database mapping behavior.


Hmm. So why does a Value Object need to override equals? And why can only Value Objects be mapped as Embedded Value and Dependents not and vice versa for the Dependent Mapping (Dependents O.K., Value Objects apparently not)?
[ April 17, 2008: Message edited by: Peter Merker ]
 
Anirudh Vyas
Ranch Hand
Posts: 93
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Its weird, I just got finished writing this at my blog. (This should explain some stuff).

DTO abuses

Hope it helps.
 
Peter Merker
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your reply, Anirudh. In your blog you write about the difference between Data Transfer Objects (DTO) and Value Objects (VO). Both terms have been mixed in the past, but nowadays it seems that there is an agreement that each term describes a different kind of object, in accordance with Fowler's definition of VOs.

What confuses me is the difference between VOs and Dependents, though.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic