I recently finished reading Clean Code – A Handbook of Agile Software Craftsmanship – by Robert C. Martin.
What is clean code you might ask? One of the definitions that most resonated with me is that of Grady Booch, author of Object Oriented Analysis and Design with Applications: “Clean code is simple and direct. Clean code reads like well-written prose. Clean code never obscures the designer’s intent but rather is full of crisp abstractions and straightforward lines of control.”
The main premise of the book, as stated by the author, is: “learning code is hard work. It requires more than just the knowledge of principles and patterns. You must sweat over it. You must practice it yourself, and watch yourself fail. You must watch others practice it and fail. You must see them stumble and retrace their steps. You must see them agonize over decisions and see the price they pay for making those decisions the wrong way.”
The book is made up of three sections: The first one outlines the “principles, patterns, and practices of writing clean code”. This includes topics such as naming, functions, comments, formatting etc. The second one, includes several working examples of code cleanup using the tools from the first section. The last section, includes a number of heuristics and smells that help identify the need for cleaning code. These smells are divided by area, such as environment, names, comments etc.
What sets this book apart is the applicability, practicality and breadth of the concepts discussed. The last section of the book is of particular relevance as a starting point for identifying weaknesses or deficiencies in code. These then serve as a testing ground for applying the concepts introduced in the book. What the author stresses throughout his work, is the need to continuous practice and to clean the code in an iterative manner.
A recommended read for anyone involved with the software development lifecycle regardless of experience. From a critical standpoint, the choice of some of the case study code bases was at times questionable given its abstraction. This made them hard to follow at times.