Nelz's Blog

Mah blogginess

JAR Encapsulation

When I was helping to start the project that I work most frequently on at work, I broke out the jars into a model looking like the following:old_stack

What I’ve realized lately, is though that is close to what we want, something like this would be preferable:new_stack

(The arrows in these diagrams represent a “uses” type of relationship… I.e. the JAR doing the pointing needs the JAR being pointed at for compilation.)

This provides a better encapsulation. For example, the XX-BASE JAR holds the DAO’s. In the old model, the XX-WEB JAR objects then could ‘see’, if not even use, those DAO’s. (Even if it does blow up at runtime…)

Now, I haven’t yet implemented the “new” model, and while thinking about it I am wondering if I have a problem with the UI layer interacting with the EJB’s, but I don’t think so… I’ll update if I am able to implement this before I leave my current job for one in SF.

(BTW, those graphics were created by myself using the free tools offered at Gliffy.com. You do have to register, but I’ve gotten no spam yet…)