magpiebrain

Sam Newman's site, a Consultant at ThoughtWorks

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.

Advertisements

13 Responses to “Think Simple”

  1. Nat Pryce

    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.

    Reply
  2. Sam Newman

    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 🙂

    Reply
  3. Stuart Ervine

    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.

    Reply
  4. hammett

    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

    Reply
  5. portly

    Some developers I’ve worked with seem to think that the size of their codebase is directly related to the size of their lunchbox …

    Reply
  6. Sam Newman

    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.

    Reply
  7. Tim Bacon

    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.”

    Reply
  8. portly

    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

    Reply
  9. Ville Aine

    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.”

    Reply
  10. Chris Milburn

    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 !

    Reply
  11. Sam Newman

    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.

    Reply

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Basic HTML is allowed. Your email address will not be published.

Subscribe to this comment feed via RSS

%d bloggers like this: