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!