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

TDD Overview. Efficient Bug fixing

Vlad
February 12, 2021

TDD Overview. Efficient Bug fixing

Vlad

February 12, 2021
Tweet

More Decks by Vlad

Other Decks in Technology

Transcript

  1. Kent Beck “Rather than apply minutes of suspect reasoning, we

    can just ask the computer by making the change and running the tests.” Test Driven Development: By Example
  2. Laws of TDD 1. You can’t write any production code

    until you have fi rst written a failing unit test. 2. You can’t write more of a unit test than is su ffi cient to fail, and not compiling is failing. 3. You can’t write more production code than is su ff i cient to pass the currently failing unit test.
  3. TDD Advantages • design before you code • documentation for

    design • proof that code implements design • encouraging design of testable code
  4. TDD Caveats • some things are too hard to test

    • some tests are too trivial • over-testing is possible • test cycle should take little time
  5. Kent Beck “I'm not a great programmer; I'm just a

    good programmer with great habits.”
  6. TDD Overview Overview TDD is a process When the same

    thing gets repeated over and over It may look as just a waste of time And we could have written code faster if we didn’t write tests!
  7. Why should I spend time on washing my hands!? I

    would have saved more people if I didn’t! TDD Overview Overview
  8. TDD Overview Overview Process No Process Surgery Cutting People Open

    Architecture Putting bricks Software Engineering Programming
  9. Fail fast • code style • test coverage • CI

    • code quality tools • knowledge sharing Efficient bug fixing
  10. Bram Cohen “The trick is to fix the problem you

    have, rather than the problem you want.”
  11. • Don’t panic • Reproduce the bug • Understand the

    root cause • understand the expected behavior • fi nd misbehaving place in the code • look around for similar patterns Bug Analysis
  12. • implement the correction • test the correction • clean

    the code • test the correction again Correction of the bug
  13. Richard Pattis “When debugging, novices insert corrective code; experts remove

    defective code.” Senior lecturer at University of California, Irvine
  14. Q&A