Test Driven Development Part 2
-
Upload
gamal-shaban -
Category
Education
-
view
100 -
download
3
description
Transcript of Test Driven Development Part 2
Test Driven Test Driven DevelopmentDevelopment
Part 2Gamal Shaaban Gamal Shaaban International CentersOrange Labs CairoMobile Applications & Software Development
2 Orange restricted
3 Orange restricted
Session-2Session-2
3
• The Three Rules Of TDD• Legacy Code & Refactoring• Code Smells• Coupling And Cohesion• Continues Integration
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 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 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 Orange restricted
Smells To Be Smells 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 Orange restricted
COUPLING AND COUPLING 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 Orange restricted9
Degree of dependence among components
No dependencies Loosely coupled-some dependencies
Highly coupled-many dependencies
10 Orange restricted
11 Orange restricted
CONTINUES INTEGRATION
12 Orange restricted
• Teams integrate their work multiple timesper day.
• Each integration is verified by an automated build
• Significantly reduces integration problems
• Develop cohesive software more rapidly
Source: Martin Fowler
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 Orange restrictedOrange presentation
Questions?
thanks