Application Development Practices: Analyzing and Fixing Defects
Application Development Practices: Analyzing and Fixing Defects
Development Practices
© 2013
Analyzing and Fixing Defects
Scalability Efficiency
Extensibility Interoperability
Installability Operational availability
Maintainability* Flexibility*
Portability* Reliability
Reusability* Robustness
Readability* Safety
Testability* Security
* Internal software
Accessability characteristic
© 2013, Nguyen Tran Hoang Linh 3
What is a Defect?
Code defects are programming errors
Sources of defects:
• Poor understanding of requirements
• Poor design
• Poor coding practices
• Limited or no unit and integration testing
• Introduced during defect fixing
• Typos
• Others ...
60
50
40
30
20
10
0
Requirements Design Code Development Acceptance Operation
Testing Testing
(Source: Boehm, Barry W. Software
Development Phase Engineering Economics. Englewood
Cliffs, NJ: Prentice-Hall)
© 2013, Nguyen Tran Hoang Linh 5
Defects & Schedules
“[IBM] found that products with the lowest
defect counts were also the products with
the shortest schedules”
If you’re finding more than 5% of your
defects after product release:
• Vulnerable to low quality problems
• Taking more time to develop than necessary
Intentional development?
or
(Source: McConnell, Steve Code Complete. Microsoft Press, 2004. pages 537-538)
© 2013, Nguyen Tran Hoang Linh 8
Defects as Opportunities
As a developer you can:
• Learn about how you solve problems
Does your approach to finding problems work?
Do you find defects quickly?
Do you guess at where the problem is?
• Learn about how you fix defects
Do you make a complete problem diagnosis and
implement systematic corrections?
(Source: McConnell, Steve Code Complete. Microsoft Press, 2004. pages 537-538)
© 2013, Nguyen Tran Hoang Linh 9
Steps for Fixing Problems
1. Identify how to repeat the problem
• Gather data through repeatable experiments
• You may need to replicate the user’s machine
2. Form a hypothesis that accounts for the
behavior
3. Design an experiment that proves/disproves the
hypothesis
By testing the software or examining the code
Run the experiment
Repeat as needed
4. Fix the defect
5. Test the fix
(Source: McConnell, Steve Code Complete.
6. Look for similar problems Microsoft Press, 2004. pages 540-541)
(Source: McConnell, Steve Code Complete. Microsoft Press, 2004. pages 540-548)
© 2013, Nguyen Tran Hoang Linh 14
Know Your Available Tools
Scientific method
• Isolate the problem and make it repeatable
Print statements
• To display key software events and variables
Design review
• Walk through the broken code with many eyes
Don’t rush
• Time pressure can lead to rushed judgment,
incomplete diagnosis and incomplete correction
(Source: McConnell, Steve Code Complete. Microsoft Press, 2004. pages 540-548)
© 2013, Nguyen Tran Hoang Linh 17
Tips for Fixing Defects
Fix the problem, and not the symptom
• Don’t put in special case fixes. They are hard
to maintain, and probably don’t solve the
problem
From studies;
• 80% of defects are found in 20% of classes or
routines
• 50% of defects are found in 5% of classes
(Source: McConnell, Steve Code Complete. Microsoft Press, 2004. pages 517-522)
© 2013, Nguyen Tran Hoang Linh 20
Estimating Defect Fixes
Most defects are easy to fix
• ~85% can be fixed in a few hours
• ~15% can be fixed in 4 hours to a few days
• ~1% take longer than a few days
(Source: McConnell, Steve Code Complete. Microsoft Press, 2004. pages 519)
© 2013, Nguyen Tran Hoang Linh 21
Estimating Defect Fixes
Don’t assign junior programmers to fix
defects
• They can unintentionally introduce new defects
(Source: McConnell, Steve Code Complete. Microsoft Press, 2004. pages 519)
© 2013, Nguyen Tran Hoang Linh 22
Rules for Making Code Changes
Developers responsible for:
• Keeping their machine in synch with the
configuration management system
• Fixing one defect per set of source file revisions
• Creating/updating automated unit tests
May want to consider test first programming style
• Creating/updating automated system and/or
acceptance tests
• Ensuring that all tests run successfully before
integrating code back into master repository
• Resolving conflicts when checking code back in
• Updating change documentation
© 2013, Nguyen Tran Hoang Linh 23
Summary
As a developer YOU are responsible for
creating high quality code in a timely and
predictable manner
Learn:
• The software you are working on
• Coding and problem solving techniques
• The development tools available to you
Share your knowledge, and learn from
your peers
In most cases, the projects with the fewest
defects have the shortest schedules
© 2013, Nguyen Tran Hoang Linh 24