Hi ,
what is the Technical meaning of this context plain-vanilla Java Beans & plain-vanilla Java Class ??.
Hi ,
what is the Technical meaning of this context plain-vanilla Java Beans & plain-vanilla Java Class ??.
A 'plain-vanilla' bean/class means a very basic class usually with the following properties;
This is also called a POJO (Plain Old Java Object). For example;
public class MyPojo
{
/*
* Private class variables
*/
private String name;
private int size;
/**
* Empty constructor
*/
public MyPojo()
{
}
/*
* Standard getter/setters
*/
public String getName()
{
return name;
}
public void setName(String name)
{
this.name = name;
}
public int getSize()
{
return size;
}
public void setSize(int size)
{
this.size = size;
}
}
The "plain-vanilla" reference is to differentiate it from JavaBeans (an ancient best-practice for re-usable GUI widgets) and EnterpriseJavaBeans (elements of the Java EE spec).
A plain vanilla class is one that doesn't need to meet requirements of any framework or scheme.
A plain vanilla bean is a class with mutators and accessors (i.e. getters/setters), but no behaviour.
I think the history of the "plain vanilla Java Bean" and POJO went like this:
The "plain-vanilla Java Class" (aka. POJO) is a class which has attributes. As the name says, it's a Plain Old Java Object.
Ideally a POJO doesn't extends any class nor implements any interface. It doesn't have annotations either.
The "plain-vanilla Java Bean" (aka. JavaBean) is a class which has some requirements.
Serializable
So a JavaBean is a kind of POJO (not an ideal POJO because it implements Serializable) with some restrictions.
Resources :
On the same topic :
'Vanilla' description comes from ice cream, I think, and describes the usual or basic flavour available. Hence vanilla pojos are unadorned, simple and plain pojos. The term is also used in finance and sex, and probably other domains too. (This is the most non-technical SO answer I have posted!)