Model Class And POJO Class
Andrew Mclaughlin
What is difference between Model Class and POJO class ? What are they exactly ? Question asked in context to android development.While extacting data from JSON what is the use of Model Class occurs?
2 Answers
POJO is a term coined by Martin Fowler to denote any ordinary Java object, not bound by any special restriction and not requiring any class path. Its a technical term.
A model class is typically used to "model" the data in your application. For example you could write a Model class that mirrors a database table , or a JSON . You could use objects of these classes as vessels to send / receive data.
As an example this tool allows you top generate model java classes for JSON . See here. Typically a model class is a POJO because models are actually simple old fashioned java objects. But then you may write a POJO but not use it as a model.
In simple POJO (Plain Old Java Object) is a class which has no business logic and provides Object representation without any behavior. Such objects are easy and light to transport from one layer to other layer, one process to another process even one system to another system.
So any object can be of POJO type but it is very common to have Model classes to follow these specification.