Thursday, 27 September 2007

POJOs and annotations

What is a POJO? It is a plain old Java object. I believe the definition allows inheritence, but I would like to think that it discourages use of factories, home interfaces and other such malarky (think EJB2).

But what really disturbes me is that people think that they can take a POJO and annotate it and it is still a POJO. Well that's just not true!

By annotating your POJO you have coupled it tightly to whatever framework supplies the class definitions for the annotations. For instance, EJB3. People rave about being able to use POJOs, but you're still annotating your classes with EJB specific code.

The programming model is similar to POJO, in that you now don't have to worry about that extra EJB rubbish you had to produce in earlier versions (never understood why that was needed in the first place!), but it's still an EJB.

As far as I am aware, please correct me if I am wrong, you can't take that EJB annotated class out of the J2EE environment and use it elsewhere without having to include the classes for the annotations. I believe you will get a "class not found" (or "class def not found") exception if you try to use a class that has been annotated, but you don't have those classes on your class-path.

Which to me makes annotations pretty much useless.

No comments: