No… More… Jars…
George Malamidis, July 7th, 2006The first rule of poker is finding reasons to fold your hand.
That’s what my colleague Marco Tolesano told me yesterday. And what a great metaphor for software development that is. We spend too much time thinking about why we should be doing something. Why not concentrate on why we shouldn’t be doing it?
Here’s a typical scenario: Blog savvy developer finds out about the latest cool magic offered by cool framework X. Promptly downloads the jars, fires up his fave IDE, creates a new project, chucks a bunch of jars in the lib directory and writes a few XML files. Kick-starts the app – NoClassDefFoundError.
Hmmm… I’ve seen this before.
Pastes the stacktrace in Google, the people on the forums say that dependencies A and B are unsatisfied. Easy. Downloads a few more jars and adds them to the classpath. Repeats this process a few times. Still doesn’t work, because the developer doesn’t yet fully understand how the framework works and how to set it up. In true developer fashion, the verdict is quite unfavorable towards the framework. What we don’t understand is lame.
Because our developer is persistent, though, and because he’s been reading more and more posts on JavaBlogs about the framework being the one to end all of the world’s problems, he gives it another shot. A few more jars later and a little bit more of reading the documentation and fiddling around with the configuration…
Hey, it works! Boy this is cool. Look, mom, I don’t have to write any code.
As developers, the more we understand something, the highest it scores on our list of what is good and what isn’t. You’ve seen it happen. Knowing how something works somehow makes it part of us. We’re prepared to go to war to defend something we understand if somebody has something negative to say about it.
Back to our story, it is needless to say that by now the lib directory weighs 44.9 Mb. 99.5% of the dependencies introduced are unused, but who cares when code looks so clean, when it’s the framework that takes care of everything behind the scenes.
A few weeks later, the 44.9 Mb have been added to the existing 151 Mb of the .ear bundle of the project the developer is working on for his employer, along with all the issues and bugs that come with 44.9 Mb of framework code. Everyone thinks this addition to their armory saves them time and makes the code cleaner, even though they have to write more XML than the actual code it would have taken them to achieve the same goal. Even though they have to spend 2 days running around when something goes wrong, trying to figure out what it is.
Here’s what I think: I think that we have taken the whole ‘code reuse’ concept a bit too far. Or, perhaps, we got it slightly wrong. We put too much focus on knowing what’s out there, so we can incorporate it in our work to make software better, and most importantly deliver it faster. The ‘velocity through knowledge of the tools for the job’ issue can be very tricky if it isn’t approached with caution.
For those of us out there who have had to deal with legacy code, do you remember how it feels when you figure out that the problem you’re trying to solve is due to a five year old library that’s not supported any more? Five years from now, there are still going to be developers who will have to code on Struts releases that came out in 2004. Surely that can’t be right.
Replacing code with declarative framework configurations doesn’t make the codebase cleaner. It makes it difficult to maintain. And it doesn’t save time, because when something goes wrong it takes hours of effort and frustration to fix. And most of the time, if we spend half an hour to figure out what it is the framework does to attack the problem at the hand, we’ll realize that we can do the same thing in 5 lines of code, most importantly avoiding all the dependency garbage the framework will force in our classpath, because Java frameworks are trying to be too generic, but usually end up just being overweight.
I suppose the need for third party libraries is largely due to the fact that Java’s core libraries justify the existence of something like the Commons packages, but let’s not get into Java’s shortcomings here… On the surface, there’s nothing wrong with that. Code reuse, dude. Until those libraries are out of date and not very well supported.
Everyone loves saying “don’t reinvent the wheel”. But most of the time it’s not about that. It’s about making a better, lighter, rounder wheel that’s exactly fit for the kind of terrain your car will roam and will be easier to change when you get a flat tire.
For my part, I’ll try harder to find reasons as to why I should fold the latest hand I’ve picked.
Seven or Eleven, snake eyes watching you, Double up or quit, double stake or split, The Ace Of Spades , Lemmy Kilmister once said.
Digg gambling

July 7th, 2006 at 1:04 pm
I totally agree with you about the so-called advantages of declarative configuration. I just spend many hours trying to figure out a classloading problem that the compiler would have found for me if I had just created objects in code instead of in XML (but lets avoid using the S* word so that we’re not flamed by all the S* fans out there – it’ll be our secret that using S* sucks ;-)).
July 7th, 2006 at 1:09 pm
The first time you use a framework, yes it is tedious and time consuming. But once you know it, next time it will be faster to use.
And I would love to see Struts being coded in 5 lines of code :-)
July 7th, 2006 at 3:24 pm
Spot on with that description of my typical approach to finding out about a new framework! I’ve definitely been thru that loop many times.
And often the framework is basically just too much for the fairly simple request/response requirements of the proposed webapp. I’ve been thru a whole thing recently trying to get Spring and Hibernate going when I just realized in a flash that I don’t NEED any of that stuff: so I went back to Struts Classic and it worked. What I needed was a “good enough” framework, not the “perfect” framework.
July 7th, 2006 at 3:48 pm
My first thought is that by skipping out on these frameworks, you’ll lose the power of “With enough eyes, all bugs are shallow.”
July 8th, 2006 at 3:01 pm
I like Struts framework and I also hate it! Struts 1.1’s general idea is indeed good. It does save a lot of complex coding . I always keep my Struts at the barest minimum level. The trouble comes when people extend things unnecessarily. I very much wish that the comunity knew what is good enough and just leave it there instead of perpetually trying to ‘improve’ and in effect spoiling things.
July 10th, 2006 at 9:05 am
I hate xml for this reason. On one hand, Java is such a programming success, that abstraction *CAN* be taken to a config only level, but the IDE’s can’t follow it there.
A great feature to have for Java SE7 would be compiler checked XML configuration. Then maybe it wouldn’t suck so much.
July 10th, 2006 at 9:34 am
Well when I run a project as manager I will make certain that my programmers use framework what a lot of people know… It much easier to get new people in and get them up to speed… home grown frameworks can’t give the support like struts or spring… my customers want a solution they are not buying a framework!
July 10th, 2006 at 11:23 am
I think it’s the problem of everything in software…. a lot of people is programmig for Windows Native because they know it’s here for stay…. days ago i read something interesting about open source project…. it’s a “Natural Selection” the good project got critical mass and grow…. the bad project disappear with no support…. for example Struts & EJB are evolving to survive the new ecosystem…. struts is going to merge with webworks and EJB3 are now Pojo-based like Hibernate…
It’s up to the developer to build a system that’s not heavily dependent to a particular framework…. even if a project is based on struts… i can still have jsp without it….
PS I think Struts was great… until u have to manage all the Bloat-ware needed…. now i hope i can use Tapestry/Hivemind in my projects…
PPS about XML – config files…. a lot of people/projects abused of it….. now EJB3 use a very friendly & clear annotations… i hope that a lot of other developer follow that way!!!
Bye and sorry for being so Long!!!
July 10th, 2006 at 4:59 pm
anybody that knee-jerks and starts defending their favorite API in response to reading this post is the exact reason we have this problem in the first place….after you have been around the block a a couple times, kiddies, you will understand.
and i REALLY like the lemmy reference (you kiddies wont get that one either).
July 12th, 2006 at 8:51 am
If your colleague mentioned in the article, is the same Marco Tolesano I once worked with, it would be great to hear his view on this subject.
I recall him being a great fan of Spring / Hibernate / Inversion of Control etc