Difference between JavaBeans, VO, POJO and DTO

Sri Kathiravan
3 min readSep 4, 2021

--

JavaBeans

  • JavaBeans are reusable software components for Java that can be manipulated visually in a builder tool.
  • Practically, they are classes written in the Java programming language conforming to a particular convention.
  • They are used to encapsulate many objects into a single object (the bean), so that they can be passed around as a single bean object instead of as multiple individual objects.
  • A JavaBean is a Java Object that is serializable, has a nullary constructor, and allows access to properties using getter and setter methods.

In order to function as a JavaBean class, an object class must obey certain conventions about method naming, construction, and behaviour. These conventions make it possible to have tools that can use, reuse, replace, and connect JavaBeans.

The required conventions are:

  • The class must have a public default constructor.
  • The class properties must be accessible using get, set, and other methods.
  • The class should be serializable. This allows applications and frameworks to reliably save, store, and restore the bean’s state in a fashion that is independent of the VM and platform.

EJB

  • Jakarta Enterprise Beans (formerly Enterprise JavaBeans).
  • EJB is a server-side software component that encapsulates the business logic of an application.

Types of EJB

  • Session Beans — Stateful or Stateless or Singleton.
  • Message Driven Beans (MDB).

POJO

  • POJO is an acronym for Plain Old Java Object. The name is used to emphasize that the object in question is an ordinary Java Object, not a special object, and in particular not an Enterprise JavaBean.
  • A JavaBean is a POJO that is serializable, has a no-argument constructor, and allows access to properties using getter and setter methods.

VO

  • A Value Object or VO is an object such as java.lang.Integer that hold values.
  • A value Object is a small object such as a Money or date range object. Their key property is that they follow value semantics rather than reference semantics.
  • Value objects should be entirely immutable. If you want to change a value object you should replace the object with a new one and not be allowed to update the values of the value object itself.

DTO

  • Data transfer object (DTO), formerly known as value objects or VO, is a design pattern used to transfer data between software application subsystems.
  • DTOs are often used in conjunction with data access objects to retrieve data from a database.
  • A DTO does not have any logic or behaviour except for the storage and retrieval of its own data.

Accessor and Mutator methods

Accessor and Mutator are just fancy names for a getter and a setter.

  • A getter, “Accessor”, returns a class’s variable or its value.
  • A setter, “Mutator”, sets a class variable pointer or its value.

Thanks…

I Am…..

I am a Software Engineer having experience in mobile app development with expertise in Java, Android and Flutter. Interested people can contact me through LinkedIn and Instagram.

--

--