Making Good Software

A blog by Alberto G (Alberto Gutierrez)

Written by Alberto Gutierrez

October 30th, 2009 at 2:52 am

The 7 characteristics of simple code (KISS)

with 8 comments

I used to believe that the most important quality of code is its extensibility. The code had to be prepared for future changes so I would code lots of things not necessary now. But after realizing that I never was right upfront guessing what the future changes will be, and after having quite a few maintenance and handover nightmares, a few a years ago I decided that I will take the opposite approach to what good code is. Ever since I did that, I am every day more convinced that the key characteristic of good code is simplicity. Simple code is easy to read and easy to change. And because it is simple, it is less prone to have bugs (the more complex the algorithm you are creating the more changes to make a mistake).

Whenever you are coding, I recommend you to check every time if your code is still simple, and remember: “there are no hard problems, only hard solutions”

The seven main characteristics of simple code are:

1.- Easy to read.

Simple code doesn’t need additional documentation, or it only needs minimal documentation to be understood

2.- Easy to use.

Whoever is using your code will find it intuitive to use your objects.

3. Easy to change.

Simplicity means that there is no duplicated logic. A change should match a single place in your code.

4. Doesn’t use any non-necessary third party, tool or technology.

Through my experience I have observed how some developers just love to use technologies, tools and frameworks just for the sake of making the project more “cool”. Every time you use them, you are adding extra complexity, and extra complexity means that is more difficult to understand, to maintain and is more prone to failures.

5. It looks simple.

If it doesn’t look simple, it is not simple! You know your code is simple if when you finish you are astonished at how simple the final solution is and you ask yourself how it was possible that it took you so long.

6. Lean.

It only does what is necessary, and nothing else. I think most seasoned developers would agree that trying to anticipate the problems your code will have to face in the future is impossible.

7. Is straight forward.

It doesn’t have unnecessary indirections; the most important operations only require a straight method call.

How can we develop simple code?

The key of producing simple code is continuous refactoring, and the only way to do this is continuous testing.

You are going to need refactoring because every time you add a new line to your algorithm, you are probably making it more complex. So every now and then you should refactor to get it back to a simple stage.

You need many tests because you are doing so much refactoring, and if you don’t have a safety net you are going to introduce bugs into your system.

8 Responses to 'The 7 characteristics of simple code (KISS)'

Subscribe to comments with RSS or TrackBack to 'The 7 characteristics of simple code (KISS)'.

  1. […] This post was mentioned on Twitter by Igor Sukharev and Bin-Blog, Vincent Marque. Vincent Marque said: RT @programmingjoy: The 7 characteristics of simple code (KISS) #programming […]

  2. “the more complex the algorithm you are creating the more changes to make a mistake”
    Maybe you meant “chances” instead of “changes”

    Igor Popov

    30 Oct 09 at 7:05 am

  3. One of my biggest irks is the unnecessary use of comments. There are times that comments help with the readability of code, but it is unnecessary to include your initials with a date stamp in a comment – especially in times of version control.

    Daniel H

    30 Oct 09 at 8:41 am

  4. “Doesn’t use any non-necessary third party, tool or technology”

    I would disagree. I don’t ever NEED to use jQuery. I can do everything that it does on my own with simple Javascript, but then I break all of characteristics that you have mentioned here.

    Sometimes simple requires use of a third party library to KISS.


    2 Nov 09 at 8:25 am

  5. I have to agree with JW here. Use libraries that make reading code simple.


    3 Nov 09 at 6:26 pm

  6. Hello Alberto,
    Your post is very interesting. I have translated it in french : Les 7 caractéristiques d’un code simple (KISS)
    Regards, Fabrice.

  7. Thanks for the interesting advise. We are about to redesign the architecture for this open source project on software agents. I invite folks here to review the proposed redesign and provide any relevant feedback.


    20 Dec 09 at 6:11 pm

  8. […] Hoy he reparado en una web (que he agregado a mis enlaces) que trata sobre temas de la programación y, en definitiva, se centra en hacer buen software. […]

Leave a Reply