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.
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.
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:
# You can’t work out what the hell it does, therefore a rewrite is complicated. I would also argue that in this case you would have a hard time asking yourself if it does work
# You don’t have the time to change it
# You think really complicated code is really pretty
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”:http://www.amazon.com/exec/obidos/tg/detail/-/0596006764/qid=1097398975/sr=8-1/ref=sr_8_xs_ap_i1_xgl14/104-8886722-3321522?v=glance&s=books&n=507846 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?
bq. “There are two ways of constructing a software design: One way is to make it so simple that there are obviously no deficiencies, and the other way is to make it so complicated that there are no obvious deficiencies. The first method is far more difficult.”
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.