Transcript psp-0102

Chapter 12
Defects
In the chapter
 Concept of Defects
 Defects and software quality
 What is Defect?
 Defects versus Bugs
 Defect types
 Recording defects and counting
defects
 The Defect Recording Log
 The updated PSP process
山东大学计算机学院
2
Software quality
 Must be in terms that are meaningful
to the product’s users.
 Meet users’ needs;
 Reliably and consistently doing the
user’s job.
 It’s essential to have clear and exact
requirements. So the development,
clarification, and refinements of
requirements is a major subject
however it’s beyond the scope of this
class.
山东大学计算机学院
3
Hierarchy of Needs
 Software performs its required




tasks
Product meets its performance
requirements
Software is usable
Development is economical and
timely
Product is dependable and reliable
山东大学计算机学院
4
Defects & Software
quality
 Defects are the primary measure
of quality in PSP.
 Finding and fixing defects will do
great help to improving software
quality.
 Finding and fixing defects is
necessary but not sufficient to
assure software quality.
山东大学计算机学院
5
Top 10 lists about Defects
and quality





Finding and fixing a software problem after
delivery is often 100 times more expensive
than finding and fixing it during the
requirements and design phase.
About 40-50% of the effort on current
software projects is spent on avoidable
rework.
About 80% of the avoidable rework comes
from 20% of the defects.
About 80% of the defects come from 20%
of the modules and about half the modules
are defect free.
About 90% of the downtime comes from at
most 10% of the defects.
山东大学计算机学院
6
Top 10 lists about Defects
and quality
 Peer reviews catch 60% of the defects.
 Perspective-based reviews catch 35%
more defects than non-directed reviews.
 Disciplined personal practices can reduce
defect introduction rates by up to 75%.
 All other things being equal, it costs 50%
more per source instruction to develop
high-dependability software products than
to develop low-dependability software
products. However, the investment is more
than worth it if significant operations and
maintenance costs are involved.
 About 40-50% of user programs enter use
with nontrivial defects.
山东大学计算机学院
7
Some Fix Time Data
Some typical fix time ratios
IBM rules of thumb - coding: 1.5; testing:
60; usage: 100
Boehm - design: 1; development test: 15 to
40; acceptance test: 30 to 70; operation: 40
to 1000
Remus - design: 1, code: 20, test: 82
Ackerman - test: 2 - 10 times inspection
time
Russell - inspection: 1, test: 2 to 4, use: 33
PSP research - unit test takes 12 times
longer than code review to find and fix
defects, also the cost!
山东大学计算机学院
8
Related concepts
about Defects





Defect:
 something wrong with a program, such as a
syntax error, a misspelling, or an incorrect
program statement.
Defect injection:
 Defects introduced by engineers making errors.
 All defects, in fact, result from human errors.
Defect Prevention
 Finding defects is expensive so it is better to
avoid them in the first place
Defect Removal
The improvement of defect finding and fixing process
 Understanding the defects you have injected,
identify the mistakes that caused them, and learn
how to avoid repeating the same mistakes in the
future.
山东大学计算机学院
9
Software Bugs
 Latent bugs must
 be operationally insignificant
 not be destructive(破坏性的)
 not be observed often
 Bugs are not important to the
customer if they do not
 affect operations
 cause inconvenience
 cost time or money
 cause loss of confidence in
software results
山东大学计算机学院
10
Defects versus Bugs
 ‘Bugs’ trivializes a critical problem
and fosters a wrong attitude.
 ‘Bugs’ versus ‘Time bomb’
 Defects are more like time bomb
than bugs
 Trivial mistakes can have
unforeseeable consequence.
 For example, buffer overflow
 Defects is a general concept than
bugs
山东大学计算机学院
11
No Defects or Bugs!
 The software engineer who writes
a program is best able to find an
d fix its defects.
 They take personal responsibility
for the quality of the programs
they produce.
 Learn to write a defect-free
program is an enormous
challenge for a software engineer
and it takes data, effective
technique,and skill.
山东大学计算机学院
12
Class exercise
 Write a program to input the grades
(Math, Program, Data structure,
Algorithm Design, English) of a class
and calculate the mean grades of
each course.
 写一个函数计算当参数为n(n很大)时的
值 1-2+3-4+5-6+7......+n
 Use any language, 10 minutes.
 Find the defects be injected
 List the defects you often injected in
your programming process
山东大学计算机学院
13
Answer 1
 long fn(long n)
{
long temp=0;
int i,flag=1;
if(n<=0)
{
printf("error: n must > 0);
exit(1);
}
for(i=1;i<=n;i++)
{
temp=temp+flag*i;
flag=(-1)*flag;
}
return temp;
}
山东大学计算机学院
14
Answer 2
 long fn(long n)
{
}
if(n<=0)
{
printf("error: n must > 0);
exit(1);
}
if(0==n%2)
return (n/2)*(-1);
else
return (n/2)*(-1)+n;
山东大学计算机学院
15
Defect types
Type No. Type name
Description
10
documentation
Comments, messages
20
Syntax
30
Build, Package
Spelling, punctuation, typos(打字), instruction
formats
Change management, Library, version control
40
Assignment
Declaration, duplicate, names, scope, limits
50
Interface
60
Checking
Procedure calls and references, I/O, user
formats
Error messages, inadequate checks
70
Data
Structure, content
80
Function
Logic, Pointer, loops, recursion, computation,
function defects
90
system
Configuration, timing, memory
100
Environment
Design, compile, test, other support system
problem
山东大学计算机学院
16
Understanding
defects
 1.gather defect data
 Keep a record of every defect you find
 Record enough information on each
defect
 Analyze these data to see what defect
types caused the most problem
 Devise ways to find and correct defects
 2.understand the defects,avoid them
 3.figure out how to find,fix,prevent
山东大学计算机学院
17
The Defect Recording Log
Date Number Type Inject Remove Fix Time Fix Defect
—— —— ——— ——— ———— ———— —————
Description
—————————————————————————
—————————————————————————
—————————————————————————
 Help to gather defect data.
 Describe each defect in enough detail
so you can later understand it.
 Analyze the data to see where you
injected and removed defect,and which
types caused the most trouble.
山东大学计算机学院
18
How to complete the
log?-1




1.When starting to develop a program
2.When you first encounter a defect
3.Use a separate line for each found
4.Enter the date the defect was found
Date Number Type Inject Remove Fix Time Fix Defect
10/28 —— ——— ——— ———— ———— —————
 5.After fixing the defect, enter the defect
type
Date Number Type Inject Remove Fix Time Fix Defect
10/28 —— —20— ——— ———— ———— —————
山东大学计算机学院
19
How to complete the
log?-2
 6.Enter the phase of the process when you
injected the defect
Date Number Type Inject Remove Fix Time Fix Defect
10/28 —— —20— code ———— ———— —————
 7.Enter the process phase when you
removed the defect.
Date Number Type Inject
10/28 —— —20— code
Remove Fix Time Fix Defect
complie ———— —————
 8.For the defect fix time, estimate the time
from when you first were aware
Date Number Type Inject
10/28 —— —20— code
Remove Fix Time Fix Defect
complie —1 min— —————
山东大学计算机学院
20
How to complete the
log?-3


9.The fix defect entry
10.Write a brief description of the defect in the
description section
Date Number Type Inject
10/28 —— —20— code
Remove
complie
Fix Time Fix Defect
—1 min— —————
Description
——missing;————————————————————
山东大学计算机学院
21
Counting Defects
 Defect number
 Defect type
 When to count defect
 Start counting defects whenever you
complete a phase for a product or part of
a product.
 So, after the design phase,you could count
all design defects.
 In this class, we only count the defect
in compiling and testing phase.
山东大学计算机学院
22
Why using the Defect
Recording Log
 To improve your programming
 To reduce the number of defects in
your program
 To save time
 The longer defects stay in a program,
the more time they take to find and the
harder they are to fix.
 Remove the defects as soon as possible
after you inject them
 To save money
 To do your job responsibly
山东大学计算机学院
23
Updated PSP
process
 Updated PSP scripts: See table 12.5 in
p150
山东大学计算机学院
24
Updated PSP
process
PSP Project Plan Summary
Student
Program
Instructor
Summary
Minutes/LOC
LOC/Hour
Defects/KLOC
Yield
A/FR
Program Size (LOC):
Total new and changed
Maximum Size
Minimum Size
Date
Program #
Language
Plan
Actual
To Date
Plan
Actual
To Date
山东大学计算机学院
25
Updated PSP
process
Time in Phas e (min.)
Planning
Design
Code
Code review
Compile
Test
Postmortem
Total
Maximum Time
Minimum Time
Plan
Actual
山东大学计算机学院
To Date
To Date %
26
Updated PSP
process
De fe cts Inje cte d
Planning
Design
Code
Code review
Compile
Test
Total
De fe cts Re move d
Planning
Design
Code
Code review
Compile
Test
Total
Plan
Actual
To Date
To Date %
De f/Hour
Plan
Actual
To Date
To Date %
De f/Hour
山东大学计算机学院
27
Updated PSP
process
PSP Project Plan Summary
Student
Program
Instructor
Student x
Date
Program #
Language
Mr.liu
Summary
Minutes/LOC
LOC/Hour
Defects/KLOC
Yield
A/FR
Program Size (LOC):
Total new and changed
Maximum Size
Minimum Size
03/30/04
10
Ada
Plan
6.76
8.88
Actual
6.12
9.80
To Date
Plan
Actual
To Date
44
58
30
山东大学计算机学院
57
6.50
9.23
105
28
Updated PSP
process
Time in Phas e (min.)
Planning
Design
Code
Code review
Compile
Test
Postmortem
Total
Maximum Time
Minimum Time
Plan
13
11
130
Actual
18
43
162
To Date
33
55
308
To Date %
4.8
8.1
45.2
44
82
17
297
392
203
21
73
32
349
70
165
51
682
10.2
24.2
7.5
100.0
山东大学计算机学院
29
Updated PSP
process
De fe cts Inje cte d
Planning
Design
Code
Code review
Compile
Test
Total
De fe cts Re move d
Planning
Design
Code
Code review
Compile
Test
Total
Plan
Plan
Actual
To Date
To Date %
2
6
2
6
25.0
75.0
8
Actual
8
To Date
100.0
To Date %
6
2
8
6
2
8
75.0
25.0
100.0
山东大学计算机学院
De f/Hour
De f/Hour
30
PSP Quality Strategy part 1
 Identify PSP quality objectives, e.g.
 remove all defects before first compile
 Establish PSP process quality
measures, e.g.
 overall process yield
 LOC reviewed per hour
 Examine products reviewed
 determine their ratings on the measures
 see which behaviors impacted these
results
山东大学计算机学院
31
PSP Quality Strategy part 2
 Based on these data, identify your
most effective work practices.
 Incorporate these practices in your
process artifacts
 process scripts
 checklists
 forms
 Identify measures that predict process
quality
 use these as control variables
 set specifications for these variables
山东大学计算机学院
32
PSP Quality Strategy part 3
 Track your performance against these
specifications.
 Track your process to determine
 when and if to change these
specifications
 actions to take for further process
improvement
山东大学计算机学院
33
Summary
 Summary
 Software quality
 Software defects
 Record the software defect-Defect
Recording Log
 Defect types
 Updated PSP process
山东大学计算机学院
34
remember
 1. Software quality starts with defects.
 2. If defects are not managed, more
important quality issues cannot be
adequately addressed.
 3. The most effective way to manage
defects is with the individual software
engineer
 4. If you don’t eliminate your own
defects, they will be much more
expensive and time consuming to
remove later.
山东大学计算机学院
35
Assignment
 Use the Defect Recording Log to
record every defect find in the
program you write. Summarize the
defect data in the Project Plan
Summary for each program.
山东大学计算机学院
36