Clean Code by Uncle Bob (Robert C. Martin)
Here is the link to original Youtube Playlist
Rules of Functions
- They should be small enough so that no sub-function can be extracted from it.
- Function should take atmost 3 arguments.
- Don’t pass boolean as function arguments for conditional processing.
- Don’t pass variables to store data.
- Function should not create any side-effect (not change state of program).
- Avoid switch statements.
- Command-Query Seperation.
Comments
- Comment is a failure to express oneself through code.
- Don’t commit TODO comments in source control.
- Don’t commit commented cod in source control.
Formatting
- Average file size should be around 50 lines and max around 100 lines.
- Line should not have length greater than 150 characters.
- Variable Name Length ∝ Size of scope of variable
- Function Name Length ∝ 1/(Size of scope of function)
Tip
Pair programming is great way for knowledge sharing.
Professionalism
- Never ship shit.
- After every sprint (preferably 1 week), software must be ready for deployment (may not have features).
- Stable Productivity: Feature release rate should not slow down with time.
- Inexpensive Adaptability: Changeable Software.
- Continuous Improvement.
- Every engineer must practice Test Driven Development.
Test Driven Development
- Disciplined way of coding.
flowchart TD
Red -- just enough code to pass --> Green
Green --rename and extract functions and variables --> Refactor
Refactor -- write a failing test--> Red
style Red fill:#FAA0A0
style Green fill:lightgreen
style Refactor fill:lightblue- Evolve tests to become more specific.
- Evolve code to become more generic.
Info
Lisp is a language that never dies.