Upgrade to Pro — share decks privately, control downloads, hide ads and more …

clean code: four rules of simple design

clean code: four rules of simple design

the slide deck used for an internal design/programming workshop for developers.

Avinash Chugh

May 31, 2014
Tweet

More Decks by Avinash Chugh

Other Decks in Programming

Transcript

  1. 5 RULE 1 - ALL TESTS MUST PASS ! Program

    correctness Feedback loops Confidence levels Ease of evolution Working specification ! !
  2. THE PYRAMID OF TESTING 6 Unit tests Integration tests Functional

    tests The higher we go ! ▫︎fewer numbers ▫︎slower feedback ▫︎higher cost
  3. 7 ! ! Duplication is waste Eliminate waste Say it

    once, Say it well Less code means fewer bugs ! ! RULE 2 - ONCE AND ONLY ONCE (OOO)
  4. RULE 3 - EXPRESS YOUR INTENT 8 ! All in

    the name Staying small Role playing Tell, don’t ask The world as we see it
  5. 9 ! ! ! Would you really need this? (minimal

    methods, classes, & modules) RULE 4 - NO SUPERFLUOUS PARTS
  6. 12 YOU AIN’T GONNA NEED IT! ! ! The world

    is changing. fast. Build for what you know. Over time, you’ll know more. What if I could look ahead?
  7. LISTEN TO THE CODE 13 ! ! 1. Write a

    test, make it pass, refactor 2. Refactor to the point of simplicity 3. Listen to the code
  8. SUMMARY 15 ! ! 1. All tests must pass 2.

    Don’t repeat yourself 3. Express your intent 4. Stay lean
  9. REFERENCES 17 ! ! 1. http://c2.com/cgi/wiki?XpSimplicityRules 2. http://www.amazon.com/Clean-Code-Handbook-Software-Craftsmanship/dp/ 0132350882 3.

    http://math.ucr.edu/home/baez/physics/General/occam.html 4. http://blog.thecodewhisperer.com/2013/12/07/putting-an-age-old-battle-to-rest/