Saturday, June 14, 2014

Uncle Bob's Advice on Clean Code

Several years ago, I read Robert C. Martin's book, Clean Code: A Handbook of Agile Software Craftmanship and I was inspired to write cleaner, higher quality code.

Uncle Bob has created a video series that goes beyond the material covered in his book. Recently, in an effort to better grasp all of the SOLID principles, I started watching the video series from the beginning. The format is entertaining and the material is thought provoking.

The basis of episode 1 "Clean Code," (and for that matter, the entire series), is that code is written for humans. Code has to be maintained. After code is written, it is read over and over again during maintenance. While it may be subjective as to what clean code actually looks like, Uncle Bob makes many strong arguments about what makes code maintainable.

So far I've watched four episodes and I've been thoroughly entertained and inspired. I'm amazed at how much I have learned.  The second episode talks about code, space, class and function names. The third and forth episodes dig into functions.  Here is a short outline of episodes three and four to give you an idea of what the video contains:

After a brief astronomy lesson, Uncle Bob starts appearing in all varying places all over the world talking about functions.  A set of guidelines for writing functions is given.  For example, functions shouldn't have more than three parameters and functions shouldn't take a Boolean as a parameter. He gives solid arguments as to why that is. If the pointy haired boss threw something like that into a requirement document, you'd probably be inclined to question the sanity of his reasoning.  Thankfully, it's coming from Uncle Bob, who's time in the industry has served as a proving ground for his reasoning on clean code.

If you haven't ever read the book Clean Code, check it out.  If you have, check out the videos...They offer a deeper dive into the material in a very entertaining package.

No comments:

Post a Comment