Presentation is loading. Please wait.

Presentation is loading. Please wait.

Software Metrics.

Similar presentations


Presentation on theme: "Software Metrics."— Presentation transcript:

1 Software Metrics

2 Software Metrics White Box Metrics LOC Halstead’s Software Science
McCabe’s Cyclomatic Complexity

3 White Box Metrics White Box Metrics Linguistic: Structural: Hybrid:
LOC Halstead’s Software Science Structural: McCabe’s Cyclomatic Complexity Information Flow Metric Hybrid: Syntactic Interconnection

4 Types of White Box Metrics
-Linguistic Metrics: measuring the properties of program/specification text without interpretation or ordering of the components. -Structural Metrics: based on structural relations between objects in program; usually based on properties of control/data flowgraphs [e.g. number of nodes, links, nesting depth], fan-ins and fan-outs of procedures, etc. -Hybrid Metrics: based on combination (or on a function) of linguistic and structural properties of a program.

5 Linguistic Metrics Lines of code/statements (LOC)
perhaps the simplest: count the number of lines of code (LOC) and use as a measure of program complexity. Simple to use: if errors occur at 2% per line, a 5000 line program should have about 100 errors.

6 LOC examples of use include: productivity KLOC/person-month
quality faults/KLOC cost $$/KLOC Documentation doc_pages/KLOC

7 LOC Various studies indicate:
error rates ranging from 0.04% to 7% when measured against statement counts; LOC is as good as other metrics for small programs LOC is optimistic for bigger programs. LOC appears to be rather linear for small programs (<100 lines), but increases non-linearity with program size. Correlates well with maintenance costs Usually better than simple guesses or nothing at all.

8 A basic overview: based on two easily obtained program parameters:
the number of distinct operators in program the number of distinct operands in program paired operators such as: "begin...end", "repeat...until“ are usually treated as a single operator. the program length is defined by: define the following: N1 = total count of all operators in program. N2 = total count of all operands in program.

9 then the actual Halstead length is given as:
[usually accepted as more appropriate] which is basically a static count of the number of tokens in program. the vocabulary of a program is defined as the sum of the number distinct operands and operators :

10 Example of program length
= 9 (if, <, =,- (sign), while, 1 if (y < 0) pow = - y; else pow = y; z = 1.0; while (pow != 0) { z = z * x; pow = pow - 1; } z = 1.0 / z; ! =, *, - (minus), /) n = 7 (y, 0, pow, z, x, 1, 1.0) 2 H = 9 log 9 + 7 log 7 48 2 2

11 Example of program length
= 9 (for, =, <, + +, -, +, [], >, if) 1 n = 7 (j, 1, N, last, k, list, temp) for ( j=1; j<N; j++) { last = N - j + 1; for (k=1; k <last; k ++) { if (list[k] > list[k+1]) { temp = list[k]; list[k] = list[k+1]; list[k+1] = temp; } 2 H = 9 log 9 + 7 log 7 48 2 2

12 Halstead’s bug prediction

13

14 Exercise : Program Effort
14 Known weaknesses: Exercise : Program Effort call depth not taken into account a program with a sequence 10 successive calls more complex than one with 10 nested calls An if-then-else sequence given same weight as a loop structure. added complexity issues of nesting if-then-else or loops not taken into account, etc.


Download ppt "Software Metrics."

Similar presentations


Ads by Google