Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Difference in Data Transfer Object and Value Object  RSS feed

 
Lanny Gilbert
Ranch Hand
Posts: 132
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can anyone tell me a *real* difference in a Data Transfer Object
versus a Value Object? They seem to serve the same purpose in
providing coarse-grained access to data from Entity Beans
 
Pradeep bhatt
Ranch Hand
Posts: 8933
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, they are both the same.
 
David Harkness
Ranch Hand
Posts: 1646
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I use the two names to distinguish two forms of implementation of the same concept. They both provide a way to move data around from tier to tier and give coarse-grained access to the entity EJBs.
The difference in my usage is that a Value Object is just like a regular Java Bean -- it has named accessors and fields to hold the values -- while a Data Transfer Object is more like a HashMap of key/value pairs with only a single pair of get/set methods -- nothing is named for the specific bean.
I'm currently using the latter (DTO) because we need a service architecture that can be more pluggable. If someone uses our service, and we upgrade it to include more fields on an object, we need for them to be able to use our upgraded service *without* recompiling. If we had named accessors in VOs, they'd need to recompile against the new interface. With a generic DTO, they do not.
Note, they won't get the functionality of the extra fields, but their app won't break either.
 
Lasse Koskela
author
Sheriff
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
David, I would avoid using DTO and VO to mean different things because the community in general knows them as one and the same. Anyway, here's some background for those who are interested:
- "Data Transfer Object" was originally used by Martin Fowler's (ThoughtWorks) and Kyle Brown's (IBM) folks in 1999 or so.
- "Value Object" was later used by Sun (around 2001, I think) to describe the same pattern.
- Recently, the people at Sun agreed to standardize on the term "Data Transfer Object".
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!