Summary of 'Clean Code' by Robert C. Martin GitHub
Summary of 'Clean Code' by Robert C. Martin GitHub
Martin · GitHub
wojteklu / clean_code.md
Last active 3 hours ago
Star
Code
Revisions
2
Stars
3,310
Forks
696
clean_code.md
Code is clean if it can be understood easily – by everyone on the team. Clean code can be
read and enhanced by a developer other than its original author. With understandability
comes readability, changeability, extensibility and maintainability.
General rules
Design rules
https://gist.github.com/wojteklu/73c6914cc446146b8b533c0988cf8d29 1/17
12/24/21, 2:58 AM Summary of 'Clean code' by Robert C. Martin · GitHub
Understandability tips
1. Be consistent. If you do something a certain way, do all similar things in the same way.
2. Use explanatory variables.
3. Encapsulate boundary conditions. Boundary conditions are hard to keep track of. Put
the processing for them in one place.
4. Prefer dedicated value objects to primitive type.
5. Avoid logical dependency. Don't write methods which works correctly depending on
something else in the same class.
6. Avoid negative conditionals.
Names rules
Functions rules
1. Small.
2. Do one thing.
3. Use descriptive names.
4. Prefer fewer arguments.
5. Have no side effects.
6. Don't use flag arguments. Split method into several independent methods that can be
called from the client without the flag.
Comments rules
https://gist.github.com/wojteklu/73c6914cc446146b8b533c0988cf8d29 2/17
12/24/21, 2:58 AM Summary of 'Clean code' by Robert C. Martin · GitHub
Tests
4. Independent.
5. Repeatable.
Code smells
abelosorio
commented on Jul 23, 2018
Great job! I've read Clean Code and this summary is very helpful and a quick reference do-not-forget list.
👍
hopeogbons
commented on Sep 7, 2018
tbrunel
commented on Oct 7, 2018
https://gist.github.com/wojteklu/73c6914cc446146b8b533c0988cf8d29 4/17