savchenko.tech / software engineering blog by Maryna Savchenko

Clean code notes

2022-12-14

cleanCode.png

It is hard to find software engineer these days that has never heard of Clean code. At the same time in many organizations code that runs on production brings bugs and pain every day.

So, what is Clean code and why it is important?

Clean code is set of principles for writing clear, understandable, and maintainable code. It is not strict rules and applying each principle needs to make sense in concrete situation.

Two main reasons to use Clean Code principles are:

There is a list of principles that I use frequently.

1. Meaningful names of variables

2. Small methods

3. Avoid flag argument

4. Command query separation

5. DRY – do not repeat yourself

6. Null, do not pass, do not return

7. Clean tests

Sources:

  1. Clean Code: A Handbook of Agile Software Craftsmanship by Robert C. Martin.
  2. The Clean Coder: A Code of Conduct for Professional Programmers by Robert C. Martin.