| Metrics |
|
|
Object Oriented MetricsApplications developed using object oriented languages like Java are conceived as a collection objects which interact with one another to achieve the desired functionality. Interaction between objects creates a relationship between them. Object oriented metrics proposed by Chidamber & Kemerer and others , provide methods to measure the quality of object design, their relationship, dependency and other OO principles. Analyst4j measures these metrics automatically, which forms the source for analysis.
Weighted methods per class (WMC)The WMC is a count of the methods implemented within a class or the sum of the complexities of the methods (method complexity is measured by cyclomatic complexity). WMC1:Consider a Class C with methods M1, M2...Mn that is defined in the class. Let C1, C2...Cn be the complexity of the methods. Then WMC1 = C1 + C2 + .... + Cn. However the researcher's didn't define what "Complexity" of a method is deliberately, and left it for the implementers to choose. If all methods complexities are considered to be unity, then WMC1 = n, the Number of methods. Therefore, WMC1 = No. Of Methods (Considering complexities of methods to be unity). WMC2:WMC2 = C1 + C2 + ... + Cn (Sum of Cyclomatic Complexity of methods).
Response for a Class (RFC)The RFC is the count of the set of all methods that can be invoked in response to a message to an object of the class or by some method in the class. Methods in a class can be used as measures of communication. Methods can be viewed as definitions of responses to possible messages.Therefore, RFC = |RS| where RS is the response set for the class. RS (Response set) is the set of all methods that can be invoked in response to a message to an object of the class. Methods include methods outside the class as well, since methods within the class may call methods from other classes. RS = { M } U { Ri }, where M = set of all methods in the class. Ri = set of methods called by method i. The cardinality of this set is a measure of communication.
Lack of Cohesion (LCOM)Lack of Cohesion (LCOM) measures the dissimilarity of methods in a class by instance variable or attributes. Cohesion is the similarity of two things to be the intersection of the sets of properties of the two things. So, the degree of similarity of the methods within the object can be defined to be the intersection of the sets of instance variables that are used by the methods. If an object class has different methods performing different operations on the same set of instance variables, then the class is said to be cohesive. Cohesion is centered on data that is encapsulated within an object and how methods interact with data. Lack of cohesion, is a measure of how close methods are to the data they access. The more methods that access each attribute, the lower the value of LCOM and the more cohesive the class Interpretation
Coupling Between Object Classes (CBO)Coupling Between Object Classes (CBO) is a count of the number of other classes to which a class is coupled. Two objects are coupled if and only if at least one of them acts upon the other. CBO for a class is a count of the Number of other classes to which it is coupled. CBO relates to the notion that an object is coupled to another object if one of them acts on the other, i.e., methods of one use methods or instance variables of another. Since objects of the same class have the same properties, two classes are coupled when methods declared in one class use methods or instance variables defined by the other class. Interpretation
Depth of Inheritance Tree (DIT)The depth of a class within the inheritance hierarchy is the maximum number of steps from the class node to the root of the tree and is measured by the number of ancestor classes. Designers develop an abstraction of the application domain by arranging the classes in a hierarchy. The inheritance hierarchy is a directed acyclic graph that can be described as a tree structure with classes as nodes, leaves and a root. In any application, there can be many possible choices for the class hierarchy. Design choices on the hierarchy employed to represent the application are essentially choices about restricting or expanding the scope of properties of the classes of objects in the application. Two design decisions which relate to the inheritance hierarchy can be defined. They are Depth of Inheritance of class of objects and the Number of Children of the class, collectively they represent the genealogy of a class. Depth of Inheritance(DIT) = depth of the class in the inheritance tree. The depth of a node of a tree refers to the length of the maximal path from the node to the root of the tree. Depth of inheritance indicates the extent to which the class is influenced by the properties of its ancestors. Interpretation
Number of Children (NOC)The number of children is the number of immediate subclasses subordinate to a class in the hierarchy. Designers develop an abstraction of the application domain by arranging the classes in a hierarchy. The inheritance hierarchy is a directed acyclic graph that can be described as a tree structure with classes as nodes, leaves and a root.In any application, there can be many possible choices for the class hierarchy. Design choices on the hierarchy employed to represent the application are essentially choices about restricting or expanding the scope of properties of the classes of objects in the application. Two design decisions which relate to the inheritance hierarchy can be defined. They are Depth of Inheritance of class of objects and the Number of Children of the class, collectively they represent the genealogy of a class. Number of children = Number of immediate descendants of the class. Number of children indicates the potential impact on descendants. Interpretation
ReferenceA Metrics Suite for Object Oriented Design, S. R. Chidamber & C. F. Kemerer |
| < Prev | Next > |
|---|