File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes POJO vs DTO vs BO vs VO Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "POJO vs DTO vs BO vs VO" Watch "POJO vs DTO vs BO vs VO" New topic
Author

POJO vs DTO vs BO vs VO

Anand Jain
Greenhorn

Joined: Jul 27, 2009
Posts: 18
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

Joined: Jun 22, 2005
Posts: 1527
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?


Keep Smiling Always — My life is smoother when running silent. -paul
[FAQs] [Certification Guides] [The Linux Documentation Project]
Winston Gutkowski
Bartender

Joined: Mar 17, 2011
Posts: 8008
    
  22

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


Isn't it funny how there's always time and money enough to do it WRONG?
Articles by Winston can be found here
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19719
    
  20

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.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Winston Gutkowski
Bartender

Joined: Mar 17, 2011
Posts: 8008
    
  22

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

Joined: Aug 02, 2005
Posts: 27
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

Joined: Mar 05, 2008
Posts: 3018
    
  10
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

Joined: Mar 17, 2011
Posts: 8008
    
  22

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

Joined: Mar 05, 2008
Posts: 3018
    
  10
Makes sense - Fowler never used the abbreviated term VO, so the only people using that term were actually referring to DTOs.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: POJO vs DTO vs BO vs VO