• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Difference between Value Object, Java Bean & POJO

 
Senthil Kumar Sekar
Ranch Hand
Posts: 45
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can anybody tel me the difference between the mostly frequently used words

Value Object, Java bean and POJO ?

Thanks.

Regards
Senthil Kumar Sekar
 
John Jai
Rancher
Posts: 1776
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Read these - Ranch old thread 1
Ranch old thread 2

and from other forum
 
Jack Dwaltz
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic