Test Driven Development Part 2

  • View
    91

  • Download
    3

Embed Size (px)

DESCRIPTION

The Three Rules Of TDD Legacy Code & Refactoring Code Smells Coupling And Cohesion Continues Integration THE THREE RULES OF TDD You are not allowed to write any production code unless it is to make a failing unit test pass. You are not allowed to write any more of a unit test than is sufficient to fail; and compilation failures are failures. You are not allowed to write any more production code than is sufficient to pass the one failing unit test. Refactoring is one of the most important parts of TDD, which means you need to refine the code design as you add new tests. Refactoring should be done consistently as you increment the software, adding tests and production code. Make code easier to maintain in the future Use IDE when possible to do refactoring. Refactor Without Fear. A code smell is a surface indication that usually corresponds to a deeper problem in the system. Duplicated Code Long Method Large Class Long Parameter List Divergent Change Lazy Class Speculative Generality Temporary Field Data Class Refused Bequest Comments MiddleMan Maximize internal interaction (cohesion) easier to understand easier to test Minimize external interaction (coupling) can be used independently easier to test easier to replace easier to understand

Text of Test Driven Development Part 2

  • 1. Test Driven DevelopmentTest Driven Development Part 2 Gamal ShaabanGamal Shaaban International Centers Orange Labs Cairo Mobile Applications & Software Development
  • 2. 2 Orange restricted
  • 3. 3 Orange restricted Session-2Session-2 3 The Three Rules Of TDD Legacy Code & Refactoring Code Smells Coupling And Cohesion Continues Integration
  • 4. 4 Orange restricted THE THREE RULES OF TDD 1. You are not allowed to write any production code unless it is to make a failing unit test pass. 2. You are not allowed to write any more of a unit test than is sufficient to fail; and compilation failures are failures. 3. You are not allowed to write any more production code than is sufficient to pass the one failing unit test. http://butunclebob.com/ArticleS.UncleBob.TheThreeRulesOfTdd 4
  • 5. 5 Orange restricted RefactoringRefactoring Refactoring is one of the most important parts of TDD, which means you need to refine the code design as you add new tests. Refactoring should be done consistently as you increment the software, adding tests and production code. Make code easier to maintain in the future Use IDE when possible to do refactoring. Refactor Without Fear. 5
  • 6. 6 Orange restricted Code SmellsCode Smells A code smell is a surface indication that usually corresponds to a deeper problem in the system. Martin FowlerMartin Fowler http://martinfowler.com/bliki/CodeSmell.html 6
  • 7. 7 Orange restricted Smells To BeSmells To Be RefactoredRefactored 1.Duplicated Code 2.Long Method 3.Large Class 4.Long Parameter List 5.Divergent Change 6.Lazy Class 7.Speculative Generality 8.Temporary Field 9.Data Class 10.Refused Bequest 11.Comments 12.MiddleMan
  • 8. 8 Orange restricted COUPLING ANDCOUPLING AND COHESIONCOHESION Maximize internal interaction (cohesion) easier to understand easier to test Minimize external interaction (coupling) can be used independently easier to test easier to replace easier to understand 8
  • 9. 9 Orange restricted 9 Degree of dependence among components No dependencies Loosely coupled-some dependencies Highly coupled-many dependencies
  • 10. 10 Orange restricted
  • 11. 11 Orange restricted CONTINUES INTEGRATION
  • 12. 12 Orange restricted Teams integrate their work multiple times per day. Each integration is verified by an automated build Significantly reduces integration problems Develop cohesive software more rapidly Source: Martin Fowler
  • 13. 13 Orange restricted Five Principles of Continuous Integration Environments based on stability Maintain a code repository Commit frequently and build every commit Make the build self-testing Store every build 13
  • 14. 14 Orange restrictedOrange presentation Questions?
  • 15. thanks