ASSESSING THE MAINTAINABILITY OF C++ SOURCE CODE By MARIUS SUNDBAKKEN A thesis submitted in partial fulfillment of the requirements for the degree of Master of Science in Computer Science WASHINGTON STATE UNIVERSITY School of Electrical Engineering and Computer Science DECEMBER 2001 To the Faculty of Washington State University: The members of the Committee appointed to examine the thesis of MARIUS SUNDBAKKEN find it satisfactory and recommend that it be accepted. Chair ii ASSESSING THE MAINTAINABILITY OF C++ SOURCE CODE Abstract by Marius Sundbakken, M.S. Washington State University December 2001 Chair: David Bakken Maintenance refers to the modifications made to software systems after their first release. It is not possible to develop a significant software system that does not need maintenance because change, and hence maintenance, is an inherent characteristic of software systems. It has been estimated that it costs 80% more to maintain software than to develop it. Clearly, maintenance is the major expense in the lifetime of a software product. Predicting the maintenance effort is therefore vital for cost-effective design and development. Automated techniques that can quantify the maintainability of object- oriented designs would be very useful. Models based on metrics for object-oriented source code are necessary to assess software quality and predict engineering effort. This thesis will look at C++, one of the most widely used object-oriented programming languages in academia and industry today. Metrics based models that assess the maintainability of the source code using object-oriented software metrics are developed. iii Table of Contents 1. Introduction .................................................................................................................1 1.1. Maintenance and Maintainability........................................................................ 1 1.2. Analyzing C Source Code................................................................................... 2 1.3. Problems Addressed............................................................................................ 2 1.4. Outline................................................................................................................. 5 2. Related Work............................................................................................................... 6 2.1. Object-Oriented Concepts................................................................................... 6 2.2. Principles of Object-Oriented Design ................................................................. 8 2.2.1. The Open Closed Principle (OCP).............................................................. 9 2.2.2. The Liskov Substitution Principle (LSP) ..................................................10 2.2.3. The Dependency Inversion Principle (DIP).............................................. 11 2.2.4. The Interface Segregation Principle (ISP) ................................................ 14 2.3. Object-Oriented Metrics.................................................................................... 15 2.4. Difficulty Gathering Metrics............................................................................. 17 2.4.1. Tools.......................................................................................................... 17 2.5. Object-Oriented Programming Languages........................................................ 19 2.6. Assessing Maintainability of Object-Oriented Code ........................................ 20 2.6.1. Inheritance................................................................................................. 22 2.6.2. Encapsulation ............................................................................................ 27 2.6.3. Polymorphism ...........................................................................................29 3. Gathering Object-Oriented Metrics........................................................................... 32 3.1. Conceptual Source Code Module...................................................................... 32 iv 3.1.1. Concept and Design .................................................................................. 33 3.1.2. The Code Module...................................................................................... 34 3.2. Functionality in m2 ...........................................................................................36 3.3. Metrics gathered................................................................................................ 36 3.4. Introducing m3.................................................................................................. 44 3.4.1. Changes ..................................................................................................... 45 3.4.2. Sets ............................................................................................................ 53 3.5. Object-Oriented Metrics Gathered.................................................................... 54 3.6. mvt..................................................................................................................... 71 3.7. mmf ...................................................................................................................72 4. Developing Maintainability Index Candidate Models .............................................. 73 4.1. Source Code Sample Set ................................................................................... 74 4.2. Evaluations of the Sample Sets ......................................................................... 75 4.3. Establishing Maintainability of the Sample Set ................................................ 81 4.4. Metrics Analysis................................................................................................ 81 4.5. Maintainability Index Candidate Models.......................................................... 84 4.5.1. Single-Metric Models................................................................................ 84 4.5.2. Two-Metric Models................................................................................. 113 4.5.3. Three-Metric Models............................................................................... 119 Five-Metric Model .................................................................................................. 123 5. Summary ................................................................................................................. 124 5.1. Conclusions ..................................................................................................... 124 5.2. Further Work................................................................................................... 126 v Bibliography.................................................................................................................... 129 References ....................................................................................................................... 135 Appendix ......................................................................................................................... 136 A. Abbrevations ....................................................................................................... 136 B. Compatibility.......................................................................................................138 C. Survey.................................................................................................................. 139 D. Output Format ..................................................................................................... 144 E. Principal Component Analysis Results............................................................... 146 vi List of Tables Table 1 Recommended metrics......................................................................................... 16 Table 2 Source code static analyzers................................................................................. 18 Table 3 Metrics in m2 ....................................................................................................... 36 Table 4 Source code for object.h, string.h and unicode.h. ................................................ 48 Table 5 Metrics added....................................................................................................... 54 Table 6 Analysis #1 for total lines of code for objects...................................................... 85 Table 7 Analysis #2 for total lines of code for objects...................................................... 85 Table 8 Analysis #1 for average lines of code for objects. ............................................... 87 Table 9 Analysis #2 for average lines of code for objects. ............................................... 87 Table 10 Analysis #1 for comment lines for objects......................................................... 89 Table 11 Analysis #2 for comment lines for objects......................................................... 89 Table 12 Analysis #1 for average comment lines for objects. .......................................... 91 Table 13 Analysis #2 for average comment lines for objects. .......................................... 91 Table 14 Analysis #1 for number of methods added. ....................................................... 93 Table 15 Analysis #2 for number of methods added. ....................................................... 93 Table 16 Analysis #1 for member
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages158 Page
-
File Size-