> For the complete documentation index, see [llms.txt](https://claudiu-stanciu.gitbook.io/software-craft/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://claudiu-stanciu.gitbook.io/software-craft/code-craft/clean-code.md).

# Clean code

Clean code that is easy to understand, maintain, and adapt

## How to write it

* Meaningful name for variables. Avoid Manager, Proxy, Data …
  * Use verbs for function names and nouns for classes and attributes
* Small functions. Rule of nesting levels (max 3 levels)
* Small function arguments. No more than 3, or encapsulate them into other
* Single resposability
* Tested/testable code
* Use 1 formatting style
* Comments are appreciated for complex functions (see function complexity)
* Comments should address the logic/business, not the implementation
* Don't reinvent the wheel just because you can
* Don't use a library/framework just because you want to play with it. Side projects exist for a reason
* Keep it DRY and SOLID (or shorter: keep it simple)

## How to enforce it

* Define coding guidelines
* Code reviews / pair programming
* Code analysis tooling (Sonar, linters, compiler configurations)
