All about software errors

Kevin Burke

Follow along

@derivativeburke

#gosf

kev.inburke.com/slides/errors

What we're covering today

What makes me an expert?

Methodology

Methodology (cont'd)

Stop using the word "bug"

Examples of bugs

Things that are not bugs

These are errors/defects

Terminology has implications

You have room to improve

50% of time is spent debugging, refactoring, reworking

Mills 1983, Boehm 1987, Cooper and Mullen 1993, Fishman 1996, Haley 1996

Room to improve

10x differences between pro programmers on:

Room to improve, cont'd

Productivity variation between programmers

Sackman, Erickson, Grant, "Exploratory Experimental Studies Comparing Online/Offline Programming Performance", 1968

Room to improve, cont'd

Curtis, "Substantiating Programmer Variability", 1981

Room to improve, cont'd

Demarco and Lister, "Programmer performance and the effects of the workplace", 1985

Where do errors come from?

What kinds of errors?

What kinds of errors?

  • Most errors (~85%) can be fixed in a short period of time
    Endres, "An Analysis of Errors and Their Causes in System Programs", 1975
  • Most errors are the programmer's fault
  • Other common error sources - changing requirements, communication breakdown, thin domain knowledge
  • What things are correlated with errors?

  • Unused variables (Card, Church, Agresti, 1986)
  • What things are correlated with errors?

  • High numbers of comments
  • What things are correlated with errors?

  • Complex control flow
    (McCabe, "A Complexity Measure", 1976) See: gocyclo
  • 3+ layers of nesting
    (Yourdon, "Managing the Structured Techniques: Strategies for Software Development in the 1990s", 1986)
  • How are errors distributed?

    In general, 80% of the errors come from 20% of the code.
    Also, 50% of errors from 5% of the code

    Case study at IBM: 31 of 425 classes found to be error-prone. After repair/refactoring, defects reported by customers were reduced by 90%

    Capers Jones, "Software Assessments, Benchmarks, and Best Practices," 2000

    How often do we make errors?

    Best estimates: you will find 1-25 errors per 1000 lines of code

    (McConnell, "Code Complete", 2003)

    5-8 defects/hour during coding

    (Humphrey, "Introduction to the Personal Software Process", 1997)

    How many can we expect to find?

    If you do it well: 70%

    If you do it poorly: 20%

    Effectiveness of different bug-finding tools

    Tools don't overlap

    Inspections/reviews find different errors than tests

    Using a different tool can double effectiveness

    Myers, 1979; Kouchakdjian, Green, and Basili 1989; Tripp, Struck, and Pflug 1991; Schneider, Martin, and Tsai 1992

    What the heck is an inspection?

    What the heck is an inspection?

    Michael Fagan (IBM), "Design and Code Inspections to Reduce Errors in Program Development", 1976

    Inspections crush testing on effectiveness

    Inspections crush testing

    What won't testing catch?

    If you do test:

    Review small changes

    Review small changes

    In one company, 55% of one line changes were incorrect

    After code review was implemented, 2% were incorrect

    Freedman and Weinberg, 1990

    "Never debug standing up."

    Gerald Weinberg

    Pull request length

    Example

    Requirements change

    Average change is 1-4% per month. (Jones 2000)

    Store requirements in version control so changes are visible

    Keep your own records

    Things you can measure:

    Cost of fixing defects at various stages

    Fagan 1976, Dunn 1984, Shull 2002

    Personal Error Tracking

    Spreadsheet with errors

    Thanks!

    Newest project:

    Twenty Milliseconds

    Kevin Burke

    kev.inburke.com

    kev@inburke.com

    @derivativeburke


    These slides are available at:

    kev.inburke.com/slides/errors

    /

    #