1 software engineering: a practitioner’s approach, 6/e chapter 15b: product metrics for software...

13
1 Software Engineering: A Practitioner’s Approach, 6/e Software Engineering: A Practitioner’s Approach, 6/e Chapter 15b: Chapter 15b: Product Metrics for Product Metrics for Software Software copyright © 1996, 2001, 2005 R.S. Pressman & Associates, Inc. For University Use Only May be reproduced ONLY for student use at the university level when used in conjunction with Software Engineering: A Practitioner's Approach. Any other reproduction or use is expressly prohibited.

Upload: clare-hoover

Post on 16-Jan-2016

212 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: 1 Software Engineering: A Practitioner’s Approach, 6/e Chapter 15b: Product Metrics for Software Software Engineering: A Practitioner’s Approach, 6/e Chapter

1

Software Engineering: A Practitioner’s Software Engineering: A Practitioner’s Approach, 6/eApproach, 6/e

Chapter 15b:Chapter 15b:Product Metrics for SoftwareProduct Metrics for Software

copyright © 1996, 2001, 2005

R.S. Pressman & Associates, Inc.

For University Use OnlyMay be reproduced ONLY for student use at the university level

when used in conjunction with Software Engineering: A Practitioner's Approach.Any other reproduction or use is expressly prohibited.

Page 2: 1 Software Engineering: A Practitioner’s Approach, 6/e Chapter 15b: Product Metrics for Software Software Engineering: A Practitioner’s Approach, 6/e Chapter

2

Architectural Design MetricsArchitectural Design Metrics

Architectural design metricsArchitectural design metrics Structural complexity = g(fan-out)Structural complexity = g(fan-out) Data complexity = f(input & output variables, fan-out)Data complexity = f(input & output variables, fan-out) System complexity = h(structural & data complexity) System complexity = h(structural & data complexity)

HK metric:HK metric: architectural complexity as a function architectural complexity as a function of fan-in and fan-outof fan-in and fan-out

Morphology metrics:Morphology metrics: a function of the number of a function of the number of modules and the number of interfaces between modules and the number of interfaces between modulesmodules

Page 3: 1 Software Engineering: A Practitioner’s Approach, 6/e Chapter 15b: Product Metrics for Software Software Engineering: A Practitioner’s Approach, 6/e Chapter

3

Metrics for OO Design-IMetrics for OO Design-I Whitmire [WHI97] describes nine distinct and measurable Whitmire [WHI97] describes nine distinct and measurable

characteristics of an OO design:characteristics of an OO design: SizeSize

Size is defined in terms of four views: population, volume, length, and Size is defined in terms of four views: population, volume, length, and functionalityfunctionality

ComplexityComplexity How classes of an OO design are interrelated to one anotherHow classes of an OO design are interrelated to one another

CouplingCoupling The physical connections between elements of the OO designThe physical connections between elements of the OO design

SufficiencySufficiency ““the degree to which an abstraction possesses the features required of it, the degree to which an abstraction possesses the features required of it,

or the degree to which a design component possesses features in its or the degree to which a design component possesses features in its abstraction, from the point of view of the current application.”abstraction, from the point of view of the current application.”

CompletenessCompleteness An indirect implication about the degree to which the abstraction or An indirect implication about the degree to which the abstraction or

design component can be reuseddesign component can be reused

Page 4: 1 Software Engineering: A Practitioner’s Approach, 6/e Chapter 15b: Product Metrics for Software Software Engineering: A Practitioner’s Approach, 6/e Chapter

4

Metrics for OO Design-IIMetrics for OO Design-II

CohesionCohesion The degree to which all operations working together to The degree to which all operations working together to

achieve a single, well-defined purposeachieve a single, well-defined purpose PrimitivenessPrimitiveness

Applied to both operations and classes, the degree to Applied to both operations and classes, the degree to which an operation is atomicwhich an operation is atomic

SimilaritySimilarity The degree to which two or more classes are similar in The degree to which two or more classes are similar in

terms of their structure, function, behavior, or purposeterms of their structure, function, behavior, or purpose VolatilityVolatility

Measures the likelihood that a change will occurMeasures the likelihood that a change will occur

Page 5: 1 Software Engineering: A Practitioner’s Approach, 6/e Chapter 15b: Product Metrics for Software Software Engineering: A Practitioner’s Approach, 6/e Chapter

5

Distinguishing Distinguishing CharacteristicsCharacteristics

Localization—the way in which information is concentrated in a Localization—the way in which information is concentrated in a programprogram

Encapsulation—the packaging of data and processingEncapsulation—the packaging of data and processing Information hiding—the way in which information about Information hiding—the way in which information about

operational details is hidden by a secure interfaceoperational details is hidden by a secure interface Inheritance—the manner in which the responsibilities of one Inheritance—the manner in which the responsibilities of one

class are propagated to anotherclass are propagated to another Abstraction—the mechanism that allows a design to focus on Abstraction—the mechanism that allows a design to focus on

essential detailsessential details

Berard [BER95] argues that the following characteristics require that special OO metrics be developed:

Page 6: 1 Software Engineering: A Practitioner’s Approach, 6/e Chapter 15b: Product Metrics for Software Software Engineering: A Practitioner’s Approach, 6/e Chapter

6

Class-Oriented Class-Oriented MetricsMetrics

weighted methods per classweighted methods per class depth of the inheritance treedepth of the inheritance tree number of childrennumber of children coupling between object classescoupling between object classes response for a classresponse for a class lack of cohesion in methodslack of cohesion in methods

Proposed by Chidamber and KemererProposed by Chidamber and Kemerer::

Page 7: 1 Software Engineering: A Practitioner’s Approach, 6/e Chapter 15b: Product Metrics for Software Software Engineering: A Practitioner’s Approach, 6/e Chapter

7

Class-Oriented Class-Oriented MetricsMetrics

class sizeclass size number of operations overridden by a number of operations overridden by a

subclasssubclass number of operations added by a subclassnumber of operations added by a subclass specialization indexspecialization index

Proposed by Lorenz and Kidd [LOR94]:Proposed by Lorenz and Kidd [LOR94]:

Page 8: 1 Software Engineering: A Practitioner’s Approach, 6/e Chapter 15b: Product Metrics for Software Software Engineering: A Practitioner’s Approach, 6/e Chapter

8

Class-Oriented MetricsClass-Oriented Metrics

Method inheritance factorMethod inheritance factor Coupling factorCoupling factor Polymorphism factorPolymorphism factor

The MOOD Metrics SuiteThe MOOD Metrics Suite

Page 9: 1 Software Engineering: A Practitioner’s Approach, 6/e Chapter 15b: Product Metrics for Software Software Engineering: A Practitioner’s Approach, 6/e Chapter

9

Operation-Oriented Operation-Oriented MetricsMetrics

average operation sizeaverage operation size operation complexityoperation complexity average number of parameters per average number of parameters per

operationoperation

Proposed by Lorenz and Kidd [LOR94]:Proposed by Lorenz and Kidd [LOR94]:

Page 10: 1 Software Engineering: A Practitioner’s Approach, 6/e Chapter 15b: Product Metrics for Software Software Engineering: A Practitioner’s Approach, 6/e Chapter

10

Component-Level Design Component-Level Design MetricsMetrics

Cohesion metrics:Cohesion metrics: a function of data objects and a function of data objects and the locus of their definitionthe locus of their definition

Coupling metrics:Coupling metrics: a function of input and output a function of input and output parameters, global variables, and modules calledparameters, global variables, and modules called

Complexity metrics:Complexity metrics: hundreds have been hundreds have been proposed (e.g., cyclomatic complexity)proposed (e.g., cyclomatic complexity)

Page 11: 1 Software Engineering: A Practitioner’s Approach, 6/e Chapter 15b: Product Metrics for Software Software Engineering: A Practitioner’s Approach, 6/e Chapter

11

Interface Design MetricsInterface Design Metrics

Layout appropriateness:Layout appropriateness: a function of layout a function of layout entities, the geographic position and the “cost” entities, the geographic position and the “cost” of making transitions among entitiesof making transitions among entities

Page 12: 1 Software Engineering: A Practitioner’s Approach, 6/e Chapter 15b: Product Metrics for Software Software Engineering: A Practitioner’s Approach, 6/e Chapter

12

Code MetricsCode Metrics

Halstead’s Software Science:Halstead’s Software Science: a comprehensive a comprehensive collection of metrics all predicated on the collection of metrics all predicated on the number (count and occurrence) of operators and number (count and occurrence) of operators and operands within a component or programoperands within a component or program It should be noted that Halstead’s “laws” have It should be noted that Halstead’s “laws” have

generated substantial controversy, and many believe generated substantial controversy, and many believe that the underlying theory has flaws. However, that the underlying theory has flaws. However, experimental verification for selected programming experimental verification for selected programming languages has been performed (e.g. [FEL89]).languages has been performed (e.g. [FEL89]).

Page 13: 1 Software Engineering: A Practitioner’s Approach, 6/e Chapter 15b: Product Metrics for Software Software Engineering: A Practitioner’s Approach, 6/e Chapter

13

Metrics for TestingMetrics for Testing

Testing effort can also be estimated using Testing effort can also be estimated using metrics derived from Halstead measuresmetrics derived from Halstead measures

Binder [BIN94] suggests a broad array of design Binder [BIN94] suggests a broad array of design metrics that have a direct influence on the metrics that have a direct influence on the “testability” of an OO system. “testability” of an OO system. Lack of cohesion in methods (LCOM). Lack of cohesion in methods (LCOM). Percent public and protected (PAP). Percent public and protected (PAP). Public access to data members (PAD). Public access to data members (PAD). Number of root classes (NOR). Number of root classes (NOR). Fan-in (FIN). Fan-in (FIN). Number of children (NOC) and depth of the inheritance Number of children (NOC) and depth of the inheritance

tree (DIT).tree (DIT).