There’s been alot of talk lately about Persistence frameworks for Java. I’m quite familiar with the subject having worked with ODMG, TopLink and now OJB. However, I found it curiously interesting that JIRA uses the OFBiz Entity Engine. Real world applications are the best validation for the usefulness of a framework. JIRA provides good validation for the Entity Engine (don’t know what else it uses in the OFBiz project).
So, I did a little bit of reading regarding the Entity Engine, to my surprise I read this in their docs:
No Object-Relational Mapping
- Data is all relational, front to back, meaning no extra object to relation and relation to object translation code
- Relational data is also the data structure used in logic, or rules, languages providing a seamless integration between the Rules Engine and the Entity Engine
Very Few Objects in Applications
- Functionality implemented as events and services that are static Java methods, BeanShell scripts, rulesets or workflows
- Data is manipulated directly in entities rather than using an object model
Have they gone mad? What’s going on here? After all these years of moving away from Relational models to OO models, these guys have gone full circle. Could the be on to something?
Let’s think for a moment here, when we build webapps, using a framework like Struts or Webwork, we see things called Actions, in fact its not just for webapps, you find them in Swing too? What are Actions? Actions are functions in the form of an object. Could we just not have just had plain functions as first class objects? Are Actions the same thing as functions, so like what the OFBiz guys say, there are only Services and Entities. Just like what a C guy would say, there are only functions and data structures.
My take on all this is that “programming in the large” is a bit different that the usual programming. What happens is that abstractions that are quite similar to the usual procedural things become important. You simply can’t deny the importance of these Actions in webapp or gui work, however they aren’t the same thing as functions in C. The difference is that an Action (aka Command) can be persisted, sent as a message, suspended, undone, redone, stopped, cancelled, approved etc. These are not attributes that are associated with function in the procedural sense.
What about their data model being all relational? Does that mean we throw out Objects, that is Identity, Inheritance and Polymorphism? My take on this is that the relational model has nice properties, for example, you can always dynamically create a new class (i.e. table) based on existing classes (i.e. tables). You can dynamically create views that are subsets of the attributes of a single class (table). In fact there’s a whole lot of kinds of way you can compose a new class (i.e. table) dynamically. You can’t do that with Java, you can’t do that in traditional OO. However, I don’t think you can throw away Identity, Inheritance or Polymorphism. On second thought, maybe inheritance but definitely not polymorphism. We may take inspiration from BC4J framework from Oracle, it nicely unifies the OO and relational model.
In summary, the OFBiz guys may have not gone full circle, however they may not realize it. They’ve probably stepped into a whole new world of “Programming in the large”.