Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

POJO vs DTO vs BO vs VO

 
Anand Jain
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • 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.
 
Akhilesh Trivedi
Ranch Hand
Posts: 1603
  • Mark post as helpful
  • send pies
  • 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?
 
Winston Gutkowski
Bartender
Pie
Posts: 10430
63
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • 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
 
Rob Spoor
Sheriff
Pie
Posts: 20555
57
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • 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
Pie
Posts: 10430
63
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • 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
 
Carlo Moore
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • 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.
 
Mike Simmons
Ranch Hand
Posts: 3090
14
  • Mark post as helpful
  • send pies
  • 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
Pie
Posts: 10430
63
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • 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
Ranch Hand
Posts: 3090
14
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic