Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Improving Design Through Test Driven Development (TDD)


Published on

Improving Design Through TDD was presented at the DC Agile Engineering Conference on 12/7/2012 by Sam Brown (@SamuelBrownIV) and Mike McGarr (@jmichaelmcgarr).

Published in: Technology
  • Login to see the comments

Improving Design Through Test Driven Development (TDD)

  1. 1. Improving Design throughTest Driven Development (TDD) Sam Brown @SamuelBrownIV Mike McGarr @jmichaelmcgarr DC Agile Engineering Conference #DCAEC12
  2. 2. About Us Sam Brown Mike McGarr• 11 years software engineer • 11 years software engineer• DevOps Evangelist at Excella • Directory of DevOps for• Certified Scrum Master Blackboard Learn• Puppet Certified • Founder of the DC Professional Continuous Integration, Delivery and Deployment Meetup
  3. 3. Types of Tests
  4. 4. Unit TestsFastIndependentRepeatableSelf-VerifyingTimely
  5. 5. Test Driven Development Golden Rule of TDD: Never write production code without a failing test
  6. 6. TDD improves quality and design
  7. 7. Coupling
  8. 8. Cohesion
  9. 9. Object Oriented Design Principles Single responsibility principle (SRP) Open/close principle (OCP) Liskov substitution principle (LSP) Interface segregation principle (ISP) Dependency inversion principle (DSP)
  10. 10. Bowling Game• Ten Frames per game• 2 rolls per frame • Unless a strike is rolled• Properly calculate Spares• Properly calculate Strikes
  11. 11. DesignDecision
  12. 12. DesignDecision
  13. 13. Notice the duplication in the tests. Let’s refactor this.
  14. 14. More duplication
  15. 15. Design Problem – roll() calculates scoreLet’s Refactor!
  16. 16. We need a concept of frames.
  17. 17. Ugly Code
  18. 18. Design Decisions• Design client interface• Refactor • Change design without changing behavior• Defer to last responsible moment • Avoids “Big Upfront Design”
  19. 19. New Requirements!
  20. 20. Requested ChangesThe Bowling game is becoming service oriented!• New Requirement: – Post rolls in real-time
  21. 21. Collaborator
  22. 22. Test Doubles• Dummy• Stubs• Fake• Mocks• Spy
  23. 23. NullPointerException! We need a default implementation.
  24. 24. Contact UsSam Cute Baby Arrival@SamuelBrownIV 12/20/2012 • J. Michael McGarr • • @jmichaelmcgarr • • DC CI Meetup -