Clean Code Between Religion And Truth

May 30, 2009   //   by Hackadelic   //   Blog  //  2 Comments

Migraine!Yesterday, I read yet another quote that evangelizes “clean code”:

Code that only you can understand does not make you an advanced coder; code that your grandmother can understand does!

Jeremy Brown – Macromedia Flash MX 2004 ActionScript 2.0 Dictionary

Now WTF is that supposed to mean?

No doubt, the only code that my grandmother could possibly understand is code that’s not written. Does it mean only a non-programmer is a good programmer??? Reminds me of “The only good X is a dead X” somehow (substitute X to your liking).

Who needs such a cheap, placative propaganda?

The truth is, code always reflects the thinking structures of the person who developed it. If you are a linear thinker, you will develop linear code. If you think in multiple dimensions and facets, your code will reflect that too.

Does that mean that skilled and smart programmers are bad programmers? Nope! It just means that skilled and smart programmers are more likely to understand code of other skilled and smart programmers, while dumb programmers are not. (And if they are really dumb, they’ll have difficulties understanding their own 😉 ) But even two skilled and smart programmers with completely different mental approaches will have hard times understanding each other’s code.1

There’s no better way to understand code than by getting to know the person who wrote it.

  1. If code is communication (and it is), then this is communication basics I: Miscommunication is less likely between people that think alike. []


  • What he meant by that is that, if other people are going to look at your code, you should take that into account.

    For example, if you are going to take notes in a class so you can study it later, you can use whatever structure you want for your text.

    But if you are publishing your text on a blog for example, you have to write better than that! People can’t understand your hacky notes made quickly while hearing the class.

    Normally this notes are disposed after a few days, but if you kept them for a year and tried to read, you will most likelly have a really hard time. But code normally is used for a relativelly long time, so you may want to keep it as understandable as possible. If possible, on a extreme case, your grandmother will be able to understand parts of it: “get_comment”, “update_comment”, “change_theme”.

    • The point is: The mantra about “clean” code has been so worn out in the last decade, it has almost lost its meaning. Obviously, code that is understandable for everyonee is utopia. So the question is: Who should you keep your code understandable for?

      Clearly, it depends on the abilities of the reader what kind of code he/she can understand. Compare it with, say, Chinese: If I gave you a child book written in Chinese, and you didn’t speak Chinese, you won’t be able to understand it, even if every kid (or grandmother) in China can.

      On the other hand, if I found out that someone working for me was spending hours in trying to make his code understandable by his grandmother, I’d probably fire him for wasting my money just to keep his grandmother busy. 😉

      I’m not saying that clean code isn’t important. But if code is communication (which it is), and every communication is interaction (which it is, too), then, as with any interaction, the outcome depends on all participants. You can’t replace a well-rehearsed team with “clean coding style”.

I have come here to chew bubblegum and kick ass...
and I'm all out of bubblegum.
-- Nada in They Live