Image for post

File: Robert C. Martin surrounded by computers.jpg Author: Angelacleancoder

In a recent article, I wrote an article called: “40 Tips that will change your coding skills forever”, which is based on the things that have given me more value in this profession. In this new article, I am going to write about one of the books that have most inspired me: The Clean Code book, written by the God Robert C Martin, also known as ‘Uncle Bob.’

The book is one of the most important that exists for anyone who wants to be a good software developer. It has a lot of fantastic recommendations and is highly recommended for anyone who wants to improve their development skills.

Learning to use different libraries or frameworks is fine, but what is going to move you forward is learning the pillars of this profession. I think the first time I read it was in 2008 or 2009, and my way of developing software changed forever, for better. These principles will serve you forever, no matter what language you learn or what framework you will use.

I am going to select some of the ideas in it (and others that time has taught me), but if you have not read it, I strongly advise you to do so.

Let’s start.

Universal principles to follow:

  • Follow standard rules: experiments always end in disaster.
  • Avoid duplication in the code (DRY principle or Don’t Repeat Yourself ).
  • We must apply The Boy Scouts rule to our profession: Leave the campground cleaner than you found it.
  • Follow SOLID principles to write clean classes and well-organized APIs.

Names rules:

  • Use names that can be pronounced well.
  • Choose descriptive and clear names.
  • Use searchable names.
  • Make it easy to remember them.
  • Use names according to the context.
  • Use names that are consistent with each other. For example, it’s confusing to have “retrieved” and “get” as equivalent methods in distinct classes.
  • Use the same language in the names of variables, functions: English, French, etc. In my case, I prefer to use English because it’s a standard.
  • Avoid encodings and don’t append prefixes or type information.


  • Comments are difficult to maintain and don’t tell the truth about the code, so try to avoid it. They are almost always out of date.
  • The code is the best documentation.
  • Don’t be redundant.
  • Avoid unnecessary comments (most of all).
  • Use only as a clarification of code.

Functions rules:

  • They should be short and only do one thing. If your function is doing more than “one thing,” it is a perfect moment to extract to another function.
  • Avoid passing booleans. Why do you need to pass a Boolean? Do you need to do more than one thing within a function?
  • Keep the number of arguments as low as possible.
  • Avoid side effects. Declare the arguments as final(Java) if you can.
  • Functions should either answer something or do something, but not both.
  • Prefer Exceptions to return error codes and extract error handling try catch into their function.
  • Don’t return a null value. What is null? It does not provide any information.

Design rules:

  • You should declare local variables as close as you can to their usage.
  • You should declare instance variables at the top of the class.
  • Constants should be declared at the top of the class or in a Constants class by example.
  • Follow the Law of Demeter: A class should know only its direct dependencies.
  • Coding is like writing; try to express the purpose of the programmer and the code.
  • Use dependency injection (DIP).
  • If you use third-party libraries, wrap them, so if they change, only your wrapper implementation needs to change.
  • It is a good idea to separate concepts vertically.
  • Place methods in a top-down direction.

#software-engineering #software-development #solid #programing #clean-code #visual studio code

The Must-Know Clean Code Principles
14.00 GEEK