Programming While Stupid

Over engineering is a major problem within the software industry. This problem has led to the adoption of ‘lean software development’ – at least amongst the agile folk. Lean software development is writing code to support the current set of requirements and nothing more. This is not as easy to do as one might think.

As developers we naturally tend to make assumptions as to what the user, or system, will need. In truth, it is very difficult to accurately predict the future requirements of a system. Coding to meet our assumptions will inevitably lead to over engineering.

We should not let our intuition guide us into false requirements. As strange as it may sound, it takes a concious effort to stop ourselves from doing extra work. We need to adopt a ‘lean coding culture’. We need to constantly remind our selves to stick to lean software development. In agile teams it is common to hear developers reminding each other with certain acronyms and expressions e.g. ‘do the simplest thing that works’.

‘Do the simplest thing that works’ is in-line with lean software development, although it can be misleading. Some people interpret this as ‘do the first thing that comes to mind’ e.g. slap on another if statement – that is a simplistic solution and not a simple solution. If you take a quick and dirty simplistic approach you will end up with a big ball of mud. You need to do the simplest thing that works. The thing that works is something that can be tested, it is something that does not add unnecessary complexity. Therefore the simplest thing that works is not necessarily the quickest and easiest thing to do.

When talking about lean software development we often refer to KISS (Keep It Simple Stupid). I agree with keeping things simple but I don’t like to be called stupid, the truth hurts. I prefer to use: Keep It Simple and Sensible. This is more positive and the sensible part indicates that we should give some thought to our code. For example, instead of littering your code with conditional statements you could refactor the code to use an established design pattern. Having said that, design patterns are not always a good idea.

You should not implement a design pattern unless there are real signs indicating that you need a smarter solution. It can be detrimental to implement a design pattern for the sake of having one. You are likely to implement the wrong pattern and that code will be a hindrance. Only do what you really need to do. This is also referred to as YAGNI.

YAGNI (You Ain’t Gonna Need It) – This is a term used by Russ Olsen in Design Patterns in Ruby. In this book, Russ Olsen does a fantastic job of explaining design patterns. He also explains when not to use certain patterns and the problems that come with using each pattern – After all, software is about trade off’s.

Russ Olsen explains that we should not write code or implement patterns in anticipation of a requirement that might emerge. Firstly that requirement may never surface, and if it does it may have a stipulation which makes the pre-emptive solution void. It is safer to code to meet the current and real requirements of the system. To drive this point home, here is a delightful paragraph from Russ Olsens’ Design Patterns in Ruby:

“Look at it this way: Barring a sharp blow to the head, as you stand here today you are as dumb as you ever will be. We are all learning, getting smarter every day. This is especially true in software projects: You can be sure that you will have a better grasp of the requirements, technology, and design of any software that you work on at the end of the project then at the beginning. Whenever you put in a feature before you really need it, you are guilty of programming while stupid; if you wait until you really do need the thing, you are likely to have a better understanding of what you need to do and how you should go about doing it.”

The moral is: Don’t be guilty of programming while stupid

5 thoughts on “Programming While Stupid

  1. I do prefer your version of KISS – it is more positive and meaningful than potentially insulting, especially in multi-lingual groups where once or twice I have seen people infuriarated temporarily/permanently when it came up.

    I quite like the idea that 1 is stupid at this point in time, and will be less stupid in a point in time in the future as 1 would have learned something(s) more that could be assistance to that future circumstance.

    Elaborating a little further on this topic, I wanted to draw your attention to 1 of the 7 principles of Lean Software Development – the Last Responsible Moment (to decide/to act/to code/to write/etc). Lean Software Development is a little more than keeping KISS in mind when implementing code for a feature that may or may not be required. It is very much driven from a Value Chain Analysis and thus applies to *everything* one does on a software project/product/team.

    Check out my brief post after I read the book a little while ago – perhaps it will inspire you to buy and read it also!

  2. Rob,

    I am glad you picked up on the main difference in ‘programming while stupid’ and ‘keep it simple stupid’. ‘programming while stupid’ implies you should not take premature steps and rather wait if you can. In ‘Keep it simple stupid’ you are considered as being stupid regardless of what action you take.

    You also make a good point about lean software development being more the just implementing features – there is a bigger picture. Perhaps I will look into acquiring that book.

    – Thanks

  3. I’m so glad that you found Design Patterns In Ruby useful!

    I think the concept of “programming while stupid” is a very valuable one – it is a good way of reminding folks who are getting a bit too enthusiastic about technologies or all encompassing designs of a) what we are trying to accomplish and b) the limited resources – including programming time and attention – that we have.

    Finally, I have to mention that I have a co-worker (Hi Tom!) who uses the word YAGNI almost as a spell to ward off complex designs. Explain some overly complex idea to him and he will usually answer with the single word.


  4. Hi Rus, thank you for the comment!

    Design Patterns In Ruby is an excellent book – a must have in my opinion.

    Tom might be pleased to know that YAGNI has become a common ‘spell’ at my place of work.

    Kind regards, Daryn

Leave a Reply

Your email address will not be published. Required fields are marked *