File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes Difference between Value Object, Java Bean & POJO Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Difference between Value Object, Java Bean & POJO" Watch "Difference between Value Object, Java Bean & POJO" New topic

Difference between Value Object, Java Bean & POJO

Senthil Kumar Sekar
Ranch Hand

Joined: Aug 08, 2010
Posts: 45

Can anybody tel me the difference between the mostly frequently used words

Value Object, Java bean and POJO ?


Senthil Kumar Sekar
John Jai

Joined: May 31, 2011
Posts: 1776

Read these - Ranch old thread 1
Ranch old thread 2

and from other forum
Jack Dwaltz

Joined: May 12, 2008
Posts: 17
A Java Bean is a Java class that has getters and setters in order to conform to Java-bean standards.
Essentially you declare properties private and use getters and setters to read or modify the data.
The standardization was introduced to enable automatic access to properties via Java reflection to automate some activity performed e.g. by application servers.

A POJO is a “plain old java object” hence and instance of a simple java class: the term is used to contrast to the EJB (Enterprise Java Beans).
Enterprise beans are the Java beans used in JEE applications that are Java Beans that live in an application server that enables inter process communication and remote communication, dealing also with transactions and security.

The term was used to mean "go back to simple objects" and stop using Java EE.

The term “Value Objects” is used with different meanings.
Some call a value-object a DTO: which usually is aq class with no logic use only to pack information in a single item like a C Struct.

But the most wide-spread interpretation is a type of object that does not exist (yet) in Java.

The difference is determined by the behaviour of the assignment of such an object to another one.

In java a Struct or a Class are the same and any instance derived from a Class/Struct is an object used with the “reference logic”.
Hence when you do an assignment of an object you copy a reference to a memory address that holds the data associated with object.

In C# instead a Struct is a Value Object and is different from a Class.
In this case if you assign an object implementing a struct the value is copied and not a reference to the object.

The memory management is also different since the data of a Struct in C# is kept in the stack while for the classes the data is stored in the heap and the reference in the stack.
This helps in performance.
I agree. Here's the link:
subject: Difference between Value Object, Java Bean & POJO
It's not a secret anymore!