41
Agile versus Formal Methods: Survival of the Fittest? Paul Boca

Formal Versus Agile: Survival of the Fittest? (Paul Boca)

  • Upload
    adacore

  • View
    4.128

  • Download
    5

Embed Size (px)

DESCRIPTION

The potential for combining agile and formal methods holds promise. Although it might not always be an easy partnership, it will succeed if it can foster a fruitful interchange of expertise between the two communities. In this talk I explain how formal methods can complement agile practices and vice versa. There are no pre-requisites for this talk, except an open mind and a desire to make software development more reliable. Leave any pre-conceptions at home, and be prepared for myths to be dispelled.

Citation preview

Page 1: Formal Versus Agile: Survival of the Fittest? (Paul Boca)

Agile versus Formal Methods: Survival of the Fittest?

Paul Boca

Page 2: Formal Versus Agile: Survival of the Fittest? (Paul Boca)

Collaborators

• Sue Black

• Mike Hinchey

• Jonathan Bowen

• Jason Gorman

(Scrum mistress)

(Formal Methodist)

(Zzzzzzzzzzz)

Page 3: Formal Versus Agile: Survival of the Fittest? (Paul Boca)

About Me

• PhD in program transformation (categorical stuff) • Hardware Compilation R&D (industry light)• High-level synthesis (start up)• Was R&D manager at UK static analysis vendor• Currently Quality Engineering Manager (SME)• Formal Methods enthusiast• Organizer of formal methods seminars

Page 4: Formal Versus Agile: Survival of the Fittest? (Paul Boca)

Outline

• Agile background• Formal Methods background• Co-existence of Formal Methods and Agile• The Cost of Agile• Summary

But first...

Page 5: Formal Versus Agile: Survival of the Fittest? (Paul Boca)

Quiz #1

• First Prize: Toyota Prius• Second Prize: Sony PlayStation 3• Runner up: Toyota Prius and PlayStation 3

Page 6: Formal Versus Agile: Survival of the Fittest? (Paul Boca)

Quiz #1

• 63,000 ?

• 2,000+ ?

• 700 ?

• 280210 ?

The number of bugs in Windows 2000

The number of pages of Z specifications in a certain air-traffic control system

Number of lines of code written per month by an agile developer

Sony PlayStation 3 bug revealed!

What do each of the numbers below correspond to

Page 7: Formal Versus Agile: Survival of the Fittest? (Paul Boca)

Agile Manifesto

• Individuals and interactions over processes and tools

• Working software over comprehensive documentation

• Customer collaboration over contract negotiation

• Responding to change over following a plan

http://agilemanifesto.org/

Page 8: Formal Versus Agile: Survival of the Fittest? (Paul Boca)

Approaches + Techniques

• Approaches– Extreme Programming– Scrum– DSDM

• Techniques– Pairwise Programming– Test Driven Development

Page 9: Formal Versus Agile: Survival of the Fittest? (Paul Boca)

Quiz #2

Agile is about producing software quickly

Agile is about being responsive to change

Page 10: Formal Versus Agile: Survival of the Fittest? (Paul Boca)

Some Agile Success Stories

Page 11: Formal Versus Agile: Survival of the Fittest? (Paul Boca)

But Agile is not perfect

• Lacks comprehensive documentation

• Writing tests upfront is great, but it’s not possible to test everything

• Rapidly changing requirements can be hard to trace.

• Refactoring code can introduce defects

We’ll return to these later...

Page 12: Formal Versus Agile: Survival of the Fittest? (Paul Boca)

Formal Methods

The application of a fairly broad variety of theoretical computer science fundamentals, in particular logic calculi, formal languages, automata theory, and program semantics, but also type systems and algebraic data types to problems in software and hardware specification and verification

http://en.wikipedia.org/wiki/Formal_methods

Page 13: Formal Versus Agile: Survival of the Fittest? (Paul Boca)

Formal Methods Timeline

Z1977

B1986

CSP1978

Circus2000

DbC1986

1970 1980 1990 2000 2010

X machines1974

VDM70s

Alloy1997

FM + Agile2003

not complete but sound

Page 14: Formal Versus Agile: Survival of the Fittest? (Paul Boca)

Formal Methods Success Stories

Page 15: Formal Versus Agile: Survival of the Fittest? (Paul Boca)
Page 16: Formal Versus Agile: Survival of the Fittest? (Paul Boca)

Formal Methods Success Stories

Page 17: Formal Versus Agile: Survival of the Fittest? (Paul Boca)

Quiz #3• Agile will phase out Formal Methods

• Formal Methods will phase out Agile

• Formal Methods and Agile can coexist

What’s more, Agile and Formal Methods need one another

Page 18: Formal Versus Agile: Survival of the Fittest? (Paul Boca)

Agile is not perfect

• Lacks comprehensive documentation

• Writing tests upfront is great, but it’s not possible to test everything

• Rapidly changing requirements can be hard to trace.

• Refactoring code can introduce defectsIt's like déjà vu all over againYogi Berra

Page 19: Formal Versus Agile: Survival of the Fittest? (Paul Boca)

Agile is not perfect

• Lacks comprehensive documentation

• Writing tests upfront is great, but it’s not possible to test everything

• Rapidly changing requirements can be hard to trace.

• Refactoring code can introduce defects

Page 20: Formal Versus Agile: Survival of the Fittest? (Paul Boca)

Why we need documentation

• Code bases need to be maintained and extended

• Some systems will be in operation for decades• Knowledge transfer to prepare for personnel

leaving– Pairwise programming = Knowledge in silos

Page 21: Formal Versus Agile: Survival of the Fittest? (Paul Boca)

Design by Contract to the rescue

• Preconditions and postconditions provide information on the intent of a function

• Generating loop invariants can help with retrospective documentation

• Contracts can be checked (semi-)automatically

Page 22: Formal Versus Agile: Survival of the Fittest? (Paul Boca)

Agile is not perfect

• Lacks comprehensive documentation

• Writing tests upfront is great, but it’s not possible to test everything

• Rapidly changing requirements can be hard to trace.

• Refactoring code can introduce defects

Page 23: Formal Versus Agile: Survival of the Fittest? (Paul Boca)

To test or not to test?

• Writing tests is definitely a good thing• When is enough enough? • Can only test the finite, and you can’t test

everything• Testing sequential programs is hard enough,

so what happens when parallelism is introduced?

• What about safety critical applications?

Page 24: Formal Versus Agile: Survival of the Fittest? (Paul Boca)

Formal Methods to the Resue

• Automated generation of test cases (e.g. Perl, Python, Functional Programming languages)

• Use static analysers (e.g. Coverity)– Finds issues in code, but can’t find everything– Complements dynamic testing

• Use model checkers (e.g. FDR)• Mutation testing

– Modify the code base introducing “mutants”– See whether the test suite “kills” the mutant– Helps to identify gaps in test suites

Page 25: Formal Versus Agile: Survival of the Fittest? (Paul Boca)

Agile is not perfect

• Lacks comprehensive documentation

• Writing tests upfront is great, but it’s not possible to test everything

• Rapidly changing requirements can be hard to trace

• Refactoring code can introduce defects

Page 26: Formal Versus Agile: Survival of the Fittest? (Paul Boca)

Agile is not perfect

• Lacks comprehensive documentation

• Writing tests upfront is great, but it’s not possible to test everything

• Rapidly changing requirements can be hard to trace

• Refactoring code can introduce defects

Page 27: Formal Versus Agile: Survival of the Fittest? (Paul Boca)

Refactoring Code

• Refactor to– Remove code smells– Beautify code

• IDEs can carry out certain refactoring steps automatically.

• Refactoring to change underlying algorithms is a manual process – needs a “Eureka”

• Manual refactoring is error prone

Page 28: Formal Versus Agile: Survival of the Fittest? (Paul Boca)

Refactoring = program transformation

• Correctness preserving transformations are present under the hood of refactoring systems

• New transformations can be added

• Proved sound

• Completeness issues

• Decidability issues

Page 29: Formal Versus Agile: Survival of the Fittest? (Paul Boca)

Avoiding Continuous Disintegration!

• Continuous Integration– Frequent checkins to source control system– Build frequently (triggered after commit)– Run tests– Fix defects immediately

Avoid the wrath of Agnes!!

Page 30: Formal Versus Agile: Survival of the Fittest? (Paul Boca)

Continuous Integration (CI)

Subversion server

build server

test server

Feedbackmechanism

commit

commit

commit

check

Model checker

TheoremProver

Analysis tools

Page 31: Formal Versus Agile: Survival of the Fittest? (Paul Boca)

Enabling CI+FM

• Faster tools• Harness multi core architectures• Deploy machines on demand in the cloud

– No need to use physical machines– Provision servers in the cloud to meet demand– Cost effective solution

Page 32: Formal Versus Agile: Survival of the Fittest? (Paul Boca)

The Cost of Agile

Time Time

Eff

ort

Eff

ort

Formal development XP development

Page 33: Formal Versus Agile: Survival of the Fittest? (Paul Boca)

The Cost of Agile

Time Time

Eff

ort

Eff

ort

Formal development Scrum development

Page 34: Formal Versus Agile: Survival of the Fittest? (Paul Boca)

The Cost of Agile

Time Time

Eff

ort

Eff

ort

Formal development DSDM

Page 35: Formal Versus Agile: Survival of the Fittest? (Paul Boca)

Agile and FM: survey

• We’re putting together a survey to gain further insight into how formal methods and agile can work together

• Areas of interest include:– Suitability of FMs Suitable Agile approaches– Application areas Success Stories– Demographics Reasons for Failure– Team sizes Team skills– Tools used Lessons learned– Defect rates Maintainability of code

Page 36: Formal Versus Agile: Survival of the Fittest? (Paul Boca)

Summary

• Agile has drawbacks, but these can be overcome with formal methods

• Formal methods opens up areas for agile, e.g. Safety Critical Systems

• Continuous Integration can be supplemented with formal methods, harnessing cloud computing

• Dispelled myths about the costs of Agile and Formal Methods

• Surveying the landscape: formal methods and agile usage in industry

Page 37: Formal Versus Agile: Survival of the Fittest? (Paul Boca)

Take Away Messages

Formal Methods can add value in the agile domain, acting as a sanity check and safety net

Formal methods provides reliability, assurance and good documentation, whilst agile provides flexibility, customer satisfaction and tangible progress

Page 38: Formal Versus Agile: Survival of the Fittest? (Paul Boca)

Agile and FM: survey

• If you would like to participate in the survey, please email me at [email protected]

• I look forward to hearing from you

• Thank you in advance.

Page 39: Formal Versus Agile: Survival of the Fittest? (Paul Boca)

FM + AM 2010

• 17 September, Pisa, Italy

• One of the workshops at SEFM 2010:– http://www.sefm2010.isti.cnr.it/

• See http://fm-am-2010.tripod.com/index.html for further details of the workshop

• SUBMIT SUBMIT SUBMIT SUBMIT SUBMIT SUBMIT (even though you’ll be reducing the chances of my paper being accepted!)

Page 40: Formal Versus Agile: Survival of the Fittest? (Paul Boca)

<shameless plug/>

20% reduction for delegates.

If you are interested, please pick upa flyer.

All royalties ploughed back into seminarseries

Page 41: Formal Versus Agile: Survival of the Fittest? (Paul Boca)

AGILE

FM

The perfect partnership