Download - A Lesson In Low-Defect Software
![Page 1: A Lesson In Low-Defect Software](https://reader033.vdocuments.us/reader033/viewer/2022052912/55a05de21a28ab3c2e8b45b1/html5/thumbnails/1.jpg)
A Lesson In Low-Defect Software- or -
A Journey From A Quick HackTo A High-Reliability Database Engine
and how you can use the same techniques to reducethe number of bugs in your own software projects
D. Richard Hipp2009-03-10
![Page 2: A Lesson In Low-Defect Software](https://reader033.vdocuments.us/reader033/viewer/2022052912/55a05de21a28ab3c2e8b45b1/html5/thumbnails/2.jpg)
What Is ?
SQL Database EngineACID
Transactional Single-file Database
Small footprint
Efficient
Robust
Zero-administration
EmbeddedServerless
Stable, cross-platform file format
Public domain
Easy to integrate
![Page 3: A Lesson In Low-Defect Software](https://reader033.vdocuments.us/reader033/viewer/2022052912/55a05de21a28ab3c2e8b45b1/html5/thumbnails/3.jpg)
SQL?What's That?
● “Structured Query Langauge”● A high-level language for interacting with
databases● The most widely known programming language
in the world.
![Page 4: A Lesson In Low-Defect Software](https://reader033.vdocuments.us/reader033/viewer/2022052912/55a05de21a28ab3c2e8b45b1/html5/thumbnails/4.jpg)
Why SQLite?
![Page 5: A Lesson In Low-Defect Software](https://reader033.vdocuments.us/reader033/viewer/2022052912/55a05de21a28ab3c2e8b45b1/html5/thumbnails/5.jpg)
![Page 6: A Lesson In Low-Defect Software](https://reader033.vdocuments.us/reader033/viewer/2022052912/55a05de21a28ab3c2e8b45b1/html5/thumbnails/6.jpg)
● Serverless● Zero-administration● Portable file format● Small footprint● Public domain
![Page 7: A Lesson In Low-Defect Software](https://reader033.vdocuments.us/reader033/viewer/2022052912/55a05de21a28ab3c2e8b45b1/html5/thumbnails/7.jpg)
● Serverless● Zero-administration● Portable file format● Small footprint● Public domain
![Page 8: A Lesson In Low-Defect Software](https://reader033.vdocuments.us/reader033/viewer/2022052912/55a05de21a28ab3c2e8b45b1/html5/thumbnails/8.jpg)
DatabaseFiles on
Disk
SQL Database
Engine
Client
Client Client
Client
![Page 9: A Lesson In Low-Defect Software](https://reader033.vdocuments.us/reader033/viewer/2022052912/55a05de21a28ab3c2e8b45b1/html5/thumbnails/9.jpg)
DatabaseFiles on
Disk
Client
Client Client
Client
![Page 10: A Lesson In Low-Defect Software](https://reader033.vdocuments.us/reader033/viewer/2022052912/55a05de21a28ab3c2e8b45b1/html5/thumbnails/10.jpg)
Advantages of Serverless
● No background server process● No configuration files● No IPC● No security issues● Nothing to start, shutdown, or reboot● Nothing to go wrong or need tending to
![Page 11: A Lesson In Low-Defect Software](https://reader033.vdocuments.us/reader033/viewer/2022052912/55a05de21a28ab3c2e8b45b1/html5/thumbnails/11.jpg)
Advantages of Serverless
● No background server process● No configuration files● No IPC● No security issues● Nothing to start, shutdown, or reboot● Nothing to go wrong or need tending to
“ - ”Zero a dm in i str a t i on
![Page 12: A Lesson In Low-Defect Software](https://reader033.vdocuments.us/reader033/viewer/2022052912/55a05de21a28ab3c2e8b45b1/html5/thumbnails/12.jpg)
● Serverless● Zero-administration● Portable file format● Small footprint● Public domain
![Page 13: A Lesson In Low-Defect Software](https://reader033.vdocuments.us/reader033/viewer/2022052912/55a05de21a28ab3c2e8b45b1/html5/thumbnails/13.jpg)
Database Administrators
![Page 14: A Lesson In Low-Defect Software](https://reader033.vdocuments.us/reader033/viewer/2022052912/55a05de21a28ab3c2e8b45b1/html5/thumbnails/14.jpg)
![Page 15: A Lesson In Low-Defect Software](https://reader033.vdocuments.us/reader033/viewer/2022052912/55a05de21a28ab3c2e8b45b1/html5/thumbnails/15.jpg)
![Page 16: A Lesson In Low-Defect Software](https://reader033.vdocuments.us/reader033/viewer/2022052912/55a05de21a28ab3c2e8b45b1/html5/thumbnails/16.jpg)
DatabaseFiles on
Disk
SQL Database
Engine
Client
Client Client
Client
![Page 17: A Lesson In Low-Defect Software](https://reader033.vdocuments.us/reader033/viewer/2022052912/55a05de21a28ab3c2e8b45b1/html5/thumbnails/17.jpg)
DatabaseFiles on
Disk
Client
Client Client
Client
![Page 18: A Lesson In Low-Defect Software](https://reader033.vdocuments.us/reader033/viewer/2022052912/55a05de21a28ab3c2e8b45b1/html5/thumbnails/18.jpg)
DatabaseFiles on
Disk
Client
Client Client
Client
SQLite 1.02000-08-17
![Page 19: A Lesson In Low-Defect Software](https://reader033.vdocuments.us/reader033/viewer/2022052912/55a05de21a28ab3c2e8b45b1/html5/thumbnails/19.jpg)
Another way to think ofSQLite in relation totraditional SQL databaseengines....
![Page 20: A Lesson In Low-Defect Software](https://reader033.vdocuments.us/reader033/viewer/2022052912/55a05de21a28ab3c2e8b45b1/html5/thumbnails/20.jpg)
![Page 21: A Lesson In Low-Defect Software](https://reader033.vdocuments.us/reader033/viewer/2022052912/55a05de21a28ab3c2e8b45b1/html5/thumbnails/21.jpg)
![Page 22: A Lesson In Low-Defect Software](https://reader033.vdocuments.us/reader033/viewer/2022052912/55a05de21a28ab3c2e8b45b1/html5/thumbnails/22.jpg)
is to is toas
![Page 23: A Lesson In Low-Defect Software](https://reader033.vdocuments.us/reader033/viewer/2022052912/55a05de21a28ab3c2e8b45b1/html5/thumbnails/23.jpg)
● SQLite does not compete with Oracle
![Page 24: A Lesson In Low-Defect Software](https://reader033.vdocuments.us/reader033/viewer/2022052912/55a05de21a28ab3c2e8b45b1/html5/thumbnails/24.jpg)
● SQLite does not compete with Oracle● SQLite competes with fopen()
![Page 25: A Lesson In Low-Defect Software](https://reader033.vdocuments.us/reader033/viewer/2022052912/55a05de21a28ab3c2e8b45b1/html5/thumbnails/25.jpg)
● Serverless● Zero-administration● Portable file format● Small footprint● Public domain
![Page 26: A Lesson In Low-Defect Software](https://reader033.vdocuments.us/reader033/viewer/2022052912/55a05de21a28ab3c2e8b45b1/html5/thumbnails/26.jpg)
Portable File Format
● A database is a single ordinary disk file● No special naming conventions or required file
suffixes● Cross-platform: big/little-endian and 32/64-bit● Backwards compatible through 3.0.0● Promise to keep it compatible moving forward● Not tied to any particular programming
language.
![Page 27: A Lesson In Low-Defect Software](https://reader033.vdocuments.us/reader033/viewer/2022052912/55a05de21a28ab3c2e8b45b1/html5/thumbnails/27.jpg)
![Page 28: A Lesson In Low-Defect Software](https://reader033.vdocuments.us/reader033/viewer/2022052912/55a05de21a28ab3c2e8b45b1/html5/thumbnails/28.jpg)
● Serverless● Zero-administration● Portable file format● Small footprint● Public domain
![Page 29: A Lesson In Low-Defect Software](https://reader033.vdocuments.us/reader033/viewer/2022052912/55a05de21a28ab3c2e8b45b1/html5/thumbnails/29.jpg)
Small Footprint
gcc -Os -DSQLITE_THREADSAFE=0
gcc -O3 -DSQLITE_ENABLE_FTS3=1 -DSQLITE_ENABLE_RTREE=1
272 KiB
789 KiB
As of 2009-02-17
![Page 30: A Lesson In Low-Defect Software](https://reader033.vdocuments.us/reader033/viewer/2022052912/55a05de21a28ab3c2e8b45b1/html5/thumbnails/30.jpg)
Single Source Code File
● The “amalgamation” source code file: sqlite3.c● About 60,000 lines of ANSI C code● 3.5 MB● No other library dependencies on than standard
library routines:– memcpy(), memset(), malloc(), free(), etc
● Very simple to add to a larger C program
![Page 31: A Lesson In Low-Defect Software](https://reader033.vdocuments.us/reader033/viewer/2022052912/55a05de21a28ab3c2e8b45b1/html5/thumbnails/31.jpg)
![Page 32: A Lesson In Low-Defect Software](https://reader033.vdocuments.us/reader033/viewer/2022052912/55a05de21a28ab3c2e8b45b1/html5/thumbnails/32.jpg)
● Serverless● Zero-administration● Portable file format● Small footprint● Public domain
![Page 33: A Lesson In Low-Defect Software](https://reader033.vdocuments.us/reader033/viewer/2022052912/55a05de21a28ab3c2e8b45b1/html5/thumbnails/33.jpg)
![Page 34: A Lesson In Low-Defect Software](https://reader033.vdocuments.us/reader033/viewer/2022052912/55a05de21a28ab3c2e8b45b1/html5/thumbnails/34.jpg)
Other Features Of SQLite
● App-defined functions● App-defined collating
sequences● UTF8 or UTF16● Robust against power
loss● Robust against
malloc() failures
● Full text search● R-Trees● ATTACH DATABASE● Gigibyte size BLOBs
and strings● Robust against I/O
errors● Zero-malloc option
![Page 35: A Lesson In Low-Defect Software](https://reader033.vdocuments.us/reader033/viewer/2022052912/55a05de21a28ab3c2e8b45b1/html5/thumbnails/35.jpg)
Adobe Photoshop Lightroom
![Page 36: A Lesson In Low-Defect Software](https://reader033.vdocuments.us/reader033/viewer/2022052912/55a05de21a28ab3c2e8b45b1/html5/thumbnails/36.jpg)
Adobe Reader
![Page 37: A Lesson In Low-Defect Software](https://reader033.vdocuments.us/reader033/viewer/2022052912/55a05de21a28ab3c2e8b45b1/html5/thumbnails/37.jpg)
Mozilla Firefox
![Page 38: A Lesson In Low-Defect Software](https://reader033.vdocuments.us/reader033/viewer/2022052912/55a05de21a28ab3c2e8b45b1/html5/thumbnails/38.jpg)
![Page 39: A Lesson In Low-Defect Software](https://reader033.vdocuments.us/reader033/viewer/2022052912/55a05de21a28ab3c2e8b45b1/html5/thumbnails/39.jpg)
Google Android
![Page 40: A Lesson In Low-Defect Software](https://reader033.vdocuments.us/reader033/viewer/2022052912/55a05de21a28ab3c2e8b45b1/html5/thumbnails/40.jpg)
iPhone
![Page 41: A Lesson In Low-Defect Software](https://reader033.vdocuments.us/reader033/viewer/2022052912/55a05de21a28ab3c2e8b45b1/html5/thumbnails/41.jpg)
iPod & iTunes
![Page 42: A Lesson In Low-Defect Software](https://reader033.vdocuments.us/reader033/viewer/2022052912/55a05de21a28ab3c2e8b45b1/html5/thumbnails/42.jpg)
iStuff
![Page 43: A Lesson In Low-Defect Software](https://reader033.vdocuments.us/reader033/viewer/2022052912/55a05de21a28ab3c2e8b45b1/html5/thumbnails/43.jpg)
Blackberry
![Page 44: A Lesson In Low-Defect Software](https://reader033.vdocuments.us/reader033/viewer/2022052912/55a05de21a28ab3c2e8b45b1/html5/thumbnails/44.jpg)
Palm webOS
![Page 45: A Lesson In Low-Defect Software](https://reader033.vdocuments.us/reader033/viewer/2022052912/55a05de21a28ab3c2e8b45b1/html5/thumbnails/45.jpg)
Skype
![Page 46: A Lesson In Low-Defect Software](https://reader033.vdocuments.us/reader033/viewer/2022052912/55a05de21a28ab3c2e8b45b1/html5/thumbnails/46.jpg)
Sony Playstation
![Page 47: A Lesson In Low-Defect Software](https://reader033.vdocuments.us/reader033/viewer/2022052912/55a05de21a28ab3c2e8b45b1/html5/thumbnails/47.jpg)
... and so forth
![Page 48: A Lesson In Low-Defect Software](https://reader033.vdocuments.us/reader033/viewer/2022052912/55a05de21a28ab3c2e8b45b1/html5/thumbnails/48.jpg)
Various Programming Languages
![Page 49: A Lesson In Low-Defect Software](https://reader033.vdocuments.us/reader033/viewer/2022052912/55a05de21a28ab3c2e8b45b1/html5/thumbnails/49.jpg)
SQLite.orgThe Company
![Page 50: A Lesson In Low-Defect Software](https://reader033.vdocuments.us/reader033/viewer/2022052912/55a05de21a28ab3c2e8b45b1/html5/thumbnails/50.jpg)
The SQLite Development Team
![Page 51: A Lesson In Low-Defect Software](https://reader033.vdocuments.us/reader033/viewer/2022052912/55a05de21a28ab3c2e8b45b1/html5/thumbnails/51.jpg)
ConsortiumThe
● Guarantees of project continuity● Enterprise-level technical support● Highest priority bug fixes● Community Outreach
![Page 52: A Lesson In Low-Defect Software](https://reader033.vdocuments.us/reader033/viewer/2022052912/55a05de21a28ab3c2e8b45b1/html5/thumbnails/52.jpg)
ConsortiumThe
● Guarantees of project continuity● Enterprise-level technical support● Highest priority bug fixes● Community Outreach
Keep It Reliable And Bug-Free!
![Page 53: A Lesson In Low-Defect Software](https://reader033.vdocuments.us/reader033/viewer/2022052912/55a05de21a28ab3c2e8b45b1/html5/thumbnails/53.jpg)
The SQLite Journey
● SQLite 1.0 started out as a quick hack– To solve a single problem in a single application– Used only in a tightly controlled environment
● It has evolved into highly reliable and low-defect software– The most widely used SQL database engine in the
world– Hundreds of millions of deployments– Any defect has huge impact
● How did we achieve this?
![Page 54: A Lesson In Low-Defect Software](https://reader033.vdocuments.us/reader033/viewer/2022052912/55a05de21a28ab3c2e8b45b1/html5/thumbnails/54.jpg)
Safety ≠ Reliability
First, some terminology:
![Page 55: A Lesson In Low-Defect Software](https://reader033.vdocuments.us/reader033/viewer/2022052912/55a05de21a28ab3c2e8b45b1/html5/thumbnails/55.jpg)
Reliability: no failures
Safety: no harm
![Page 56: A Lesson In Low-Defect Software](https://reader033.vdocuments.us/reader033/viewer/2022052912/55a05de21a28ab3c2e8b45b1/html5/thumbnails/56.jpg)
Volvo: Safe but not Reliable
![Page 57: A Lesson In Low-Defect Software](https://reader033.vdocuments.us/reader033/viewer/2022052912/55a05de21a28ab3c2e8b45b1/html5/thumbnails/57.jpg)
Nitroglycerin: Reliable but not Safe
![Page 58: A Lesson In Low-Defect Software](https://reader033.vdocuments.us/reader033/viewer/2022052912/55a05de21a28ab3c2e8b45b1/html5/thumbnails/58.jpg)
Safety ≠ Reliability
![Page 59: A Lesson In Low-Defect Software](https://reader033.vdocuments.us/reader033/viewer/2022052912/55a05de21a28ab3c2e8b45b1/html5/thumbnails/59.jpg)
SafeSoftware
ReliableSoftware≅
![Page 60: A Lesson In Low-Defect Software](https://reader033.vdocuments.us/reader033/viewer/2022052912/55a05de21a28ab3c2e8b45b1/html5/thumbnails/60.jpg)
SafeSoftware
ExtremelyReliableSoftware
=
![Page 61: A Lesson In Low-Defect Software](https://reader033.vdocuments.us/reader033/viewer/2022052912/55a05de21a28ab3c2e8b45b1/html5/thumbnails/61.jpg)
Safe Programming Languages?
![Page 62: A Lesson In Low-Defect Software](https://reader033.vdocuments.us/reader033/viewer/2022052912/55a05de21a28ab3c2e8b45b1/html5/thumbnails/62.jpg)
Safe Programming Languages?
● Prevent buffer overruns● Help prevent memory leaks● Trap exceptions
![Page 63: A Lesson In Low-Defect Software](https://reader033.vdocuments.us/reader033/viewer/2022052912/55a05de21a28ab3c2e8b45b1/html5/thumbnails/63.jpg)
Safe Programming Languages?
● Prevent buffer overruns● Help prevent memory leaks● Trap exceptions
● They can still get the wrong answer
But....
![Page 64: A Lesson In Low-Defect Software](https://reader033.vdocuments.us/reader033/viewer/2022052912/55a05de21a28ab3c2e8b45b1/html5/thumbnails/64.jpg)
Safe Programming Languages?
Less likely to havea zero-day exploit
Less likely to causeinjury or death
![Page 65: A Lesson In Low-Defect Software](https://reader033.vdocuments.us/reader033/viewer/2022052912/55a05de21a28ab3c2e8b45b1/html5/thumbnails/65.jpg)
What Programming LanguagesDoes The World's Most Reliable
Software Use?
![Page 66: A Lesson In Low-Defect Software](https://reader033.vdocuments.us/reader033/viewer/2022052912/55a05de21a28ab3c2e8b45b1/html5/thumbnails/66.jpg)
What Programming LanguagesDoes The World's Most Reliable
Software Use?
Hint: The answer is not any of the following:
![Page 67: A Lesson In Low-Defect Software](https://reader033.vdocuments.us/reader033/viewer/2022052912/55a05de21a28ab3c2e8b45b1/html5/thumbnails/67.jpg)
Space Shuttle: HAL/S
![Page 68: A Lesson In Low-Defect Software](https://reader033.vdocuments.us/reader033/viewer/2022052912/55a05de21a28ab3c2e8b45b1/html5/thumbnails/68.jpg)
Avionics: Ada or C
![Page 69: A Lesson In Low-Defect Software](https://reader033.vdocuments.us/reader033/viewer/2022052912/55a05de21a28ab3c2e8b45b1/html5/thumbnails/69.jpg)
DO-178B and ED-12B
● It's the development process not the programming language that counts.
● Captures best practices● Required for safety-critical software by:
![Page 70: A Lesson In Low-Defect Software](https://reader033.vdocuments.us/reader033/viewer/2022052912/55a05de21a28ab3c2e8b45b1/html5/thumbnails/70.jpg)
DO-178B and ED-12B
● 21 “outputs” (mostly reports)● 66 “objectives”
Reports &Documentation
Code
![Page 71: A Lesson In Low-Defect Software](https://reader033.vdocuments.us/reader033/viewer/2022052912/55a05de21a28ab3c2e8b45b1/html5/thumbnails/71.jpg)
Planning Documents
● Plan for Software Aspects of Certification● Software Development Plan● Software Verification Plan● Software Configuration Management Plan● Software Quality Assurance Plan● Software Requirements Standards● Software Design Standards● Software Coding Standards
![Page 72: A Lesson In Low-Defect Software](https://reader033.vdocuments.us/reader033/viewer/2022052912/55a05de21a28ab3c2e8b45b1/html5/thumbnails/72.jpg)
Verification Documents
● Software Verifications Cases & Procedures● Software Verification Results● Software Configuration Management Records● Software Configuration Index● Bug Reports● Software Quality Assurance Records● Software Conformity Review● Software Accomplishment Summary
![Page 73: A Lesson In Low-Defect Software](https://reader033.vdocuments.us/reader033/viewer/2022052912/55a05de21a28ab3c2e8b45b1/html5/thumbnails/73.jpg)
Requirements Stack
System Requirements
High Level Requirements
Software Architecture
Low Level Requirements
Source Code
Object Code
![Page 74: A Lesson In Low-Defect Software](https://reader033.vdocuments.us/reader033/viewer/2022052912/55a05de21a28ab3c2e8b45b1/html5/thumbnails/74.jpg)
4 Sample Objectives out of 66
● High-level requirements comply with system requirements (with independence)
● High-level requirement algorithms are accurate (with independence)
● Source code it traceable to low-level requirements
● Modified Condition/Decision test coverage is achieved (with independence)
![Page 75: A Lesson In Low-Defect Software](https://reader033.vdocuments.us/reader033/viewer/2022052912/55a05de21a28ab3c2e8b45b1/html5/thumbnails/75.jpg)
End result of DO-178B/ED-12B....
● Software that has very few defects
![Page 76: A Lesson In Low-Defect Software](https://reader033.vdocuments.us/reader033/viewer/2022052912/55a05de21a28ab3c2e8b45b1/html5/thumbnails/76.jpg)
End result of DO-178B/ED-12B....
● Software that has very few defects
● Expensive software● Software that takes a long time to bring to
market● Boring software
Also...
![Page 77: A Lesson In Low-Defect Software](https://reader033.vdocuments.us/reader033/viewer/2022052912/55a05de21a28ab3c2e8b45b1/html5/thumbnails/77.jpg)
The Essence of DO-178B
● Use your whole brain● Full coverage testing● Good configuration management
![Page 78: A Lesson In Low-Defect Software](https://reader033.vdocuments.us/reader033/viewer/2022052912/55a05de21a28ab3c2e8b45b1/html5/thumbnails/78.jpg)
3 Steps Toward Low-Defect Code
● Use your whole brain● Full coverage testing● Good configuration management
![Page 79: A Lesson In Low-Defect Software](https://reader033.vdocuments.us/reader033/viewer/2022052912/55a05de21a28ab3c2e8b45b1/html5/thumbnails/79.jpg)
3 Steps Toward Low-Defect Code
● Use your whole brain● Full coverage testing● Good configuration management● Don't just fix bugs – fix your process
Not in DO-178B, but ought to be
4
![Page 80: A Lesson In Low-Defect Software](https://reader033.vdocuments.us/reader033/viewer/2022052912/55a05de21a28ab3c2e8b45b1/html5/thumbnails/80.jpg)
4 Steps Toward Low-Defect Code
● Use your whole brain● Full coverage testing● Good configuration management● Don't just fix bugs – fix your process
![Page 81: A Lesson In Low-Defect Software](https://reader033.vdocuments.us/reader033/viewer/2022052912/55a05de21a28ab3c2e8b45b1/html5/thumbnails/81.jpg)
Use Your Whole Brain
Math side Language side
![Page 82: A Lesson In Low-Defect Software](https://reader033.vdocuments.us/reader033/viewer/2022052912/55a05de21a28ab3c2e8b45b1/html5/thumbnails/82.jpg)
Use Your Whole Brain
Code side Comment side
![Page 83: A Lesson In Low-Defect Software](https://reader033.vdocuments.us/reader033/viewer/2022052912/55a05de21a28ab3c2e8b45b1/html5/thumbnails/83.jpg)
Why Put Comments In Code?
1) Make the code easier to read2) Engage the linguistic side of your brain
![Page 84: A Lesson In Low-Defect Software](https://reader033.vdocuments.us/reader033/viewer/2022052912/55a05de21a28ab3c2e8b45b1/html5/thumbnails/84.jpg)
Code without Comments?
● Only uses have your brain.
● In English we call this being a “half-wit”.
![Page 85: A Lesson In Low-Defect Software](https://reader033.vdocuments.us/reader033/viewer/2022052912/55a05de21a28ab3c2e8b45b1/html5/thumbnails/85.jpg)
Why Put Comments In Code?
1) Make the code easier to read2) Engage the linguistic side of your brain
Catch and fix code defects early
![Page 86: A Lesson In Low-Defect Software](https://reader033.vdocuments.us/reader033/viewer/2022052912/55a05de21a28ab3c2e8b45b1/html5/thumbnails/86.jpg)
Hey, Carl, can you look at this problem with me. I've been working on this forhours. You see the X variable clearly cannot be less than zero because Y has to be more than 20.... Oh wait. That's not right. OK, I've got it now. Thanks, Carl!
![Page 87: A Lesson In Low-Defect Software](https://reader033.vdocuments.us/reader033/viewer/2022052912/55a05de21a28ab3c2e8b45b1/html5/thumbnails/87.jpg)
Why Put Comments In Code?
1) Make the code easier to read2) Engage the linguistic side of your brain
Common Fallacy: “Well-written code needs no comments”● Ignores reason (2) for writing comments● No code is ever that well written
![Page 88: A Lesson In Low-Defect Software](https://reader033.vdocuments.us/reader033/viewer/2022052912/55a05de21a28ab3c2e8b45b1/html5/thumbnails/88.jpg)
What To Comment● Each function or procedure and major code
blocks– Explain what it computes, not how it works– Preconditions, postconditions, invariants
● Each variable, constant, and type declaration– Explain what the variable or type represents– Constraints
● Comments stand in for low-level requirements● Be succinct – avoid fancy formatting and
boilerplate
![Page 89: A Lesson In Low-Defect Software](https://reader033.vdocuments.us/reader033/viewer/2022052912/55a05de21a28ab3c2e8b45b1/html5/thumbnails/89.jpg)
Mother-tongue Or English?
● English-language comments are best for readability.
● Mother-tongue comments are best for catching bugs.
● Why not do both?
![Page 90: A Lesson In Low-Defect Software](https://reader033.vdocuments.us/reader033/viewer/2022052912/55a05de21a28ab3c2e8b45b1/html5/thumbnails/90.jpg)
![Page 91: A Lesson In Low-Defect Software](https://reader033.vdocuments.us/reader033/viewer/2022052912/55a05de21a28ab3c2e8b45b1/html5/thumbnails/91.jpg)
System Requirements
High Level Requirements
Software Architecture
Low Level Requirements
Source Code
Object Code
![Page 92: A Lesson In Low-Defect Software](https://reader033.vdocuments.us/reader033/viewer/2022052912/55a05de21a28ab3c2e8b45b1/html5/thumbnails/92.jpg)
Code :: Comment53813 :: 27695
* As of 2009-03-03 18:20 EST
![Page 93: A Lesson In Low-Defect Software](https://reader033.vdocuments.us/reader033/viewer/2022052912/55a05de21a28ab3c2e8b45b1/html5/thumbnails/93.jpg)
Code :: Comment2 :: 1
![Page 94: A Lesson In Low-Defect Software](https://reader033.vdocuments.us/reader033/viewer/2022052912/55a05de21a28ab3c2e8b45b1/html5/thumbnails/94.jpg)
Express Ideas In Different Ways
stmt ::= ALTER TABLE fullname RENAME TO id.stmt ::= ALTER TABLE fullname ADD column_opt column_def.
![Page 95: A Lesson In Low-Defect Software](https://reader033.vdocuments.us/reader033/viewer/2022052912/55a05de21a28ab3c2e8b45b1/html5/thumbnails/95.jpg)
Use Multiple Brains
● Structured Walk-Throughs & Inspections– Finds errors that a single programmer will miss– Keeps the code uniform– Helps entire team stay up-to-date– Training for junior team members– Only works if down well
![Page 96: A Lesson In Low-Defect Software](https://reader033.vdocuments.us/reader033/viewer/2022052912/55a05de21a28ab3c2e8b45b1/html5/thumbnails/96.jpg)
Use Multiple Brains
● Pair Programming– Two people working together on the same
workstation● One person works the keyboard● The other person reads and checks for mistakes
– Builds a sense of community ownership– Promotes uniformity of coding and commenting
style– Requires that programmers be colocated– Requires interpersonal skills (which many
programmers lack)
![Page 97: A Lesson In Low-Defect Software](https://reader033.vdocuments.us/reader033/viewer/2022052912/55a05de21a28ab3c2e8b45b1/html5/thumbnails/97.jpg)
Use Multiple Brains
● Open-Source– Encourage volunteer code reviewers– It helps if your code has good (English) comments!– In practice, very few bugs are ever found this way
![Page 98: A Lesson In Low-Defect Software](https://reader033.vdocuments.us/reader033/viewer/2022052912/55a05de21a28ab3c2e8b45b1/html5/thumbnails/98.jpg)
![Page 99: A Lesson In Low-Defect Software](https://reader033.vdocuments.us/reader033/viewer/2022052912/55a05de21a28ab3c2e8b45b1/html5/thumbnails/99.jpg)
4 Steps Toward Low-Defect Code
● Use your whole brain● Full coverage testing● Good configuration management● Don't just fix bugs – fix your process
![Page 100: A Lesson In Low-Defect Software](https://reader033.vdocuments.us/reader033/viewer/2022052912/55a05de21a28ab3c2e8b45b1/html5/thumbnails/100.jpg)
Full Coverage Testing
● Automated tests that exercise all features of the program– All entry points– All subroutines– All branches and conditions– All cases– All boundary values
● The single best way to find bugs● DO-178B places special emphasis on testing
![Page 101: A Lesson In Low-Defect Software](https://reader033.vdocuments.us/reader033/viewer/2022052912/55a05de21a28ab3c2e8b45b1/html5/thumbnails/101.jpg)
If it has not been testedthen it does not work.
Fly what you testand test what you fly.
![Page 102: A Lesson In Low-Defect Software](https://reader033.vdocuments.us/reader033/viewer/2022052912/55a05de21a28ab3c2e8b45b1/html5/thumbnails/102.jpg)
Statement Coverage:
Branch Coverage:
Tests cause every line of code to run at least once.
Tests cause every machine-language branch operationto evaluate to both TRUE and FALSE at least once.
![Page 103: A Lesson In Low-Defect Software](https://reader033.vdocuments.us/reader033/viewer/2022052912/55a05de21a28ab3c2e8b45b1/html5/thumbnails/103.jpg)
int exampleFunction(int a, int b){ int ans = 0; if( a>b && a<2*b ){ ans = a; }else{ ans = b; } return ans;}
![Page 104: A Lesson In Low-Defect Software](https://reader033.vdocuments.us/reader033/viewer/2022052912/55a05de21a28ab3c2e8b45b1/html5/thumbnails/104.jpg)
int exampleFunction(int a, int b){ int ans = 0; if( a>b && a<2*b ){ ans = a; }else{ ans = b; } return ans;}
Test 1: exampleFunction(1,1)
5 out of 6 statements: 83.33% statement coverage
![Page 105: A Lesson In Low-Defect Software](https://reader033.vdocuments.us/reader033/viewer/2022052912/55a05de21a28ab3c2e8b45b1/html5/thumbnails/105.jpg)
int exampleFunction(int a, int b){ int ans = 0; if( a>b && a<2*b ){ ans = a; }else{ ans = b; } return ans;}
Test 1: exampleFunction(1,1)Test 2: exampleFunction(3,2)
6 out of 6 statements: 100% statement coverage
![Page 106: A Lesson In Low-Defect Software](https://reader033.vdocuments.us/reader033/viewer/2022052912/55a05de21a28ab3c2e8b45b1/html5/thumbnails/106.jpg)
int exampleFunction(int a, int b){ int ans = 0; if( a>b && a<2*b ){ ans = a; }else{ ans = b; } return ans;}
Test 1: exampleFunction(1,1)Test 2: exampleFunction(3,2)
3 out of 4 branches: 75% branch coverage
Branches: a>b Taken on test 2 !(a>b) Taken on test 1 a<2*b Taken on test 2 !(a<2*b) Never taken
![Page 107: A Lesson In Low-Defect Software](https://reader033.vdocuments.us/reader033/viewer/2022052912/55a05de21a28ab3c2e8b45b1/html5/thumbnails/107.jpg)
int exampleFunction(int a, int b){ int ans = 0; if( a>b && a<2*b ){ ans = a; }else{ ans = b; } return ans;}
Test 1: exampleFunction(1,1)Test 2: exampleFunction(3,2)Test 3: exampleFunction(4,2)
4 out of 4 branches: 100% branch coverage
Branches: a>b Taken on test 2 !(a>b) Taken on test 1 a<2*b Taken on test 2 !(a<2*b) Taken on test 3
![Page 108: A Lesson In Low-Defect Software](https://reader033.vdocuments.us/reader033/viewer/2022052912/55a05de21a28ab3c2e8b45b1/html5/thumbnails/108.jpg)
Measuring Statement Coverage
gcc -g -fprofile-arcs -ftest-coverage./a.outgcov -c ex1.ccat ex1.c.gcov
![Page 109: A Lesson In Low-Defect Software](https://reader033.vdocuments.us/reader033/viewer/2022052912/55a05de21a28ab3c2e8b45b1/html5/thumbnails/109.jpg)
Measuring Statement Coverage
1: 1:int exampleFunction(int a, int b){ 1: 2: int ans = 0; 1: 3: if( a>b && a<2*b ){ #####: 4: ans = a; -: 5: }else{ 1: 6: ans = b; -: 7: } 1: 8: return ans; -: 9:}
Number of times this line was evaluated
Line number in source file
Test 1 only
![Page 110: A Lesson In Low-Defect Software](https://reader033.vdocuments.us/reader033/viewer/2022052912/55a05de21a28ab3c2e8b45b1/html5/thumbnails/110.jpg)
Measuring Statement Coverage
2: 1:int exampleFunction(int a, int b){ 2: 2: int ans = 0; 2: 3: if( a>b && a<2*b ){ 1: 4: ans = a; -: 5: }else{ 1: 6: ans = b; -: 7: } 2: 8: return ans; -: 9:}
Number of times this line was evaluated
Line number in source file
Tests 1 & 2
![Page 111: A Lesson In Low-Defect Software](https://reader033.vdocuments.us/reader033/viewer/2022052912/55a05de21a28ab3c2e8b45b1/html5/thumbnails/111.jpg)
Measuring Branch Coverage
gcc -g -fprofile-arcs -ftest-coverage./a.outgcov -b -c ex1.ccat ex1.c.gcov
The only change
![Page 112: A Lesson In Low-Defect Software](https://reader033.vdocuments.us/reader033/viewer/2022052912/55a05de21a28ab3c2e8b45b1/html5/thumbnails/112.jpg)
Measuring Branch Coverage
1: 1:int exampleFunction(int a, int b){ 1: 2: int ans = 0; 1: 3: if( a>b && a<2*b ){branch 0 taken 0 (fallthrough)branch 1 taken 1branch 2 never executedbranch 3 never executed #####: 4: ans = a; -: 5: }else{ 1: 6: ans = b; -: 7: } 1: 8: return ans; -: 9:}
Condition never evaluated
Branch never taken
Test 1 only
![Page 113: A Lesson In Low-Defect Software](https://reader033.vdocuments.us/reader033/viewer/2022052912/55a05de21a28ab3c2e8b45b1/html5/thumbnails/113.jpg)
Measuring Branch Coverage
2: 1:int exampleFunction(int a, int b){ 2: 2: int ans = 0; 2: 3: if( a>b && a<2*b ){branch 0 taken 1 (fallthrough)branch 1 taken 1branch 2 taken 1 (fallthrough)branch 3 taken 0 1: 4: ans = a; -: 5: }else{ 1: 6: ans = b; -: 7: } 2: 8: return ans; -: 9:}
Branch never taken
Tests 1 & 2
![Page 114: A Lesson In Low-Defect Software](https://reader033.vdocuments.us/reader033/viewer/2022052912/55a05de21a28ab3c2e8b45b1/html5/thumbnails/114.jpg)
Measuring Branch Coverage
3: 1:int exampleFunction(int a, int b){ 3: 2: int ans = 0; 3: 3: if( a>b && a<2*b ){branch 0 taken 2 (fallthrough)branch 1 taken 1branch 2 taken 1 (fallthrough)branch 3 taken 1 1: 4: ans = a; -: 5: }else{ 2: 6: ans = b; -: 7: } 3: 8: return ans; -: 9:}
Tests 1, 2, & 3
All branches takenat least once:100% coverage!
![Page 115: A Lesson In Low-Defect Software](https://reader033.vdocuments.us/reader033/viewer/2022052912/55a05de21a28ab3c2e8b45b1/html5/thumbnails/115.jpg)
Fly what you test!
● Compile for coverage testing● Run tests● Verify correct result● Recompile as delivered● Rerun tests● Verify same results as before
Not what you fly
What you fly
![Page 116: A Lesson In Low-Defect Software](https://reader033.vdocuments.us/reader033/viewer/2022052912/55a05de21a28ab3c2e8b45b1/html5/thumbnails/116.jpg)
Fly what you test!
● Compile for coverage testing● Run tests● Verify correct result● Recompile as delivered● Rerun tests● Verify same results as before● Measuring coverage validates
your tests, not your product
Not what you flyValidates your tests
What you flyValidates your product
![Page 117: A Lesson In Low-Defect Software](https://reader033.vdocuments.us/reader033/viewer/2022052912/55a05de21a28ab3c2e8b45b1/html5/thumbnails/117.jpg)
Defensive Programming
void *sqlite3InternalMalloc(int nBytes){ if( nBytes<=0 ){ return 0; }else{ return sqlite3LowLevelMalloc(nBytes); }}
● Unable to handle nBytes>0x7FFFFFF0● Will return incorrectly sized buffer if nBytes is too large.● Possible memory overrun exploit
Will never be larger than 0x40000010
![Page 118: A Lesson In Low-Defect Software](https://reader033.vdocuments.us/reader033/viewer/2022052912/55a05de21a28ab3c2e8b45b1/html5/thumbnails/118.jpg)
Defensive Programming
void *sqlite3InternalMalloc(int nBytes){ if( nBytes<=0 || nBytes>=0x7fffff00 ){ return 0; }else{ return sqlite3LowLevelMalloc(nBytes); }}
● Prevents any possibility of an exploit● But – how can we test it?
![Page 119: A Lesson In Low-Defect Software](https://reader033.vdocuments.us/reader033/viewer/2022052912/55a05de21a28ab3c2e8b45b1/html5/thumbnails/119.jpg)
Defensive Programming
void *sqlite3InternalMalloc(int nBytes){ if( nBytes<=0 || NEVER(nBytes>=0x7fffff00) ){ return 0; }else{ return sqlite3LowLevelMalloc(nBytes); }}
● NEVER() macro around conditions that are always FALSE● ALWAYS() macro around conditions that are always TRUE
![Page 120: A Lesson In Low-Defect Software](https://reader033.vdocuments.us/reader033/viewer/2022052912/55a05de21a28ab3c2e8b45b1/html5/thumbnails/120.jpg)
ALWAYS() and NEVER()
#if defined(SQLITE_COVERAGE_TEST)# define ALWAYS(X) 1# define NEVER(X) 0
#elif defined(SQLITE_DEBUG)# define ALWAYS(X) ((X)?1:sqlite3Panic())# define NEVER(X) ((X)?sqlite3Panic():0)
#else# define ALWAYS(X) (X)# define NEVER(X) (X)#endif
What you fly:ALWAYS and NEVER arepass-throughs.
![Page 121: A Lesson In Low-Defect Software](https://reader033.vdocuments.us/reader033/viewer/2022052912/55a05de21a28ab3c2e8b45b1/html5/thumbnails/121.jpg)
ALWAYS() and NEVER()
#if defined(SQLITE_COVERAGE_TEST)# define ALWAYS(X) 1# define NEVER(X) 0
#elif defined(SQLITE_DEBUG)# define ALWAYS(X) ((X)?1:sqlite3Panic())# define NEVER(X) ((X)?sqlite3Panic():0)
#else# define ALWAYS(X) (X)# define NEVER(X) (X)#endif
For test coverage measurement:Unconditional so that there are nountested branches
![Page 122: A Lesson In Low-Defect Software](https://reader033.vdocuments.us/reader033/viewer/2022052912/55a05de21a28ab3c2e8b45b1/html5/thumbnails/122.jpg)
ALWAYS() and NEVER()
#if defined(SQLITE_COVERAGE_TEST)# define ALWAYS(X) 1# define NEVER(X) 0
#elif defined(SQLITE_DEBUG)# define ALWAYS(X) ((X)?1:sqlite3Panic())# define NEVER(X) ((X)?sqlite3Panic():0)
#else# define ALWAYS(X) (X)# define NEVER(X) (X)#endif
During development:Panic if ALWAYS() is false orif NEVER() is true.
![Page 123: A Lesson In Low-Defect Software](https://reader033.vdocuments.us/reader033/viewer/2022052912/55a05de21a28ab3c2e8b45b1/html5/thumbnails/123.jpg)
Testing In
● 99% Statement Coverage● 95% Branch Coverage● Goal: 100% branch coverage by Dec 2009● Striving for 100% test coverage has been our
most effective method for finding bugs.
![Page 124: A Lesson In Low-Defect Software](https://reader033.vdocuments.us/reader033/viewer/2022052912/55a05de21a28ab3c2e8b45b1/html5/thumbnails/124.jpg)
Testing In
● “testfixture”– Written in C + TCL– Approximately 1 million test cases
● “th3”– Pure C code (for embedded platforms)– Approximately 2.3 million test cases
● “sqllogictest”– Compare SQLite against MySQL, PostgreSQL, etc– Approximately 5.8 million test cases
![Page 125: A Lesson In Low-Defect Software](https://reader033.vdocuments.us/reader033/viewer/2022052912/55a05de21a28ab3c2e8b45b1/html5/thumbnails/125.jpg)
Tcl/Tk in Google Summer of Codeslides available at http://purl.org/NET/gsoc2009
• Google Summer of Code (GSoC)– Google pay 4500USD each qualified studentfor coding for 12 weeks for approved open source project.
• Tcl/Tk – dynamic (scripting) languagealso known as “The C Library” (high quality C source code)http://www.tcl.tk (official) or http://tkosiak.blogspot.com (po polsku).
• D. Richard Hipp is Tcl Core Team Member “Emeriti” ☺• 9 / 9 students successfully completed GSoC 2008
and get paid with Tcl/Tk community(note PHP also have 9 slots in GSoC 2008)
![Page 126: A Lesson In Low-Defect Software](https://reader033.vdocuments.us/reader033/viewer/2022052912/55a05de21a28ab3c2e8b45b1/html5/thumbnails/126.jpg)
Why to apply to Tcl/Tk GSoC?• Tcl is easy to learn but very productive language.
Used in GCC/GDB, SQLite and Cisco, Intel, Mentor, IBM, Motorola …• Tcl/Tk GSoC is about coding in C and/or Tcl
and is not crowded with students applications.• 4/9 Tcl/Tk GSoC 2008 students were from Poland !!!
(please contact them about it: [email protected], [email protected], [email protected], [email protected])
• Tcl Community is known to be extremely friendly.In Poland you have local Polish speaking experts willing to help:o Tomasz Kosiak http://tkosiak.blogspot.com or http://wiki.tcl.tk/17873o Wojciech Kocjan http://kocjan.org or http://wiki.tcl.tk/3684o Paweł Salawa http://sqlitestudio.one.pl or http://wiki.tcl.tk/12959
• For more details or help contact Tomasz Kosiak ([email protected] /+48 503 021 130) who helps to organize Tcl/Tk GSoC.
![Page 127: A Lesson In Low-Defect Software](https://reader033.vdocuments.us/reader033/viewer/2022052912/55a05de21a28ab3c2e8b45b1/html5/thumbnails/127.jpg)
Testing In
● “testfixture”– Written in C + TCL– Approximately 1 million test cases
● “th3”– Pure C code (for embedded platforms)– Approximately 2.3 million test cases
● “sqllogictest”– Compare SQLite against MySQL, PostgreSQL, etc– Approximately 5.8 million test cases
![Page 128: A Lesson In Low-Defect Software](https://reader033.vdocuments.us/reader033/viewer/2022052912/55a05de21a28ab3c2e8b45b1/html5/thumbnails/128.jpg)
Testing In
Code :: Test Data1 :: 716
![Page 129: A Lesson In Low-Defect Software](https://reader033.vdocuments.us/reader033/viewer/2022052912/55a05de21a28ab3c2e8b45b1/html5/thumbnails/129.jpg)
Testing In
● Crash testing– Simulate recovery from power loss
● I/O Error and Out-of-memory testing– Recovery from system errors.
● “fuzz” testing– Test response to random inputs
● valgrind
![Page 130: A Lesson In Low-Defect Software](https://reader033.vdocuments.us/reader033/viewer/2022052912/55a05de21a28ab3c2e8b45b1/html5/thumbnails/130.jpg)
Fuzz Testing
SELECT NOT -2147483647 IN (SELECT DISTINCT 2147483649 FROM (SELECT DISTINCT EXISTS (SELECT ALL'injection' FROM (SELECT DISTINCT 1, 'experiments', 0) UNION ALL SELECT DISTINCT NULL) NOT IN(SELECT EXISTS (SELECT ALL 'fault') IN (SELECT DISTINCT 'The') IN (SELECT DISTINCT 0 ORDER BY'experiments' ASC, -2147483649 DESC)) IN (SELECT EXISTS (SELECT 'experiments') FROM (SELECTDISTINCT NULL, -2147483647)) IN (SELECT EXISTS (SELECT DISTINCT 56.1 ORDER BY -456 ASC) ORDERBY (SELECT 'first') DESC), CAST((SELECT (SELECT 0) IN (SELECT DISTINCT 'injection') IN (SELECTALL 'The') NOT IN (SELECT DISTINCT 'first' ORDER BY 2147483648 LIMIT 123456789.1234567899OFFSET 2147483648)) AS blob) FROM (SELECT 'The', -1 UNION ALL SELECT 456, CAST(56.1 AS text)ORDER BY CAST(-2147483649 AS real) ASC)))
![Page 131: A Lesson In Low-Defect Software](https://reader033.vdocuments.us/reader033/viewer/2022052912/55a05de21a28ab3c2e8b45b1/html5/thumbnails/131.jpg)
![Page 132: A Lesson In Low-Defect Software](https://reader033.vdocuments.us/reader033/viewer/2022052912/55a05de21a28ab3c2e8b45b1/html5/thumbnails/132.jpg)
Testing In
● Most bugs are found internally – before release● External bugs are mostly build problems● We do not do “alpha” or “beta” releases
– All releases are production ready● Very, very few “wrong answers” found by users
![Page 133: A Lesson In Low-Defect Software](https://reader033.vdocuments.us/reader033/viewer/2022052912/55a05de21a28ab3c2e8b45b1/html5/thumbnails/133.jpg)
4 Steps Toward Low-Defect Code
● Use your whole brain● Full coverage testing● Good configuration management● Don't just fix bugs – fix your process
![Page 134: A Lesson In Low-Defect Software](https://reader033.vdocuments.us/reader033/viewer/2022052912/55a05de21a28ab3c2e8b45b1/html5/thumbnails/134.jpg)
Configuration Management
● Identification● Access Control● Archival Storage● Reporting and Auditing● Collaboration● Defect Tracking
![Page 135: A Lesson In Low-Defect Software](https://reader033.vdocuments.us/reader033/viewer/2022052912/55a05de21a28ab3c2e8b45b1/html5/thumbnails/135.jpg)
Configuration Management
● Identification● Access Control● Archival Storage● Reporting and Auditing● Collaboration● Defect Tracking
Version Control SystemCVS, Subversion, Git, Mercurial,Monotone, Fossil, Bitkeeper,Perforce, ClearCase
![Page 136: A Lesson In Low-Defect Software](https://reader033.vdocuments.us/reader033/viewer/2022052912/55a05de21a28ab3c2e8b45b1/html5/thumbnails/136.jpg)
Configuration Management
● Identification● Access Control● Archival Storage● Reporting and Auditing● Collaboration● Defect Tracking
Various ad hoc add-ons.
![Page 137: A Lesson In Low-Defect Software](https://reader033.vdocuments.us/reader033/viewer/2022052912/55a05de21a28ab3c2e8b45b1/html5/thumbnails/137.jpg)
Configuration Management
● Identification● Access Control● Archival Storage● Reporting and Auditing● Collaboration● Defect Tracking
Very, very important yetcommonly ignored!
![Page 138: A Lesson In Low-Defect Software](https://reader033.vdocuments.us/reader033/viewer/2022052912/55a05de21a28ab3c2e8b45b1/html5/thumbnails/138.jpg)
Configuration Management
● Identification● Access Control● Archival Storage● Reporting and Auditing● Collaboration● Defect Tracking
“situational awareness”
![Page 139: A Lesson In Low-Defect Software](https://reader033.vdocuments.us/reader033/viewer/2022052912/55a05de21a28ab3c2e8b45b1/html5/thumbnails/139.jpg)
Situational Awareness
● Understanding what is happening around you● Recognizing how events and your own actions
will impact goals and objectives● Lack of situational awareness is the main cause
of human-error accidents● Important in work domains where information
flow is high and poor decisions may have serious consequences
![Page 140: A Lesson In Low-Defect Software](https://reader033.vdocuments.us/reader033/viewer/2022052912/55a05de21a28ab3c2e8b45b1/html5/thumbnails/140.jpg)
![Page 141: A Lesson In Low-Defect Software](https://reader033.vdocuments.us/reader033/viewer/2022052912/55a05de21a28ab3c2e8b45b1/html5/thumbnails/141.jpg)
Situational Awareness in CM
● What has changed last N days?● What has changed between release X and Y?● What changed in module M between dates P
and Q?● Who made the changes and why?● When and why was line of code W inserted?● When and why was subroutine U last modified?● What bugs are still outstanding?● What changes were made to address bug Z?
![Page 142: A Lesson In Low-Defect Software](https://reader033.vdocuments.us/reader033/viewer/2022052912/55a05de21a28ab3c2e8b45b1/html5/thumbnails/142.jpg)
Open-Source Reporting Systems
● CVSTrac– http://www.cvstrac.org/– CVS, Subversion, GIT
● Trac– http://trac.edgewall.org/– Subversion, GIT, Perforce, Mercurial, Darcs, Bazaar
● Fossil– http://www.fossil-scm.org/– Distributed version control with reporting built in
![Page 143: A Lesson In Low-Defect Software](https://reader033.vdocuments.us/reader033/viewer/2022052912/55a05de21a28ab3c2e8b45b1/html5/thumbnails/143.jpg)
Open-Source Reporting Systems
● CVSTrac– http://www.cvstrac.org/– CVS, Subversion, GIT
● Trac– http://trac.edgewall.org/– Subversion, GIT, Perforce, Mercurial, Darcs, Bazaar
● Fossil– http://www.fossil-scm.org/– Distributed version control with reporting built in
Used by SQLite
Essential to the success of SQLite
New projects should consider newer systems
![Page 144: A Lesson In Low-Defect Software](https://reader033.vdocuments.us/reader033/viewer/2022052912/55a05de21a28ab3c2e8b45b1/html5/thumbnails/144.jpg)
![Page 145: A Lesson In Low-Defect Software](https://reader033.vdocuments.us/reader033/viewer/2022052912/55a05de21a28ab3c2e8b45b1/html5/thumbnails/145.jpg)
![Page 146: A Lesson In Low-Defect Software](https://reader033.vdocuments.us/reader033/viewer/2022052912/55a05de21a28ab3c2e8b45b1/html5/thumbnails/146.jpg)
![Page 147: A Lesson In Low-Defect Software](https://reader033.vdocuments.us/reader033/viewer/2022052912/55a05de21a28ab3c2e8b45b1/html5/thumbnails/147.jpg)
Are you already using a version control system?
Good! Be sure to add reporting and auditing software.Maintain situational awareness!
Are you not currently using a version control?
● Go to http://www.fossil-scm.org/● Download a pre-compiled binary for fossil● Start using it!
![Page 148: A Lesson In Low-Defect Software](https://reader033.vdocuments.us/reader033/viewer/2022052912/55a05de21a28ab3c2e8b45b1/html5/thumbnails/148.jpg)
![Page 149: A Lesson In Low-Defect Software](https://reader033.vdocuments.us/reader033/viewer/2022052912/55a05de21a28ab3c2e8b45b1/html5/thumbnails/149.jpg)
![Page 150: A Lesson In Low-Defect Software](https://reader033.vdocuments.us/reader033/viewer/2022052912/55a05de21a28ab3c2e8b45b1/html5/thumbnails/150.jpg)
![Page 151: A Lesson In Low-Defect Software](https://reader033.vdocuments.us/reader033/viewer/2022052912/55a05de21a28ab3c2e8b45b1/html5/thumbnails/151.jpg)
4 Steps Toward Low-Defect Code
● Use your whole brain● Full coverage testing● Good configuration management● Don't just fix bugs – fix your process
![Page 152: A Lesson In Low-Defect Software](https://reader033.vdocuments.us/reader033/viewer/2022052912/55a05de21a28ab3c2e8b45b1/html5/thumbnails/152.jpg)
When you find a bug....
● Add a test case that demonstrates the bug– Prevents the bug from recurring
● Ask: “Are there any similar bugs elsewhere in the code?”– Find and fix them too – adding new test cases
● Ask: “What tests or development procedures might have prevented this bug?”– Implement your answers
![Page 153: A Lesson In Low-Defect Software](https://reader033.vdocuments.us/reader033/viewer/2022052912/55a05de21a28ab3c2e8b45b1/html5/thumbnails/153.jpg)
When you find a bug....
● Ask: “What is the root cause of this bug?”– Fix the root cause, not the specific manifestation
● Ask: “What can be done to prevent future occurrences of similar bugs?”– Implement your answers
![Page 154: A Lesson In Low-Defect Software](https://reader033.vdocuments.us/reader033/viewer/2022052912/55a05de21a28ab3c2e8b45b1/html5/thumbnails/154.jpg)
Summary
● Use your whole brain– Good comments and documentation reduce defects
● Full coverage testing– If it is not tested, it does not work– Fly what you test and test what you fly
● Good configuration management– Maintain Situational Awareness
● Don't just fix bugs – fix your process