Stealing from the framework
George Malamidis, November 28th, 2006I have written in the past about feeling uneasy when it comes to bringing frameworks into applications without first trying to find a really good reason as to why I should be doing so.
But, OK, being skeptical about something is one thing, blindly denying the possibility of creating less work (oxymoron?) for yourself is totally different and possibly somewhat silly. And code reuse, misunderstood/misapplied or not, is less-work-remedy whichever way you look at it.
Let me explain with an example… A few months ago, my colleague Amit Arora introduced me to Spring’s JdbcTemplate - shame on me for not knowing! I love JdbcTemplate (functional database test setUp and tearDown firewater), like I enjoy many other tiny framework packed marvels out there. My problem is, though, it hurts having to import the whole of Spring Core just to use JdbcTemplate. You wouldn’t buy a car only to use the Stereo, would you?
Now, one solution would be to write the thing myself. This means extra work (bad) and the possibility of me introducing bugs (more work in the future (bad)), while JdbcTemplate has been thoroughly tested release-after-release by the nice Spring folks and the Restless Open Source Community ™.
Since then I’ve been toying with the idea of just grabbing the bits of code that I like (need, even) and shamelessly adding them to the codebase I would be working on at the time. Don’t get me wrong, I’m not trying to steal anyone’s thunder here and I’m making sure respect due is given with copyright stuff carefully packed with the code in question. Not that anybody ever reads those, but anyway…
Situations like this remind me of why I’m not a big fan of full blown frameworks that aim solve all of the worlds problems in the first place. There are always specific bits in there that are useful for specific applications, but the rest ends up being dead weight. I have a thing against dead weight. Others don’t mind it, I do not like the thing.
So, yes, I’m kind of not-a-100%-convinced about the morals behind this type of approach, but I’d rather go with a bit of borrowing rather than importing the whole shebang just for something that should have been part of the Java Core libraries in the first place.
Is that wrong?..

November 29th, 2006 at 9:53 am
“The whole of Spring Core” - come on, Spring core is only 109 kb with some utility classes for enums, io, lang and xml.
Importing these shouldn’t hurt too much.