Page 43 - The Art of Designing Embedded Systems
P. 43

30  THE ART OF  DESIGNING EMBEDDED SYSTEMS























           FIGURE 2-5  A personal bug log.


                Identify Bad Code
                Barry Boehm found that typically 80% of the defects in a program
           are in 20% of the modules. IBM’s numbers showed that 57% of the bugs
           are in 7% of  modules. Weinberg’s numbers are even more compelling:
           80% of the defects are in 2% of the modules.
                In other words, most of  the bugs will be in a few modules orfinc-
           tions. These academic studies confirm our common sense. How many
           times have you tried to beat a function into submission, fixing bug after
           bug after bug, convinced that this one is (you hope!) the last?
                We’ve all also had that awful function that just simply stinks. It’s
           ugly. The one that makes you slightly nauseous every time you open it. A
           decent Code Inspection will detect most of these poorly crafted beasts, but
           if one slips through, we have to take some action.
                Make identifying bad code a priority. Then trash those modules and
           start over.
                It sure would be nice to have the chance to write every program twice:
           the first time to gain a deep understanding of the problem; the second to do
           it right. Reality’s ugly hand means that’s not an option. But the bad code,
           the code where we spend far too much time debugging, needs to be excised
           and redone. The data suggests we’re talking about recoding only around 5%
           of the functions-not  a bad price to pay in the pursuit of quality.
                Boehm’s studies show that these problem modules cost, on average,
           four times as much as any other module. So, if we identify these modules
           (by tracking bug rates), we can rewrite them twice and still come out ahead!
   38   39   40   41   42   43   44   45   46   47   48