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.
Isn't it funny how there's always time and money enough to do it WRONG?
Artlicles by Winston can be found here
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.
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.