Consider:
You are born with no body parts.
Person me = new Person();
Should anyone attempt to interact with you before your organs have finished arriving you will die. me.interact();
Throws a NullPointerException because the class designer improperly initialized the instance. The designer should have provided a constructor. public static Person() {
this.organs = new Organs();
}
One by one, your organs are pushed into you.Instead, the class designer probably followed the JavaBean pattern and provided a setter method for Organs:
public void setOrgans(Organs organs) {
this.organs = organs;
}
etc.(For those that don't remember: The JavaBean idea arose because early versions of Java had no way of performing introspection, something that software tools really, really need. JavaBeans broke object encapsulation by design. Many programmers had to write beans to take advantage of their tools, and learned a very bad habit.)