• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

POJO vs DTO vs BO vs VO

 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Can somebody please explain the difference among them with example(some sample piece of code) that can really help me understanding the difference.

I searched the difference among them but i couldn't clearly get that may be because of more theory and little example.
 
Ranch Hand
Posts: 1609
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Anand Jain wrote:I searched the difference among them but i couldn't clearly get that may be because of more theory and little example.


Did you at least get what they all stand for... their full-forms?
 
Bartender
Posts: 10780
71
Hibernate Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Anand Jain wrote:Can somebody please explain the difference among them with example(some sample piece of code) that can really help me understanding the difference.


Well POJO stands for "plain old Java object", which is exactly what it says it is; except that the term is usually used to differentiate it from from some other type, such as a ResultSet, which usually have a lot of specialized rules and regs for their use. Packages like Hibernate use a lot of nifty middleware to convert database table rows into POJOs so that you don't have to worry about all that extra syntax and can just treat them like any other object (most of the time ).

DTOs are objects used specifically for transferring data around from place to place, and usually don't include any behaviour (although it may be wrapped in the data itself). There are several varieties of this type, including XML-based formats and Java serialized objects, but they almost always involve a conversion process to retrieve the "actual" object from the DTO form.

As for VOs and BOs, I've never heard of them; although Wikipedia has a "value object", which iit equates to a DTO.

HIH

Winston
 
Sheriff
Posts: 22849
132
Eclipse IDE Spring Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Winston Gutkowski wrote:As for VOs and BOs, I've never heard of them; although Wikipedia has a "value object", which iit equates to a DTO.


I'm guessing Anand means value objects and business objects.
 
Winston Gutkowski
Bartender
Posts: 10780
71
Hibernate Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Rob Spoor wrote:I'm guessing Anand means value objects and business objects.


Oh, righto. Hopefully, all objects are business objects

Winston
 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As far as I know VOs were used heavily in EJB2.1 and earlier versions. Basically the role of the value object was taken over by the POJO. Before EJB3 you'd have to create a value object to hold data for an EJB client, rather than sending an EJB Local object which has all the persist specific methods.
 
Master Rancher
Posts: 5161
83
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The Wikipedia page on Value Object does not equate them with DTOs - rather, it has a "see also" link to Data Transfer Object. If you read the description of each, they are not the same thing.

The term Value Object was originally coined by Martin Fowler. Later, Sun engineers used the term to mean something completely different, and published this usage in their J2EE blueprints and in the book Core J2EE Patterns. The patterns community of course objected to this BS, and in the 2nd edition of Core J2EE Patterns they changed their misnamed "Value Object" to "Transfer Object". This is the thing that everyone now knows as DTO.

So basically, if you see a book or web site that talks about Value Objects or VOs as if they are something you use to send or receive data from a remote entity like a database or EJB, they are wrong. Just pretend they said "DTO" instead, and all will be well in the world.
 
Winston Gutkowski
Bartender
Posts: 10780
71
Hibernate Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Mike Simmons wrote:The Wikipedia page on Value Object does not equate them with DTOs...


Actually, I got to it from here (where it does) simply because I had no idea what a 'VO' was.

Winston
 
Mike Simmons
Master Rancher
Posts: 5161
83
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Makes sense - Fowler never used the abbreviated term VO, so the only people using that term were actually referring to DTOs.
reply
    Bookmark Topic Watch Topic
  • New Topic