Random Topics on Java Frameworks ( POJO, Hibernate Lazy loading, Coupling, Cohesion )

In terms of Java technology there are a lot of topics those help us to make our project structure more standard, more user friendly, more reliable. In this post I’m going to cover some of them.

Topics to be covered in this post-

  • POJO
  • Hibernate Lazy loading
  • Coupling
  • Cohesion

Random Topics on Java Frameworks ( POJO, Hibernate Lazy loading, Coupling, Cohesion )



POJO is –

  • The acronym of “Plain Old Java Object”
  • A normal java class
  • Does not require any special restriction or classpath

A java class can be POJO by following some rules –

  • Class must be public
  • Must have public default contractor
  • Private properties
  • Getters and setters methods

How POJO come?

Some years ago when developer had to work with EJB (Enterprise Java Beans), it was quiet difficult for them. Because each service needed lot of interfaces and additional methods to work properly. For running EJB developers need application server (JBoss, Glassfish). When spring came it offers simple services like POJO which removes the dependencies and restriction. And it is also easy to deploy POJO classes in lightweight container like servlet container.

POJO vs. Bean

POJO and Bean both classes follow the same rules except a Bean class must implement Serializable interface. POJO will not implement or extend any interface or class.

Hibernate Lazy Loading

Hibernate is –

  • A popular object relational mapping tool used in java
  • Maps object oriented domain model to relational database

Lazy loading is a very good feature of hibernate. It means that an entity will loaded only when the entity will be accessed for the first time.

Example –

Think about an online store. It has category for different products. In a large store there can be thousands of products with different categories. When a visitor visits the online store products catalog must loaded from the database.  Visitors must not like selecting on a category and load all the thousand products. Besides it is not possible also. Because the physical memory of the machine is not unlimited. Instead when the visitor will select a particular category, only the product under that category will be loaded from database. For managing these kind of stuff hibernate provide lazy loading feature.



  • Coupling means how two modules/classes are related and dependent on each other.
  • Loose coupling means classes are not coupled tightly. That means changing something major in one class will not affect the other.
  • In tight coupling classes are coupled tightly. Changes in classes will make the code difficult to maintain.



  1. Cohesion refers to the degree of interaction within module.
  2. It measures the level of strength and unity of different components of a program that are inter-related with each other.
  3. High cohesion is preferable because it is associated with desired characteristics of a software like robustness, reliability, reusability etc.
  4. Whereas low cohesion is just the opposite of high cohesion.


In software development always loose coupling and high cohesion is preferable.


I hope this post explained basic  concepts of POJO, Hibernate Lazy loading, Coupling, Cohesion. If you still have any queries, please do let me know in the comments section below.

Happy Learning 🙂


POJO- https://en.wikipedia.org/wiki/Plain_old_Java_object

Lazy Loading- https://en.wikipedia.org/wiki/Lazy_loading

Coupling- https://en.wikipedia.org/wiki/Coupling_(computer_programming)

Cohesion- https://en.wikipedia.org/wiki/Cohesion_(computer_science)


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s