XP and TDD Extreme Programming and Test Driven Development Bertrand - - PowerPoint PPT Presentation

xp and tdd
SMART_READER_LITE
LIVE PREVIEW

XP and TDD Extreme Programming and Test Driven Development Bertrand - - PowerPoint PPT Presentation

XP and TDD Extreme Programming and Test Driven Development Bertrand Meyer, Manuel Oriol Andreas Leitner Chair of Software Engineering ETH Zurich October 27, 2006 Chair of Software Engineering Outline Development Processes Overview Extreme


slide-1
SLIDE 1

Chair of Software Engineering

XP and TDD

Extreme Programming and Test Driven Development Bertrand Meyer, Manuel Oriol Andreas Leitner

Chair of Software Engineering ETH Zurich

October 27, 2006

slide-2
SLIDE 2

Chair of Software Engineering

Outline

Development Processes Overview Extreme Programming Test Driven Development

slide-3
SLIDE 3

Chair of Software Engineering

Outline

Development Processes Overview Extreme Programming Test Driven Development

slide-4
SLIDE 4

Chair of Software Engineering

Development Processes Overview

◮ Traditional Methods

◮ Waterfall model ◮ V model ◮ Spiral model ◮ Prototype model

◮ Agile Methods

◮ Extreme Programming ◮ Test Driven Development

slide-5
SLIDE 5

Chair of Software Engineering

Waterfall model

Figure from: Wikipedia

slide-6
SLIDE 6

Chair of Software Engineering

V model

slide-7
SLIDE 7

Chair of Software Engineering

Defect Cost

Relative cost to correct a defect

10 20 30 40 50 60 70 Requirements Design Code Development Testing Acceptance Testing Operation

Source: Barry W. Boehm, Software Engineering Economics, Prentice Hall, 1981

slide-8
SLIDE 8

Chair of Software Engineering

Spiral model

Figure from: Ghezzi, Jazayeri, Mandrioli, Software Engineering, 2nd edition, Prentice Hall

slide-9
SLIDE 9

Chair of Software Engineering

Project Management

◮ Programming competence varies greatly

◮ 1:10 in a single group (Sackman, Erikson, Grant)

◮ Who introduces more bugs?

◮ Experienced Developers ◮ Beginners

slide-10
SLIDE 10

Chair of Software Engineering

Outline

Development Processes Overview Extreme Programming Test Driven Development

slide-11
SLIDE 11

Chair of Software Engineering

XP: Motivation

◮ Schedule slips ◮ Project canceled ◮ Systems go sour ◮ Defect rate ◮ Doesn’t solve actual problem ◮ Business changes ◮ False feature rich ◮ Staff turnover

slide-12
SLIDE 12

Chair of Software Engineering

XP: Cost of Change

slide-13
SLIDE 13

Chair of Software Engineering

XP: Rules

◮ The planning game ◮ Small Releases ◮ Metaphor ◮ Simple Design ◮ Testing ◮ Refactoring ◮ Pair programming ◮ Collective Ownership ◮ Continuous Integration ◮ 40h-Week ◮ On-Site Customer ◮ Coding Standards

slide-14
SLIDE 14

Chair of Software Engineering

XP: Programming in the Wild

◮ Is XP like “programming in the wild”?

slide-15
SLIDE 15

Chair of Software Engineering

XP: Kinds of Testing

◮ Unit testing ◮ Integration testing ◮ System testing ◮ Acceptance testing ◮ Regression testing

slide-16
SLIDE 16

Chair of Software Engineering

XP: Unit testing 1/2

◮ Tools

◮ SUnit – Smaltalk (first one) ◮ JUnit – Java (www.junit.org) ◮ cppunit – C++ ◮ PyUnit – Python ◮ ...

slide-17
SLIDE 17

Chair of Software Engineering

Outline

Development Processes Overview Extreme Programming Test Driven Development

slide-18
SLIDE 18

Chair of Software Engineering

(from Neil McGovern)

slide-19
SLIDE 19

Chair of Software Engineering

(from Neil McGovern)

slide-20
SLIDE 20

Chair of Software Engineering

(from Neil McGovern)

slide-21
SLIDE 21

Chair of Software Engineering

TDD: Overview

◮ Evolutionary approach to development ◮ Combines

◮ Test-first development ◮ Refactoring

◮ Primarily a method of software design

◮ Not just method of testing

slide-22
SLIDE 22

Chair of Software Engineering

TDD: The Process

slide-23
SLIDE 23

Chair of Software Engineering

TDD = TFD + Refactoring

◮ Apply test-first development ◮ Refactor whenever you see fit (before next functional

modification)

◮ Kent Beck’s rule:

◮ Write new business code only when a test case fails ◮ Eliminate any duplication you find

slide-24
SLIDE 24

Chair of Software Engineering

TDD and Extreme Programming

◮ Easy to give in and skip some test cases ◮ Pair-programming can help ◮ Writing testable code helps

slide-25
SLIDE 25

Chair of Software Engineering

TDD: Consequences

◮ Incremental development ◮ Development environment must provide rapid response to

small changes

◮ Components are designed highly cohesive, loosely

coupled

◮ Developers learn to write good unit tests:

◮ Run fast ◮ Run in isolation ◮ Use data that makes test case easy to read ◮ Each test case is step towards overall goal

slide-26
SLIDE 26

Chair of Software Engineering

TDD & Documentation

◮ Programmers often do not read documentation ◮ Instead, they look for examples and play with them ◮ Good unit tests can serve as

◮ Examples ◮ Documentation

slide-27
SLIDE 27

Chair of Software Engineering

TDD: pros and cons

◮ Pros

◮ Reduce gap between decision and feedback ◮ Encourage developers to write code that is easily tested ◮ Creates a thorough test bed

◮ Drawbacks

◮ Time taken away from core development ◮ Some code is difficult to test

slide-28
SLIDE 28

Chair of Software Engineering

References

◮ Kent Beck: Agile software development: principles,

patterns, and practices. Addision Wesley, 2003

◮ Astels: Test Driven Development: A Practical Guide,

Prentice Hall, 2003

◮ Kent Beck: Extreme Programming Explained, Addision

Wesley, 2000

◮ Bertrand Meyer: Practice to perfect: the quality first model,

IEEE Computer, 30, 5, pages 102-103, 105-106, 1997

◮ Andrew Hunt: The Pragmatic Programmer: from

journeyman to master. Addision Wesley, 2000

◮ Kent Beck: Extreme Programming explained. Addision

Wesley, 2000