Clean Code – Summary

coryWelcome to the final part of this review of the Pluralsight course Clean Code: Writing Code for Humans by Cory House.

Cory is a Microsoft MVP in C#, founder of OutlierDeveloper.com, avid tech reader, and speaker. He believes in clean code, pragmatic development, and responsive native UIs.

Here are the links to each part in this series:

Part 1 – Writing Code For Humans

Part 2 – Clean Code Principles

Part 3 – Clean Code Naming

Part 4 – Clean Code Conditionals

Part 5 – Clean Code Functions

Part 6 – Clean Code Classes

Part 7 – Clean Code Comments

Part 8 – Clean Code Summary

In this final episode, Cory demonstrates all of the lessons that we have learned in this course.

Demo

In this module, Cory takes a dirty application and refactors it into a clean one using the principles covered earlier in this course.

It is an application for registering conference speakers and Cory registers his cleaning fish for humans course.

We see that the initial dirty code is a fairly realistic and not too exaggerated example.

Some problems with it are:

  1. Much too much indentation
  2. High cyclomatic complexity, low maintainability index and high class coupling
  3. Numerous types of useless comments
  4. Poorly named variables
  5. Variable declared to far away from their use

Cory fixes all of these problems and turns the application into something much cleaner.

Stay clean

This final module wraps up the course by examining the key takeaways.

First he discusses when, and when not to refactor. Most importantly you need adequate test coverage to protect yourself against regressions.

Next he relates the Broken Windows article to coding and the lessons that teaches us.

He recommend Code Reviews and/or Pair Programming (two best practices that I strongly agree with)

He points out Robert C. Martin’s “Boy Scout Rule”:

“Always leave the code you’re editing a little better than when you found it.”

And he ends with a summary of all these important points.

Verdict

Must Watch.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s