![]() ![]() ![]() Thus we can observe that the above example is a classic case of the POJO class in java. Also, we can observe that it is not mandatory to include any constructor in it. In the above example, we could observe that there do not exist any restrictions on the access modifiers for the fields but they could be declared as public, private, or protected. A setter updates the value of a variable, while a getter reads the value of a variable.Īlthough the POJO class in java does not have many restrictions, there are a few things that shouldn't be a part of the POJO class in java.Ī pojo class should not extend prespecified classes. Getters and Setters play an important role in retrieving and updating the value of a variable outside the encapsulating class. POJO acts as a pure data structure that has getter and setter methods. This increases the chance that it can be reused in multiple project types (web, desktop, console, etc) because it wouldn't be required to install packages or import modules. A POJO is usually simple, so it doesn't depend on other libraries, interfaces, or annotations. It is not bound by any Java framework thus it can be used by any Java program. Since the POJO class does not have strict rules for naming conventions, thus they are comparatively easier to read or write. The POJO class in java has gained popularity over the years due to the readability & reusability it provides in the program. The term POJO was introduced by Martin Fowler ( An American software developer) in 2000.The POJO class in java has been available since EJB 3.0 by sun microsystem.Įnterprise JavaBeans (or EJB) is a standard server-side component model for distributed business applications. They are commonly used for data transfer and encapsulation, and they can be used to facilitate communication between different layers of an application or between different components of a distributed system. ![]() POJO classes do not require any special classpath or dependencies, which makes them easy to develop, test, and maintain. POJOs are also referred to as free objects because they are not limited by any specific framework. POJO (Plain Old Java Objects) are Java objects that are not bound by any framework-specific restrictions or conventions, such as access modifiers or the need to implement Serializable interfaces. Introduction To Plain Old Java Object (POJO) ![]() It can be created with ease and used to produce readability and reusability in the code. In Java applications, POJOs provide a simple, flexible, and portable way to encapsulate data and behaviour. They are frequently used in conjunction with frameworks like Hibernate or Spring to provide dependency injection, map data to databases, and represent data models in web development frameworks. Additional methods for manipulating the data may also be present. In POJOs, private member variables with public getter and setter methods are typical. It can be used to facilitate communication between various layers or components of a distributed system and encapsulates data and related behaviour. Plain Old Java Object also known as POJO is a regular Java object with no special restrictions other than those forced by the Java Language Specification and does not require any classpath. ![]()
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |