Clean Code - THE book

Clean Code has got to be one of the best books I have read about code (warning: affiliated link). 

It got me hooked right in the beginning with:
"Writing clean code is what you must do in order to call yourself a professional. There is no reasonable excuse for doing anything less than your best."



We all have been in projects where the code base was a mess! Damn... we all have written really lousy code. And too many times the main victims are ourselves when we return to a lousy piece of code: "Who wrote this shit? Ups... I did..." This is madness! 



But we are authors. The ratio of reading vs writing code is 10:1! We should be proud of our code.

My favorite lesson from the book is the "Boy scout rule": check-in your code a little cleaner than you found it. That's it. It could not be easier. Rename a variable. Delete some dead code. Extract a function from a large method.



The book goes into a lot of detail by talking about:
  • meaningful names
  • functions
  • comments
  • formatting
  • objects and data structure
  • error handling
  • boundaries
  • unit tests
  • classes
  • etc.

Wow! That's a lot of nuts (for all Kung Pow fans. Not a fan? Go watch the movie. I'll wait. Thank me later)

 
It has 3 chapters where the author goes through open source code and cleans it! These are a more difficult read but are well worth it. The concurrency chapters are topics that IMHO should be saved for another book.

So let's stop the spaghetti, code like professionals and clean our mess! 

No comments:

Post a Comment