horst zuse software complexity - gbv

8
Horst Zuse Software Complexity Measures and Methods ff 8i';-iBSM ad»!!!Ä)8l t) \\ uenemiL // w DE G Walter de Gruyter Berlin-New York 1991

Upload: others

Post on 02-Apr-2022

2 views

Category:

Documents


0 download

TRANSCRIPT

Horst Zuse

Software Complexity Measures and Methods

ff 8i';-iBSM ad»!!!Ä)8l t) \ \ uenemiL / /

w DE

G Walter de Gruyter Berlin-New York 1991

Contents

1 Introduction 1

2 Problems in Evaluating the Complexity of Programs 7

2.1 Difficulties in Interpreting the Results of Software Complexity Measu­rement 7

2.2 Problems in Interpreting Numerical Values 21

2.3 Problems in Determining the Complexity of Programs 22

2.4 Problems in Calculating the Arithmetic Mean 22

2.5 Problems in Selecting Appropriate Software Complexity Measures . . . . 23

3 Discussion about Software Measurement and Measures 25

3.1 What is Software Measurement? 25

3.2 An Overview of Software Measurement 27

3.3 What are Software Metrics/Measures? 28

3.3.1 The Difference of Measure and Metric 28

3.3.2 Term Software Measure 29

3.4 Classification of Software Complexity Measures 31

3.4.1 Computational and Psychological Complexity 31

3.4.2 Basili's Classification of Complexity Measures . . . 32

3.4.3 Sherif's Classification of Software Measures 32

3.4.4 Fenton's and Kaposi's Classification of Software Measures . . . . 32

3.4.5 Program Change-Measures 33

3.4.6 GMD's Classification 33

3.4.7 Sheppard's Classification of Software Complexity Measures . . . . 33

3.4.8 METKITs Classification of Software Measures 34

3.5 Verbal Definitions of the Term Complexity 34

3.6 Limits to the Values of Software Measures 35

3.7 Remarks About Measures in Relationship to Measurement Theory

and Scales 36

3.8 Summary 37

4 Measurement Theory and Criteria for Scales 39

4.1 The Definition of the Empirical Relational System and the Formal Rela­tional System 40 4.1.1 The Difference Between the Measurement of the Length of

Wooden Boards and the Complexity of Software 41

4.2 The Definition of Scales and Meaningfulness 42

4.2.1 Examples of Scale Types 43

4.2.2 Examples of Meaningfulness 45

4.3 Criteria for Ordinal and Ratio Scales 46

X Contents

4.3.1 Weak Order and Ordinal Scale 47

4.3.1.1 The Empirical Relation "Equal or More Complex Than" 49

4.3.2 Extensive Structure and the Ratio Scale 49

4.4 Description of Measures as an Ordinal and Ratio Scale 51

4.4.1 Empirical Subrelation 51

4.4.2 Atomic Modification 51

4.4.3 Partial Property of a Measure 52

4.4.4 Property s of a Measure 54

4.4.5 Empirical Subrelation of a Measure 54

4.4.6 The Choice of an Appropriate Software Complexity Measure . . . 55

4.4.7 Partial and Complete Description of the Property s of a

Measure 56

4.4.7.1 Partial Description of the Property s of a Measure . . . 56

4.4.7.2 Complete Description of the Property s of a

Measure 56

4.4.8 Summary of Partial Properties and Atomic Modifications 56

4.4.9 Modified Axioms of the Extensive Structure 57

4.4.10 Binary Operations between Programs 58

4.5 Characterization of the Measure of McCabe 62

4.5.1 The Measure of McCabe as an Ordinal Scale 62

4.5.2 The Measure of McCabe as a Ratio Scale 64

4.6 Summary 65

5 Models of Programs and their Definitions 67

5.1 Definitions of Control Flowgraphs 67

5.2 Definitions of Subflowgraphs and Primes 72

5.3 Definitions and Notation for Decomposition of Flowgraphs, Sequence

and Nesting 77

5.4 Definitions of Structuredness of Flowgraphs 78

5.4.1 D-Structures 79

5.4.2 D'-Structures 80

5.4.3 BJn-Structures 81

5.5 Definition of Intervals and Reducibility 81

5.6 Definition of Loops 82

5.7 Definition of Unstructuredness of Flowgraphs 82

5.8 Notations Used in this Book 84

6 Ideas Behind the Complexity of Programs 87

Contents XI

6.1 Desirable Properties of Measures by Tsai, Lopez, Rodriguez and Vo-lovik 87

6.2 Desirable Properties of Measures by Evangelisti 88

6.3 Ideas of Complexity by McCabe 89

6.4 Ideas of Complexity by Belady 89

6.5 Axioms of Complexity by Piwowarski 89

6.6 Axioms of Complexity by Bache 90

6.7 Desireable Properties of Complexity Measures by Weyuker 92

6.8 Required Properties for Measures by Jayaprakash, Lakshmanan,

Sinha 96

6.9 Summary 98

7 Our Investigation of Software Complexity Measures 99

7.1 Overview of our Investigation of the Measures 99

7.2 The "Measure Demonstration System" MDS 100

7.2.1 Measures Implemented in MDS and Treated in this Book . . . . 102

7.2.2 Representation of Flowgraphs in MDS 103

7.2.3 Nested Flowgraphs for the Investigation of the Measures . . . . 103

7.2.4 Interpreting the Numbers of Measurement 106

7.2.4.1 Interpreting Numbers for the Measure MCC-V with MDS 108

7.2.4.2 Interpreting Numbers for the Measure MCC-V-Q with MDS 109

7.2.4.3 Interpreting Numbers for the Measure MCC-V2 with MDS 110

7.2.4.4 Interpreting Numbers for the Measure LOC with MDS 112

7.2.4.5 Interpreting Numbers for the Measure ALPHA with MDS 113

7.2.4.6 Interpreting Numbers for the Measure BAND with

MDS 114

7.2.5 Selection of Measures with MDS 115

7.2.6 Examples and Counterexamples for the Extensive Structure 115

7.2.6.1 Axiom of Associativity 116

7.2.6.2 Axiom of Commutativity 117

7.2.6.3 Axiom of Monotonicity 118

7.2.6.4 Archimedian Axiom 120

7.3 Atomic Modifications, Partial Properties and the Ordinal Scale 120

7.4 Extensive Structure and Binary Operations between Programs 127

XII Contents

7.5 Conditions for the Use of Measures as an Ordinal and a Ratio Scale in Practice 128

7.5.1 Conditions for the Use of the Measures MCC-V, C2 and MCC-V2 as an Ordinal and a Ratio Scale 130

7.6 Summary 131

8 Characterization of Software Complexity Measures 133

8.1 Selection of the Software Complexity Measures 138

8.1.1 Software Complexity Measures not treated in this Book 138

8.2 Measures of Halstead 142

8.3 Measure Lines of Code 146

8.4 Measures of McCabe and Modifications 151

8.4.1 Explanations by McCabe 152

8.4.2 Examples of the Measures 153

8.4.3 Cyclomatic Number of a Graph and a Flowgraph 154

8.4.4 Comments from the Literature 159

8.4.5 Discussion of the Measures of McCabe 161

8.4.6 Extensive Structure and Ratio Scale 165

8.4.7 Final Remarks 167

8.5 Measures "Relative and Absolute Logical Complexity" of Gilb 170

8.6 Measure "Control Flow Density" of Szentes and Potier 176

8.7 Measures of Szentes and Gras 179

8.8 Measure of Oviedo 195

8.9 Measure PATH of Schneidewind 200

8.10 Measures of Whitworth and Szulewski 206

8.11 Measures of Hecht and Extensions 221

8.12 Measure of Moawad and Hassan and Extensions 234

8.13 Measures "Reachability" of Schneidewind 242

8.14 Measures of Chen 250

8.14.1 Measure Maximal Intersection Number (MIN) 251

8.14.2 Measure Z 252

8.14.3 Measure Z' 252

8.14.4 Discussion of the Measures 253

8.14.4.1 Revised and Improved Definition of the Measure MIN

by the Author 254

8.14.5 Examples 255

8.14.6 Discussion of the Measures 260

8.14.7 Extensive Structure and Ratio Scale 262

8.14.8 Final Remarks 263

Contents XIII

8.15 Measures Based on the Prime Decomposition of Flowgraphs 265

8.15.1 Measures of Dunsmore and Gannon 269

8.15.2 Measure of Prather 281

8.15.3 Measures of the Project "Structured-Based Software Measure­ment" 296 8.15.3.1 Structural Measures Based on the Fenton-Whitty

Scheme 297

8.15.3.2 Definition of Structural Measures 299

8.15.3.3 The Axioms of Structure 300

8.15.3.4 Assigning of Values to Primes 301

8.15.3.5 The Measures VINAP-PD and VINAP-SUM 301

8.15.3.6 New Primes 302

8.15.3.7 Examples 303

8.15.3.8 Explanations by Bache and Fenton 309

8.15.3.9 Discussion of the Measures 309

8.15.3.10 Extensive Structure and Ratio Scale 314

8.15.3.11 Final Remarks 318

8.15.4 Measures of Fenton and Kaposi 320

8.15.5 Measures of Preiserand Storm 330

8.15.6 Measures of Ejiogu 333

8.15.7 Measures of Blaschek 345

8.15.8 Measures of Belady 362

8.16 Measure of Schmidt and Gong and Extensions 374

8.17 Measures Based on Ranges 400

8.17.1 Introduction 400

8.17.1.1 Dominators 400

8.17.1.2 First Occurrence Path 401

8.17.1.3 Lower Bound and Greatest Lower Bound 403

8.17.1.4 Ranges and Scopes 404

8.17.1.5 Nesting Level of Nodes 410

8.17.2 Measures of Harrison and Magel 413

8.17.2.1 Measure SCOPE 413

8.17.2.2 Measure SCOPE and Extensions as Defined by Ho-

watt and Baker 414

8.17.2.3 Comments from the Literature 416

8.17.2.4 Examples 416

8.17.2.5 Discussion of the Measures 425

8.17.2.6 Extensive Structure and Ratio Scale 429

XIV Contents

8.17.2.7 Final Remarks 430

8.17.3 Measures of Howatt and Baker 433

8.17.3.1 Remarks by Howatt and Baker 436

8.17.3.2 Comments by the Author 436

8.17.3.3 Examples for the Measures SCOPE, PEN and AVG . . 437

8.17.3.4 Examples for the Measure NL 441

8.17.3.5 Discussion of the Measures 450

8.17.3.6 Extensive Structure and Ratio Scale 454

8.17.3.7 Final Remarks 456

8.18 Measures for Analyzing the Unstructuredness of Flowgraphs 458

8.18.1 Measure of Woodward, Hennell and Hedley 459

8.18.2 Measure of Piwowarski and Extensions 464

8.18.2.1 Comments to the Definition of the Measure by the

Author 465

8.18.2.2 Entry-Node of a Range 469

8.18.2.3 Structuredness and Unstructuredness of Pairs of Ranges 470

8.18.2.4 Definition of the Measure of Piwowarski by the

Author 471

8.18.2.5 Examples 472

8.18.2.6 Definition of the Measure of Piwowarski by Howatt

and Baker 482

8.18.2.7 Discussion of the Measures of Piwowarski 483

8.18.2.8 Extensive Structure and Ratio Scale 486

8.18.2.9 Final Remarks 487

8.18.3 Measures for Unstructuredness of Howatt and Baker and Ex­

tensions 490

9 Results and Research in the Future 511

9.1 List of the Investigated Measures 511

9.2 Partial Properties of the Measures 512

9.2.1 Partial Properties of the Measures of McCabe and Extensions 513

9.2.2 Partial Properties of the Measures of Szentes and Gras 514

9.2.3 Partial Properties of the Measures of Hecht and Moawad . . . . 515

9.2.4 Partial Properties of the Measures of Schneidewind 515

9.2.5 Partial Properties of the Measures of Chen 516

9.2.6 Partial Properties of Measures Based on Primes 517

9.2.7 Partial Properties of the Measures of Blaschek and Ejiogu . . . . 518

9.2.8 Partial Properties of the Measures of Belady 519

Contents XV

9.2.9 Partial Properties of the Measures of Schmidt and Gong . . . . 519

9.2.10 Partial Properties of Measures Based on Ranges 520

9.2.11 Partial Properties of the Measures for Unstructuredness . . . . 521

9.2.12 List of the Measures and the Partial Properties 522

9.2.13 Complete List of the Atomic Modifications 523

9.2.14 Classification of Measures by Partial Properties 529

9.2.15 Summary 530

9.3 Properties of Measures Related to the Extensive Structure 531

9.3.1 Overview of the Properties of the Measures to Extensive

Structure 531

9.3.2 Axiom of Weak Associativity for the Binary Operation BALT . . . 534

9.3.3 Sensitivity of Measures to adding Statements 536

9.4 Set of Measures to Measure the Intra-Modular Complexity 538

9.4.1 Normalized Measures and such with Unclear Properties 538

9.4.2 Criteria for the Selection of Appropriate Measures 539

9.4.3 Set of Measures to Analyze the Program Complexity 542

9.4.4 Standardized Software Complexity Measures 545

9.4.5 Minimal Set of Standardized Software Complexity Measures . . 551

9.5 Measurement Process of Restructure and Software Reuse 551

9.6 Wrong and Correct Calculation of the Arithmetic Mean 557 9.7 Complexity in Comparison to Reference Programs and Program Ver­

sions 558

9.8 Validation of a Measure 560

9.9 Correlation between Software Complexity Measures 562

9.10 Open Problemsand Research in the Future 563

10 Glossary of Terms 565

11 References 573