Presentation is loading. Please wait.

Presentation is loading. Please wait.

Object-Oriented Metrics

Similar presentations


Presentation on theme: "Object-Oriented Metrics"— Presentation transcript:

1 Object-Oriented Metrics

2 What Are Software Engineering Metrics?
Metrics are units of measurement that are used to characterize: software engineering products, e.g., designs, source code, and test cases, software engineering processes, e.g., the activities of analysis, designing, and coding, and software engineering people, e.g., the efficiency of an individual tester, or the productivity of an individual designer.

3 If used properly, software engineering metrics can allow us to:
quantitatively define success and failure, and/or the degree of success or failure, for a product, a process, or a person, identify and quantify improvement, lack of improvement, or degradation in our products, processes, and people, make meaningful and useful managerial and technical decisions, identify trends, and make quantified and meaningful estimates.

4 OOSE metrics are different because of:
localization, encapsulation, information hiding, inheritance, and object abstraction techniques.

5 Object-Oriented Metrics
Increasingly, object-oriented measurements are being used to evaluate and predict the quality of software.

6 The Coupling Factor (CF) is evaluated as a fraction.
 METRICS FOR ANALYSIS When code is analyzed for object-oriented metrics, often two suites of metrics are used, the Chidamber-Kemerer (CK) MOOD  suites. In this section, we enumerate and explain the specific measures that can be computed using this tool.      Coupling The Coupling Factor (CF) is evaluated as a fraction. The numerator represents the number of non-inheritance couplings. The denominator is the maximum number of couplings in a system. The maximum number of couplings includes both inheritance and non-inheritance related coupling. Inheritance-based couplings arise as derived classes (subclasses) inherit methods and attributes form its base class (superclass). The CF metric is included in the MOOD metric suite.

7 Cohesion Cohesion refers to how closely the operations in a class are related to each other. Cohesion of a class is the degree to which the local methods are related to the local instance variables in the class.  The CK metrics suite examines the Lack of Cohesion (LOCOM), which is the number of disjoint/non-intersection sets of local methods.

8 Encapsulation The following two encapsulation measures are contained in the MOOD metrics suite. Attribute Hiding Factor (AHF) The Attribute Hiding Factor measures the invisibilities of attributes in classes. The invisibility of an attribute is the percentage of the total classes from which the attribute is not visible. An attribute is called visible if it can be accessed by another class or object. Attributes should be "hidden" within a class. They can be kept from being accessed by other objects by being declared a private. Method Hiding Factor (MHF) The Method Hiding Factor measures the invisibilities of methods in classes. 

9    Inheritance Inheritance decreases complexity by reducing the number of operations and operators, but this abstraction of objects can make maintenance and design difficult. The two metrics used to measure the amount of inheritance are the depth and breadth of the inheritance hierarchy.  Depth of Inheritance Tree (DIT)  Number of Children (NOC)

10 Complexity Weighted Methods/Class (WMC)
WCM measures the complexity of an individual class. A class with more member functions than its peers is considered to be more complex and therefore more error prone.

11 Summary of Metrics Metric Desirable Value Coupling Factor Lower
Lack of Cohesion of Methods Lower Cyclomatic Complexity Lower Attribute Hiding Factor Higher Method Hiding Factor Higher Depth of Inheritance Tree Low Number of Children Low Weighted Methods Per Class Low Number of Classes Higher Lines of Code Lower

12 C.K. Metrics Model Chidamber and Kemerer define the so called CK metric suite. This metric suite offers informative insight into whether developers are following object oriented principles in their design . They claim that using several of their metrics collectively helps managers and designers to make better design decision.

13 Weighted Method per Class (WMC)
WMC measures the complexity of a class. Complexity of a class can for example be calculated by the cyclomatic complexities of its methods. High value of WMC indicates the class is more complex than that of low values. So class with less WMC is better. As WMC is complexity measurement metric, we can get an idea of required effort to maintain a particular class.

14 Depth of Inheritance Tree (DIT)
DIT metric is the length of the maximum path from the node to the root of the tree. So this metric calculates how far down a class is declared in the inheritance hierarchy. This metric also measures how many ancestor classes can potentially affect this class. DIT represents the complexity of the behaviour of a class, the complexity of design of a class and potential reuse. If DIT increases, it means that more methods are to be expected to be inherited, which makes it more difficult to calculate a class’s behaviour. Thus it can be hard to understand a system with many inheritance layers. On the other hand, a large DIT value indicates that many methods might be reused.

15 Number of children (NOC)
This metric measures how many sub-classes are going to inherit the methods of the parent class. The size of NOC approximately indicates the level of reuse in an application. If NOC grows it means reuse increases. On the other hand, as NOC increases, the amount of testing will also increase because more children in a class indicate more responsibility. So, NOC represents the effort required to test the class and reuse.

16 Coupling between objects (CBO)
A class is coupled with another if the methods of one class use the methods or attributes of the other class. An increase of CBO indicates the reusability of a class will decrease. Thus, the CBO values for each class should be kept as low as possible. CBO metric measure the required effort to test the class

17 Response for a Class (RFC)
RFC is the number of methods that can be invoked in response to a message in a class. Pressman states, since RFC increases, the effort required for testing also increases because the test sequence grows. If RFC increases, the overall design complexity of the class increases and becomes hard to understand.

18 Lack of Cohesion in Methods (LCOM)
LCOM measures the amount of cohesiveness present, how well a system has been designed and how complex a class is . LCOM is a count of the number of method pairs whose similarity is zero, minus the count of method pairs whose similarity is not zero.

19 MOOD (Metrics for Object Oriented Design)
The MOOD metrics set refers to a basic structural mechanism of the OO paradigm as encapsulation ( MHF and AHF ), inheritance ( MIF and AIF ), polymorphisms ( PF ) , message-passing ( CF ) and are expressed as quotients. The set includes the following metrics:

20 1) Method Hiding Factor ( MHF )
MHF is defined as the ratio of the sum of the invisibilities of all methods defined in all classes to the total number of methods defined in the system under consideration. The invisibility of a method is the percentage of the total classes from which this method is not visible. note : inherited methods not considered. 2) Attribute Hiding Factor ( AHF ) AHF is defined as the ratio of the sum of the invisibilities of all attributes defined in all classes to the total number of attributes defined in the system under consideration.

21 3) Method Inheritance Factor ( MIF )
MIF is defined as the ratio of the sum of the inherited methods in all classes of the system under consideration to the total number of available methods ( locally defined plus inherited) for all classes. 4) Attribute Inheritance Factor ( AIF ) AIF is defined as the ratio of the sum of inherited attributes in all classes of the system under consideration to the total number of available attributes ( locally defined plus inherited ) for all classes.

22 5) Polymorphism Factor ( PF )
PF is defined as the ratio of the actual number of possible different polymorphic situation for class Ci to the maximum number of possible distinct polymorphic situations for class Ci. 6) Coupling Factor ( CF ) CF is defined as the ratio of the maximum possible number of couplings in the system to the actual number of couplings not imputable to inheritance.


Download ppt "Object-Oriented Metrics"

Similar presentations


Ads by Google