Why I Hate Frameworks
I’m currently in the planning stages of building a hosted Java web application (yes, it has to be Java, for a variety of reasons that I don’t feel like going into right now). In the process, I’m evaluating a bunch of J2EE portlet-enabled JSR-compliant MVC role-based CMS web service application container frameworks.
And after spending dozens of hours reading through feature lists and documentation, I’m ready to gouge out my eyes.
Let’s pretend I’ve decided to build a spice rack.
I’ve done small woodworking projects before, and I think I have a pretty good idea of what I need: some wood and a few basic tools: a tape measure, a saw, a level, and a hammer.
If I were going to build a whole house, rather than just a spice rack, I’d still need a tape measure, a saw, a level, and a hammer (among other things).
So I go to the hardware store to buy the tools, and I ask the sales clerk where I can find a hammer.
“A hammer?” he asks. “Nobody really buys hammers anymore. They’re kind of old fashioned.”
Surprised at this development, I ask him why.
“Well, the problem with hammers is that there are so many different kinds. Sledge hammers, claw hammers, ball-peen hammers. What if you bought one kind of hammer and then realized that you needed a different kind of hammer later? You’d have to buy a separate hammer for your next task. As it turns out, most people really want a single hammer that can handle all of the different kinds of hammering tasks you might encounter in your life.”
“Hmmmmmm. Well, I suppose that sounds all right. Can you show me where to find a Universal Hammer.”
“No, we don’t sell those anymore. They’re pretty obsolete.”
“Really? I thought you just said that the Universal Hammer was the wave of the future.”
“As it turns out, if you make only one kind of hammer, capable of performing all the same tasks as all those different kinds of hammers, then it isn’t very good at any of them. Driving a nail with a sledgehammer isn’t very effective. And, if you want to kill your ex-girlfriend, there’s really no substitute for a ball-peen hammer.”
“That’s true. So, if nobody buys Universal Hammers anymore, and if you’re no longer selling all those old-fashioned kinds of hammers, what kinds of hammers do you sell?”
“Actually, we don’t sell hammers at all.”
“So…”
“According to our research, what people really needed wasn’t a Universal Hammer after all. It’s always better to have the right kind of hammer for the job. So, we started selling hammer factories, capable of producing whatever kind of hammers you might be interested in using. All you need to do is staff the hammer factory with workers, activate the machinery, buy the raw materials, pay the utility bills, and PRESTO…you’ll have *exactly* the kind of hammer you need in no time flat.”
“But I don’t really want to buy a hammer factory…”
“That’s good. Because we don’t sell them anymore.”
“But I thought you just said…”
“We discovered that most people don’t actually need an entire hammer factory. Some people, for example, will never need a ball-peen hammer. (Maybe they’ve never had ex-girlfriends. Or maybe they killed them with icepicks instead.) So there’s no point in someone buying a hammer factory that can produce every kind of hammer under the sun.”
“Yeah, that makes a lot of sense.”
“So, instead, we started selling schematic diagrams for hammer factories, enabling our clients to build their own hammer factories, custom engineered to manufacture only the kinds of hammers that they would actually need.”
“Let me guess. You don’t sell those anymore.”
“Nope. Sure don’t. As it turns out, people don’t want to build an entire factory just to manufacture a couple of hammers. Leave the factory-building up to the factory-building experts, that’s what I always say!!”
“And I would agree with you there.”
“Yup. So we stopped selling those schematics and started selling hammer-factory-building factories. Each hammer factory factory is built for you by the top experts in the hammer factory factory business, so you don’t need to worry about all the details that go into building a factory. Yet you still get all the benefits of having your own customized hammer factory, churning out your own customized hammers, according to your own specific hammer designs.”
“Well, that doesn’t really…”
“I know what you’re going to say!! …and we don’t sell those anymore either. For some reason, not many people were buying the hammer factory factories, so we came up with a new solution to address the problem.”
“Uh huh.”
“When we stepped back and looked at the global tool infrastructure, we determined that people were frustrated with having to manage and operate a hammer factory factory, as well as the hammer factory that it produced. That kind of overhead can get pretty cumbersome when you deal with the likely scenario of also operating a tape measure factory factory, a saw factory factory, and a level factory factory, not to mention a lumber manufacturing conglomerate holding company. When we really looked at the situation, we determined that that’s just too complex for someone who really just wants to build a spice rack.”
“Yeah, no kidding.”
“So this week, we’re introducing a general-purpose tool-building factory factory factory, so that all of your different tool factory factories can be produced by a single, unified factory. The factory factory factory will produce only the tool factory factories that you actually need, and each of those factory factories will produce a single factory based on your custom tool specifications. The final set of tools that emerge from this process will be the ideal tools for your particular project. You’ll have *exactly* the hammer you need, and exactly the right tape measure for your task, all at the press of a button (though you may also have to deploy a few *configuration files* to make it all work according to your expectations).”
“So you don’t have any hammers? None at all?”
“No. If you really want a high-quality, industrially engineered spice rack, you desperately need something more advanced than a simple hammer from a rinky-dink hardware store.”
“And this is the way everyone is doing it now? Everyone is using a general-purpose tool-building factory factory factory now, whenever they need a hammer?”
“Yes.”
“Well…All right. I guess that’s what I’ll have to do. If this is the way things are done now, I guess I’d better learn how to do it.”
“Good for you!!”
“This thing comes with documentation, right?”
NOTE: I originally posted this article to the Joel on Software forum in September 2005.










March 22nd, 2006 at 9:50 am
Just a thought about your response to the guy who advocated spring… on the Joel page (http://discuss.joelonsoftware.com/default.asp?joel.3.219431.12)
Your example is bogus. (sorry).
If your application is small enough and WizzyShopping cart is simple enough simple instantiation is of course the way to go. The time to apply inversion of control is when the instantiation would be in fact a JNDI lookup (Service Locater etc) or when WizzyShopping cart has code that does things like access the database, or the HTTP session etc.
In the first case you wind up with lookup strings and other things hard coded (unless you look them up somewhere too or construct them from a bunch of other information!).
In the second case it can become impossible or difficult to write a unit test your service because the WizzyShoppingCart wants a database (and so you have to build one of those for the test) and it wants the session (so you have to find a way to give it that too), and perhaps it wants several other objects you wrote. Assuming you do all that setup and get the test written, what you have is a test for your SERVICE that breaks when:
The database has screwy data left over from another test
Your other classes (not under test) break
The way WzzyShoppingCart uses the HTTP session changes.
Granted if you are careful not to do any initialization upon construction with WizzyShoppingCart then you can still replace it with a mock implementation, but that only works because YOU wrote WizzyShopping cart. For things you don’t write (and you may be required to use in the way that you were required to use java) you’re *stuck* if you do a new Foo().
Finally, you said that your class depends upon spring… but that is of course not true. It depends on the existance of some container that will provide depenancies. It would work well with pico, nano, hivemind or spring (to name a few).
As one commenter said on the joel page, frameworks are designed to handle certain situations. The situation where you need a simple POJO that just holds data and a little logic to be added to a field on your class is not the problem spring is meant to solve. I had the same reaction to IoC when I first ran into it… but having used it for a while and can see what problems it is meant to solve I am now a fan.
It’s also worth noting that you can use the IoC of Spring without using the AOP or thier MVC web stuff. In that way Spring is very ammenable to riping out (ignoring) the other stuff and can be used as a library that provides an inversion of control mechanism.
Just another tool in the box.
June 8th, 2006 at 1:17 pm
Factory Factory Factory makes me remember Major Major from Catch -22 :->
June 8th, 2006 at 6:27 pm
Brilliant :-)
June 12th, 2006 at 8:47 am
You could always read up on a few design patterns and then just make your own ‘lite’ framework, at least you won’t have to learn it!
June 20th, 2006 at 6:37 am
OR you could just use servlet framework for framework as we do. Simple, effective and easy to learn.
- Filters are actions
- View is jsp/jstl
- Database is whatever database we want to use
Simple as simple can be and works quite well.
June 20th, 2006 at 10:08 am
Great article. Should be required reading for anyone that claims to be a J2EE expert.
June 20th, 2006 at 10:35 am
I sort of agree with you, but my reasons are a bit different.
I didn’t use to hate frameworks, but over the past few years it seems like they’ve gradually taken over my various gigs. Originally people bought into them for the promise, and the promises are big. “Simplify”, “Easy to use”, etc. etc.
What I’ve started to see is that you’re not so much simplifying as substituting framework-domain knowledge for code knowledge, e.g. you now have to know hibernate as well as JDBC, with the added complication that your hibernate code is now dependant on all kinds of unpleasant black-boxed stuff inside hibernate that’s difficult to see and trace at best. I’ve run into, for example, at least 3 different versions of hibernate, each with a slightly differing syntax, moving my coding somewhat into the domain of trial and error, using any of the following, in no particular order:
-Try it the way the docs say you should; test (often doesn’t work because of version mismatches)
-Google for other examples; test
-Grep around in the code base for something similar that works; test
Trial and error coding is not an improvement.
Some of the same issues exist for Spring, which has some nice ideas in it but does come with associated costs that people tend to gloss over - for example, because most of the execution paths run through spring, you can’t easily trace code through multiple classes.
Frameworks can give you some nice things, but I’m a bit tired of everyone I work with drinking the “Enterprise Level” kool-aid.
July 10th, 2006 at 11:16 pm
Well I think that the things get really complex when you are trying to build high quality software which is extendable and custamizable. But I dont think the people who sale software tools, dont sale Hammers. Thats the beauty of it. If you want a factory of factory of factory you can do that there are hundards of most amazing people building these for you for free most of the time. But if you dont want it you can get a hammer or use a brick for that mater. :)
July 11th, 2006 at 12:17 am
It is always better to use some thing for the purpose for which it is required. It is not wise at all that you have hammer factory for only one type of hammer. I have visited one Big Garment factory named Cressent Green Wood which produces garment. They are producing 25000 jeans per day and have their own factories for producing thread, cloth and buttons, cuz they need different customized type of threads, cloths and buttons to produce a variety of jeans. So actually its the situation which tells you whether to use some perticular pattern / framework or Not.
November 15th, 2006 at 3:23 pm
“I’m evaluating a bunch of J2EE portlet-enabled JSR-compliant MVC role-based CMS web service application container frameworks.”
I’d love to se this list, preferably with comments – I need some base to build an application. That application can make use of CMS, portlets (I’ll need bunch of standard e.g calendar, messages/news), light-weight BP engine (should already be implemented in good CMS anyway) optionally forum
“Most of these frameworks advertise their underlying technology rather than their capabilities …
Built to conform with the new JSR-170 standard ..
And it’s very rare to see something like this:
“The content repository handles centrally developed content as well as user-contributed content. Administrators can stage their own content, approve the content written by internal authors, and quarantine content written by user contributors.
..
It’s like a chef telling me what kind of oven he used to cook my meal, rather than telling me what the food tastes like.”
It sound like you there looking for several half-ready applications built on top of the same framework (so they hopefully could be easily integrated with each other). So you story despite all humor describe situation in other way around. You not looking for hammer, not even for spice rack.. you looking for kitchen table, oven and couch for your kitchen.
Yes you want chose fabrics for upholstered furniture and paint table, but
it’s ready products (or half-ready) not a tools.. so, shopping for toolsets might be not very helpful.. Analogy is dangerous thing – they good for illustrating one point, but people tend to keep them going way longer. Frameworks could have sample app. (typically pet store), but toolsets in Wal-Mart or Costco unlikely to come with sample table.. so I’ll stop my analogy right here.
CMS could be quite complex app., forum also is application and this 2 applications not that often live together.. so, unlike small e-commerce site it unlikely to be sample app. in framework distribution.
BTW about Spring
“Without the object instantiation defined in the bean configuration file and performed by Spring under the covers, the object myCart will never be instantiated. So that’s a clear *dependency* on the Spring framework.” – No it’s not, you can use other framework or do it yourself.
December 1st, 2006 at 3:59 am
“No it’s not, you can use other framework or do it yourself.”
Just curious, must Bean factories be injected too — according to best practices? If so the mechanisme should be injected by a mechanism that could injected by a mechanisme that must be injected by ..
I think Spring can perfectly does that.
Best wishes
November 28th, 2007 at 8:32 am
Hi.
Good design, who make it?
December 10th, 2007 at 4:12 pm
Thanks! I designed it myself.
In a former life–before I specialized in AI programming–I was a web designer, focusing mostly on just graphics stuff. And before that, I used to do a lot of drawing and painting (click on the “gallery” link to see some of my stuff).
Someday, when I’ve made a gazillion dollars in the software industry, I hope to get back to being an artist and a writer (I studied playwrighting in college).
January 7th, 2008 at 7:22 pm
*stop* hammer time
January 8th, 2008 at 11:35 pm
I like this. Too often, everyone wants to overarchitect the hell out of everything, because it’s a whole lot simpler to make things more complex. IBM LOVES this. Users love simple. Developers love simple (but they often don’t realize it). That’s why Rails, Wicket, Grails, etc. will be so successful for some time - because they make web development simple.
In other words, as a guy who’s way smarter than software architect I’ve ever met said (look it up to find out who):
Any intelligent fool can make things bigger, more complex and more violent. It takes a touch of genius — and a lot of courage — to move in the opposite direction.
January 9th, 2008 at 6:37 am
My take on these things are to recommend my customers (or friends) to drop the web framework. The system will be complex enough with all the remaining server-side frameworks you’ll be forced to configure, pseudo-build, and understand as it is.
I wonder if there are anyone else on the planet except me who have experience with both J2EE portlets (WebSphere) and Joomla development. I understand that in this case you must code in Java and you must deploy it on a fiendishly complex and brittle application server.
But if you didn’t, the company you work for could save quite a lot of money :)
January 9th, 2008 at 10:29 am
where to start… i think this is pretty spot-on. the real disaster in all of this mess is the end product. as in, investing months of efforts into even rolling out pre-packaged commercial software the end users don’t like. when anything is that complex, and the end result is not at least “nice”, something has gone deadly wrong.
i was encouraged by asp.net, as well as jsp/java. then you use that stuff and look at how hard it can be to perform somewhat simple tasks. again, if you have a business background you start to think in terms of what you can charge for this type of product development and start investigating other ways to produce applications (products).
i have developed universally applied approaches to using java and .net (c#) with data access layers and business objects. they work well. but the price of universal design comes with a fair heft for each deployment. might just be the way it is.
what is most interesting are new bread frameworks. like ruby on rails. the confounds are at least reasonable. and once you invest a little time, it just sorta “feels right” when you rip into application development for the web at least. and ruby is pretty nice. dynamically typed and whatnot. interesting to see languages like c# scramble to pick up features of ruby. and of course asp.net now does mvc… hmm… like rails…
i like this posting because it asks for more. it wants things to be better and demands that technical people get technology into a consumable state. the more the community stands back and says WTF are we doing with this junk, the better things will be.
January 9th, 2008 at 12:48 pm
The intention of a framework is to manage complexity. If the framework you choose results in more–not less–complexity, you’ve picked the wrong tool.
I appreciate the reductio ad absurdum though. ;-) I hope that the architects in my company don’t read this post. If they do, I’ll be writing factory factory factories till I am compelled to buy a ball-peen hammer.
January 11th, 2008 at 8:44 am
I feel that the biggest problem that most developer/architects face nowadays is the sheer number of options out there, and the “need” to use frameworks as they are deemed to make life better for us.
Although solutions and applications have evolved tremendously in the past 10 years, the issues we are facing now are essentially still the same: scalability, availability, maintenance, presentation… admittedly more sophisticated.
One of the first few things I was taught when studying IT was how to analyse a problem and draw a solution which answers that problem. In essence, would you use spring, MVC and patterns to develop an application that checks the number of items left in stock for a small shop?
Sure you could always argue that the shop might become really successful and eventually become a huge mall, process order online and sell car insurance! But would the shop really gain at this point from the app being portable, scalable to thousands of users and have a flashy-gui?
If you have the plans of your house drawn and you have an idea of the future extensions you might want to build, you’ll have an idea of which hammer might be more suitable or if you actually need to invest in a hammer factory factory factory factory.
January 15th, 2008 at 5:38 pm
I’ve thought for years that frameworks were overused. Very few architects seem to ask “Do we really need a framework?” at the start of a project. They just take it for granted that a framework (preferably one that they create themselves) is required for any new application. As was alluded to by others, often these frameworks just add more complexity and do damage to a project.
January 16th, 2008 at 5:04 am
Like one of my friends puts it: “You have got it all wrong. The Idea is to listen every feature request there ever might be and have 150 consultants working on the project.” Opposite of solving the problem.
I just don’t approve.
January 24th, 2008 at 2:57 pm
Don’t hate all frameworks. The language you are using is just the wrong tool. Might I suggest Ruby? :) Rubinus and Rails have saved me hundreds of hours. I too hated frameworks once, but that was when I was a C# coder.
January 24th, 2008 at 11:08 pm
Did it ever occur to you that in a sense, if youre using Java, you are using a framework.
I’m a .NET guy, but isn’t the core java framework over 30,000 classes in itself? Do you avoid that framework and write your own StringBuffers and collections? Or perhaps youve written a replacement for swing, is not swing a framework in itself?
My point is, “framework” is all in where you draw the line, and say “from here on, will write my own code”. Hating frameworks and using a high level programming language is being amish and owning a cell phone.
I recommend you take the red pill and realize that some projects can be written in fractions of the amount of complexity and time, if you can learn to leverage someone else’s code. Many of these frameworks are supervise by some of the most skilled developers around. Things like Hibernate, Jruby, and Spring… they become popular for a reason: you can get more done in less time. Use them, and contribute and help others make them better!
March 5th, 2008 at 10:30 am
Great analogy Benji! Frameworks can be extremely cumbersome if you try to fit all your needs into them.
BUT, there are different types of frameworks, and rapid development frameworks, vs. CMSs, vs. etc. Once again, it leads back to the question of what you’re trying to create. And if it’s a spice rack, find a framework (or any other pre-built app) that can build the spice rack the best. More importantly, if you only need a small portion of a framework, like the spice rack portion, then use only that small portion that can help in your app. Don’t try and force your project into the rules and coding practices of the entire framework.
Most often, people like certain elements of frameworks that fit their needs. Use those elements. Never mind the rest of the factory factory.
March 16th, 2008 at 9:53 am
If you’ve done some woodworking projects in the past, why don’t you already have a tape measure, level, hammer, and saw??
Its a valid question, because good programming is all about reuse, is it not? If somebody or some organization is starting a significant project entirely unlike anything they’ve tackled before, these frameworks are excellent places to start. If they’ve already done similar projects, shouldn’t they reuse the components they already have and are already familiar with?
I loved your post and have shared it with friends, but I think the argument falls short.
Cheers,
-Michael-
November 10th, 2008 at 1:27 am
Man, where did innovation go??
I would never listen to so much crap from a hardware-store guy for a mere hammer I need.
I will pick up something with enough weight and start hammering. Of course I might hit my finger a few times, as a result of using improper tool, but hey life is full of accidents. I fell off from my bed last night and I have no clue as to why and I won’t spend another another week picking my brain as to why it happened, and I’m not going to erect walls around my bed to prevent it from happening again.
Analogies are good and bad like Frameworks. Some really shed the light on the subject matter and enable us to understand things better, as for some, it might sound clever when u hear it first, or it might sound even funny, but they don’t help us in trying to understand things that we find hard to grasp.
Your analogies serve no purpose except for a bit of humor without really making any point…… almost like slap-stick humor.
But I have to admit I’m no fan of the gazillions of frameworks out there. I just happen to pinch things from here and there and make them work for me….
And as such, since they do serve me once in a while in ways different than the Architects intended, It nevertheless serves me and helps me out once in a while…
So, in conclusion, frameworks aren’t that bad at all, you just have to find your own way of using it…
July 2nd, 2009 at 7:46 am
check this out…
this is mine…