Use My Base Class!


The Bible says, “In the beginning God created man…”, then goes on later to say, “…and Abraham begat Isaac, and Isaac begat Jacob and Jacob begat Joseph…” or something like that. In Java we have a similar story. “In the beginning Sun created Object… and Object begat Servlet… and Servlet begat HttpServlet and HttpServlet begat Spring’s ViewRendererServlet which begat your application’s custom TruckRoutingServlet…” My point is why all the ancestory? Don’t get me wrong, it makes sense in the Bible (as I look skyward for raining lightning bolts intended to correct blasphemy) but in my logic I want simple focused objects that don’t need to extend some Super-Golly-Gee-Whiz framework. I’m not taking a shot at framework designers or their products (Spring is the best thing since sliced cheese, for real!) but it bothers me that the quick start tutorials all assume you want to branch off of some base class. If you don’t know, I’m experimenting with AppFuse and following the SpingMVC basic trail with a splash of iBatis. (The cool thing about AppFuse is how it lets you mix and match from the popular web and persistance frameworks so you can have a JSF modular with JPA sprinkle in sitemesh with a side of french onion soup or you can just order the SpringMVC lite with JPA.)

Sure base classes provide a quick and easy way to enforce consistency and share common logic such as the need to parse a query string into objects or the details of opening a JDBC connection stuff some SQL in it and buttoning it back up. But base classes are a pain and I’d prefer a variant of the template pattern that relies on interfaces. I’m whining because I’m on the MVC section of the AppFuse tutorial and I’m dealing with creating a org.appfuse.webapp.controller.BaseControllerTestCase sub class where my now natural instinct is to create a base test cases that knows about and only cares about my interface that I intend to create. I’ll stop complaining now and go learn more about how to properly write unit tests without obsessing over every minute detail…

PS. I know I said “Can’t blog now…” earlier but I lied! Some things I just can’t let go of without blogging them. Show yo’ love in the square typeable thing underneath the “leave a comment” instruction.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s