Monday, July 28, 2014

POJO (Plain Old Java Object)

POJO based programming is the popular way of programming in Java in recent times. Most of the frameworks has embraced this style of programming which does not forces application developer to implement or inherit their classes from framework classes. The framework makes sense of these classes either by mapping them in XML or using annotations. POJO stands for Plain old Java Objects.

  • P - Plain. These are plain objects as they do not depend on any interfaces of any framework to implement.
  • O - Old. Remember the way we used to write program in our college days without using any frameworks. Simple classes.
  • J - Java. Java is Java.
  • O - Object. Object is object
Using POJO based framework brings the following benefits to the application development:
* Your class is not forced to implement any application specific framework. The provides the freedom to use the class outside the context of the framework.
* Testability of the class becomes better especially unit test cases ad the class do not needs the existence of the framework for it to perform.
* If application is using more than one framework, same class can be used in the context of all the frameworks being used.
* If you have only the compiled code of the class and do not have the freedom to modify the definition, even than the class can be used in the context of the framework being used. (An implicit assumption that you will using XML or external configuration file and not annotation here)

No comments:

Post a Comment