Clean Code

I recently purchased @unclebobmartin‘s awesome book: Clean Code. What a book! I’m going to echo a sentiment that often ripples through the Twittersphere: If you are a programmer and you haven’t read Clean Code you are doing your fellow programmers (and yourself) a great disservice. Seriously.

For fun I decided to dig up the worst code I have ever written – quite a challenge considering how much terrible code I have produced in my life! Have a look at this beauty:

Stupid names, useless comments, multiple levels of abstraction, poor error handling, super deep nesting, etc etc etc. It pretty much breaks every rule in the book. But the best bit has to be this:

$rows_to_populate[$foreign_table][$foreign_id][$module_name][$db_row->id][] = $field_name;

Yes, that’s right, a five dimensional array!

Posted in Banter, Code, Inspiration | 4 Comments
  • Nikos

    Nice one mate, I've found that I can access that book for free on safari books lol

    cheers mate.

  • http://shaun.boyblack.co.za/blog/ shaun

    But there's nothing like a hard-copy. And this is one you want to own :]

  • raul

    hey Shaun!
    another great book is: Refactoring: Improving the Design of Existing Code
    if you haven't read, you most!!! it's really really great!

  • http://www.kensodev.com Avi Tzurel

    I recently purchased the new Kindle, this is definitely one of the first books I am going to read through the kindle.

    I watched many bob's videos and keynotes recently and I do agree with almost anything he has to say, looking forward to reading the book.