Friday, June 22, 2007

What is a Pojo? Again?

Keep hearing this word? With numerous definitions already, here is one more: A Pojo is not just a javabean with getter/setter and isX() methods but can have other behaviors too, provided they only work on the attributes owned, associated or inherited by it. The definition extends to the anemic and rich domain modeling. Event handling in Toplink is an example of a rich domain model. The following is a Pojo even though DescriptorEvent and ClassDescriptor raises eyebrows but its fine as in ORM, the Domain object "is a" descriptor.


public class Domain {
protected String name;
public String getName () { return name; }
public void setName (String name) { this.name = name; }
// -- Richness for postBuild events..
public void addHandler (DescriptorEvent event) {
...
}
// -- More Richness for After Load...
public static void addOrder(ClassDescriptor desc) {
.....
}
}

No comments: