Post on 15-Apr-2018
Chair ofSoftware Engineering
XP and TDDExtreme Programming and Test Driven Development
Bertrand Meyer, Manuel OriolAndreas Leitner
Chair of Software EngineeringETH Zurich
October 27, 2006
Chair ofSoftware Engineering
Outline
Development Processes Overview
Extreme Programming
Test Driven Development
Chair ofSoftware Engineering
Outline
Development Processes Overview
Extreme Programming
Test Driven Development
Chair ofSoftware Engineering
Development Processes Overview
I Traditional MethodsI Waterfall modelI V modelI Spiral modelI Prototype model
I Agile MethodsI Extreme ProgrammingI Test Driven Development
Chair ofSoftware Engineering
Waterfall model
Figure from: Wikipedia
Chair ofSoftware Engineering
V model
Chair ofSoftware Engineering
Defect Cost
Relative cost to correct a defect
0
10
20
30
40
50
60
70
Requirements Design Code DevelopmentTesting
AcceptanceTesting
Operation
Source: Barry W. Boehm, Software Engineering Economics, Prentice Hall, 1981
Chair ofSoftware Engineering
Spiral model
Figure from: Ghezzi, Jazayeri, Mandrioli, Software Engineering, 2nd edition, Prentice Hall
Chair ofSoftware Engineering
Project Management
I Programming competence varies greatlyI 1:10 in a single group (Sackman, Erikson, Grant)
I Who introduces more bugs?I Experienced DevelopersI Beginners
Chair ofSoftware Engineering
Outline
Development Processes Overview
Extreme Programming
Test Driven Development
Chair ofSoftware Engineering
XP: Motivation
I Schedule slipsI Project canceledI Systems go sourI Defect rateI Doesn’t solve actual problemI Business changesI False feature richI Staff turnover
Chair ofSoftware Engineering
XP: Cost of Change
Chair ofSoftware Engineering
XP: Rules
I The planning gameI Small ReleasesI MetaphorI Simple DesignI TestingI RefactoringI Pair programmingI Collective OwnershipI Continuous IntegrationI 40h-WeekI On-Site CustomerI Coding Standards
Chair ofSoftware Engineering
XP: Programming in the Wild
I Is XP like “programming in the wild”?
Chair ofSoftware Engineering
XP: Kinds of Testing
I Unit testingI Integration testingI System testingI Acceptance testingI Regression testing
Chair ofSoftware Engineering
XP: Unit testing 1/2
I ToolsI SUnit – Smaltalk (first one)I JUnit – Java (www.junit.org)I cppunit – C++I PyUnit – PythonI ...
Chair ofSoftware Engineering
Outline
Development Processes Overview
Extreme Programming
Test Driven Development
Chair ofSoftware Engineering
(fromNeil McGovern)
Chair ofSoftware Engineering
(fromNeil McGovern)
Chair ofSoftware Engineering
(fromNeil McGovern)
Chair ofSoftware Engineering
TDD: Overview
I Evolutionary approach to developmentI Combines
I Test-first developmentI Refactoring
I Primarily a method of software designI Not just method of testing
Chair ofSoftware Engineering
TDD: The Process
Chair ofSoftware Engineering
TDD = TFD + Refactoring
I Apply test-first developmentI Refactor whenever you see fit (before next functional
modification)I Kent Beck’s rule:
I Write new business code only when a test case failsI Eliminate any duplication you find
Chair ofSoftware Engineering
TDD and Extreme Programming
I Easy to give in and skip some test casesI Pair-programming can helpI Writing testable code helps
Chair ofSoftware Engineering
TDD: Consequences
I Incremental developmentI Development environment must provide rapid response to
small changesI Components are designed highly cohesive, loosely
coupledI Developers learn to write good unit tests:
I Run fastI Run in isolationI Use data that makes test case easy to readI Each test case is step towards overall goal
Chair ofSoftware Engineering
TDD & Documentation
I Programmers often do not read documentationI Instead, they look for examples and play with themI Good unit tests can serve as
I ExamplesI Documentation
Chair ofSoftware Engineering
TDD: pros and cons
I ProsI Reduce gap between decision and feedbackI Encourage developers to write code that is easily testedI Creates a thorough test bed
I DrawbacksI Time taken away from core developmentI Some code is difficult to test
Chair ofSoftware Engineering
References
I Kent Beck: Agile software development: principles,patterns, and practices. Addision Wesley, 2003
I Astels: Test Driven Development: A Practical Guide,Prentice Hall, 2003
I Kent Beck: Extreme Programming Explained, AddisionWesley, 2000
I Bertrand Meyer: Practice to perfect: the quality first model,IEEE Computer, 30, 5, pages 102-103, 105-106, 1997
I Andrew Hunt: The Pragmatic Programmer: fromjourneyman to master. Addision Wesley, 2000
I Kent Beck: Extreme Programming explained. AddisionWesley, 2000