Episode 06 – Test Driven Development

Clean Code

Episode 06

The sixth episode talks about test driven development (TDD) and how it uses to keep code clean. It also talks about some guideline for TDD and the red, green, refactor technique to achieve it.

  • Reason for TDD
    • Fear and Code Rot
    • The Big clean up
    • Eliminating fear
    • Demonstration
      • inline function
      • repartition by create a new class for the entire function and create private variable from the variables that’s are used inside the function
      • create method where multiple instance occurs in the code.
      • create method with descriptive name and replace the section where the code maybe less descriptive
      • Conclusion: good test let you clean the code because it guard against fear of breaking it.
    • The Real World
  • How to TDD
    • Three Laws of TDD
      • Write NO production code except to pass a failing test
      • Write only enough of a test to demonstrate a failure
      • Write only enough production code to pass the test.
    • Debugging Time
      • No Debugging time because removing defect that was created only the last minutes or so
    • Design documents
      • The test are low level documentation that uses all the function and api in ways that it can be use.
    • Decoupling
      • Writing test first make the production code testable.
      • Writing test first also make the system far less couple because each test demands a decoupling of a specific section of the code
    • Courage to change
    • Trust
  • Red Green Refactor
    • follows the three rules of TDD
    • check for misplace responsibility (method pin is calculating the score, but the score method should be doing that job)
  • Answering the Objections
    • TDD is an iterative process and refactoring is the improvement of the code.
    • The test and the production code are testing each other in TDD.
    • For legacy code, write tests for a small section that does not affect the whole module and then refactor the code to make it more decouple and easier for writing additional test.
  • Discipline and Professionalism
    • Double Entry Bookeeping
    • QA should find nothing
    • 100% code coverage
    • Doctor wash your hand
  • Other References
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s