Think Simple
Simple code that works is only considered a bad thing by programmers who either don’t care about maintainability, or like to hide their inadequacies behind complex solutions.
This entry was posted on Thursday, October 7th, 2004 at 5:30 pm and is filed under Java. You can follow any responses to this entry through the RSS 2.0 feed. You can skip to the end and leave a response. Pinging is currently not allowed.
13 Responses to “Think Simple”
hear, hear… somewhat relevant essay that I just stumbled upon last night: http://www.physics.nyu.edu/faculty/sokal/dawkins.html
Simplicity is the most difficult thing to achieve. It’s much easier to learn to live with an overly complex solution than it is to find out how to make it simpler, or to build complex solutions than work out how to avoid complexity in the first place.
There are three reasons to live with a complex solution:
I’ve found myself using reason 1 in occasions where the software is as a whole so downright complicated that I’m actually scared of making any changes – such codebases will be littered with defensive coding measures, because people don’t know what the hell is going on, but it seems to work. I’ve used reason 2 a fair bit, and is completely reasonable. It’s people who don’t see a problem with complicated code that I get annoyed by :-)
I have to agree with you Sam, but I used to get a kick out of creating a really complicated system, that was as generic as possible to try and do everything and then showing off to all my developer buddies… for example a friend and I created a web based reporting tool that launched excel on the client installed some plugins, and ran a macro with an XML report template as a parameter. The macro then pinged a webservice and asked it for some data to put in the report and then built the report within excel. It worked really well, but was way over-engineered and the code was rubbish.
Now I strive for simplicity, and if code looks jumbled to me, then I try to do something about it. I’ve found that inexperienced developers like the BigObject antipattern (or monster-servlet or whatever it’s called). Teaching people to avoid this is the first step towards simplicity in my eyes. I’ve found by teaching TDD, people start to see how to layer applications so they are loosely coupled and have simple objects.
Hello Sam.
I think its all educational. We – programmers – were taught to believe the more complex our code is, the best we are – for dealing with complexity.
Simplicity is a inversion of these values and something difficult to achieve, as difficult as to change your values and conception about something.
Probably a new generation of professionals will think different from now on, which is hopefully great.
Cheers
Better Faster Lighter Java is a worthwhile read on simplifying your Java code.
Some developers I’ve worked with seem to think that the size of their codebase is directly related to the size of their lunchbox …
And we all know how small your codebase is, don’t we Ian :-)
In all seriousness, I’ve certainly seen complex code used as some kind of macho status symbol. It often reminded me of people who climb mountains – sure it’s a challenge, but it’s much easier to just go round the bloody thing. Writing complex code by way of a thought excersie is all well and good but doesn’t have a place in a maintainable codebase.
There’s a great quote about this that I can vaguely remember (for the real McCoy try wandering around Ward’s Wiki in the general area of http://c2.com/cgi/wiki?DoTheSimplestThingThatCouldPossiblyWork):
“There are two ways that a programmer can demonstrate how good they are. The first is to write code that is so complex no-one else can understand it. The second is to write code that is so simple no-one else can improve on it.”
Rod Johnson quotes Einstein in his ‘J2EE Development without EJB’ book (RJ’s, not Einstein’s ;-) ) …
[Things should be] “as simple as possible and no simpler”
a good maxim for life methinks
Tim, perhaps you meant this from C.A.R. Hoare?
One thing I have come across is that managers (particularly bad managers) are impressed by heaps of really complicated code, when you say you could rewrite it using half the code they just dont believe you !
Yep – it’s the “Lines Of Code = business value” mentality – I get concerned when anyone starts asking for code metrics rather than caring about shipped functionality.
Have your say
Fields in bold are required. Email addresses are never published or distributed.
Some HTML code is allowed:
URIs must be fully qualified (eg: http://www.domainname.com) and all tags must be properly closed.
Line breaks and paragraphs are automatically converted.
Please keep comments relevant. Off-topic, offensive or inappropriate comments may be edited or removed.