How clean is your code?


I just finished reading a wonderful book for anyone doing software development.  Clean Code: A handbook of Agile Software Craftsmanship by Robert C. Martin helps us write code that can be easily read and tells the next developer what the code does.  It also makes the code easier to enhance when it is written in the style Martin suggests.  Some people refer to Robert as “Uncle Bob” because of his older and avuncular appearance.  He is also a proponent of developers thinking of themselves as craftsman.


Since this book is about how to clean up your code he uses many code examples from major open source projects.  The focus on making code that is readily understood or has high readability is the focus to many of changes Martin emphasizes.  Many of the clean coding principles are quite basic.  For instance, the naming of variables and methods are one of the first items he discusses.  This is really important for conveying what the software is to do.  I have read code before that has names that look cryptic or difficult to decipher at best.

Boy Scout Principle

Martin discusses how software craftsman need to live by a principle similar to the Boy Scout Principle, leave the campsite cleaner than you found it.  Leaving the code cleaner than you found it is spelled out in steps that Martin details with numerous code examples.

Smart vs. Professional Developer

The distinction is made in this book between Smart and Professional developers.  We sometimes think we are showing off when we write code that is difficult to understand as we think we are smart.  We demonstrate our good coding skills in the process but also create unmaintainable code.  Professional developers focus on readable and maintainable code.  We need to understand that “clarity is king” for our code.

Here is a good slide overview of this book:

If you enjoyed this please consider sharing it and don’t forget to sign up for our newsletter!

No comments yet.

Leave a Reply

Powered by WordPress. Designed by Woo Themes