Module 4-Metric For Design Model
Module 4-Metric For Design Model
• Class-Oriented Metrics
• These metrics are black box in the sense that they do not require any knowledge of the
inner workings of a particular software component.
• Structural complexity
• Data complexity
• System complexity
Architectural Design Metrics Cont’d
Structural Complexity
• Measures of structural complexity are internal attributes i.e., they are specific to the
software code artifact.
• where v(i) is the number of input and output variables that are passed to
and from module i.
Architectural Design Metrics Cont’d
System complexity
• This leads to a greater likelihood that integration and testing effort will
also increase.
Architectural Design Metrics Cont’d
Henry-Kafura Metric (HKM)
• An earlier high-level architectural design metric proposed by Henry and
Kafura also makes use the fan-in and fan-out.
• A high value for fan-in means that X is tightly coupled to the rest of the design and
alters to X will have extensive knock-on effects.
• A high value for fan-out suggests that the overall difficulty of X may be high because of
the difficulty of the control logic required to coordinate the called components.
Architectural Design Metrics Cont’d
Henry-Kafura Metric (HKM) Cont’d
where length(i) is the number of programming language statements in a module i and fin(i)
is the fan-in of a module i.
To compute HKM during design, the procedural design may be used to estimate the number
of programming language statements for module.
Architectural Design Metrics Cont’d
Morphology Metrics
• Fenton suggests a number of simple morphology (i.e., shape) metrics that
enable different program architectures to be compared using a set of
straightforward dimensions.
Size = n + a
where n is the number of nodes and a is the number of arcs.
Architectural Design Metrics Cont’d
Morphology Metrics Example
Size = 17 +18 = 35
Depth longest path from the root (top) node to a leaf node. Depth 4.
Width maximum number of nodes at any one level of the architecture. Width =6.
The arc-to-node ratio, r = a/n, measures the connectivity density of the architecture and may provide a
simple indication of the coupling of the architecture.
Architectural Design Metrics Cont’d
Design Structure Quality Index (DSQI)
• The metric was developed by the United States Air Force Systems Command.
S2 = The number of modules whose correct function depends on the source of data input or that produce
data to be used elsewhere.
S4 = The number of database items (includes data objects and all attributes that define objects).
S7 = The number of modules with a single entry and exit (exception processing is not considered to be
multiple exits).
Architectural Design Metrics Cont’d
Once values s1 through s7 are determined for a computer program, the following intermediate values
can be computed:
D1-Program structure:
If the architectural design was developed using a distinct method (e.g., data flow-oriented design or
object-oriented design), then D1 = 1, otherwise D1 = 0.
DSQI=SUM(wiDi)
• The value of DSQI for past designs can be determined and compared to a design that is currently
under development.
• If the DSQI is significantly lower than average, further design work and review are indicated.
• If major changes are to be made to an existing design, the effect of those changes on DSQI can
be calculated.
Metrics for Object-Oriented Design
Measurable Characteristics of an OO Design
Size
Volatility Complexity
Similarity
Object-Oriented Coupling
Design
Primitiveness
Sufficiency
Cohesion Completeness
Metrics for Object-Oriented Design
• Size : Size is defined in terms of four views: population, volume, length, and
functionality.
• Similarity: The degree to which two or more classes are similar in terms of their
structure, function, behavior, or purpose is indicated by this measure.
• Measures and metrics for an individual class, the class hierarchy, and class
collaborations will be invaluable when you are required to assess OO design
quality.
Note:
• Keep WMC low otherwise, A high WMC has been found to lead to more faults.
• WMC is a predictor of how much time and effort is required to develop and maintain the
class.
DIT = maximum inheritance path from the class to the root class
3. Number of Children(NOC):
NOC equals the number of immediate child classes derived
from a base class
NOC = number of immediate sub-classes of a class
• NOC measures the breadth of a class hierarchy, where maximum DIT measures the
depth.
• Depth is generally better than breadth, since it promotes reuse of methods through
inheritance.
• NOC and DIT are closely related. Inheritance levels can be added to increase the
depth and reduce the breadth.
Class-Oriented Metrics Cont’d
3. Number of Children(NOC) Cont’d
A high NOC, a large number of child classes, can indicate several things:
• Two classes are coupled when methods declared in one class use methods
or instance variables defined by the other class.
• CBO is the number of collaborations listed for a class on its CRC index
card.
• The more independent a class is, the easier it is to reuse it in another application.
• R’ = number of remote methods called, recursively through the entire call tree
• RFC is the original definition of the measure. It counts only the first level of calls outside of
the class.
Class-Oriented Metrics Cont’d
The CK Metrics Suite Cont’d
6. Lack of cohesion in methods (LCOM)
• LCOM is the number of methods that access one or more of the same attributes.
• The LCOM metric provides useful insight in some situations, but it can be misleading in
others.
• For example, keeping coupling encapsulated within a class increases the cohesion of the
system as a whole.
• Therefore in at least one important sense, higher LCOM actually suggests that a class may
have higher cohesion, not lower.
Class-Oriented Metrics Cont’d
The MOOD Metrics Suite
• These metrics are useful for projects with heavy use of object-oriented
programming.
• Polymorphism Factor
Class-Oriented Metrics Cont’d
The MOOD Metrics Suite Cont’d
1. Method inheritance factor (MIF) , Attribute Inheritance Factor (AIF)
• A class that inherits lots of methods (attributes) from its ancestor classes contributes to a
high MIF (AIF).
• A child class that redefines its ancestors' methods (attributes) and adds new ones
contributes to a lower MIF (AIF).
• An independent class that does not inherit and has no children contributes to a lower MIF
(AIF).
Class-Oriented Metrics Cont’d
The MOOD Metrics Suite Cont’d
2. Polymorphism Factor(PF)
• Polymorphism Factor (PF alias POF) measures the degree of method overriding in
the class inheritance tree. It equals the number of actual method overrides
divided by the maximum number of possible method overrides.
• Data tokens - The variables defined for a module can be defined as data tokens for the module.
• Glue tokens -This set of data tokens lies on one or more data slice.
• Superglue tokens - These data tokens are common to every data slice in a module.
• Stickiness - The relative stickiness of a glue token is directly proportional to the number of data slices
that it binds.
Component-Level Design Metrics Cont’d
2. Coupling metrics
• Module coupling provides an indication of the “connectedness” of a module to
other modules, global data, and the outside environment.
• Encompasses data
• Global coupling
• Environmental coupling
Component-Level Design Metrics Cont’d
2. Coupling metrics cont’d
• Data and control flow coupling
• di - number of input data parameters
• ci - number of input control parameters
• do - number of output data parameters
• co - number of output control parameters
• Global coupling,
• gd - number of global variables used as data
• gc - number of global variables used as control
• Environmental coupling,
• w - number of modules called (fan-out)
• r - number of modules calling the module under consideration (fan-in)
Component-Level Design Metrics Cont’d
2. Coupling metrics cont’d
Coupling Metric
The cost can be assigned to each sequence of actions according to the following
relationship:
cost = [frequency of transition(k) x cost of transition(k)]
Aesthetics
Memory Load
Metrics For Webapps
Usability
Recognition time
User effort
Page/Window waiting time
Design Metrics For Webapps
1. Interface metrics
Suggested Metric Description
Design Metrics For Webapps
2. Aesthetic (graphic design) metrics
Suggested Metric Description
Design Metrics For Webapps
3. Content metrics
Suggested Metric Description
Design Metrics For Webapps
4. Navigation metrics
Suggested Metric Description
Metrics for Source Code
Halstead’s theory
• A computer program is an implementation of an algorithm considered to be a collection of
tokens that can be classified as either operators or operand.
Testing effort, e = V / PL