Object Oriented Metrices in Software Engineering

Metrics are used to measure the quality of software on different parameters. It provides acomputed accurate estimation of projects that help in developing software with minimal fault.

“Metric is a set of specific measurement applied on a process or particular item.”

Software engineering metrics are used to characterize:

  • Software engineering processes
  • Software engineering products
  • Software engineering people

Software engineering metrics are used to:

  • Identify the latest trends of technology in software.
  • Make quantify and meaningful estimates.
  • Help managers and technicians to make meaningful decisions.
  • Analyze and declare the success and failure of a product, person, or process.
  • Find out and quantify improvement.

Introduction:  An object is an entity of interest with well define attributes and exhibits behavior. State of an object, set of values associated with each attribute of an object at a time. Objects that share common property are grouped into a class or object class.

Diagrammatically a class is represented as a rectangle with three compartments.

  1. Class name
  2. List of Attributes- Each attribute is associated with an excess specifier like private, public, and protected.
  3. List of operations - An operation can be a query operation or an update operation.A query operation will not alter the state of an object. Example: Balance inquiry performed on an account.

An update operation will alter the state of an object. For example, Cash deposit and withdrawal from an account.

Object-Oriented Metrics

For a given problem, when an object-oriented methodology is adopted, objects of interest will be identified. Once the objects are identified, associate them with another object. For example, an employee works for a department. An employee is an object, and department is another object.

It’s an association between employee and department. When an association has been identified, an appropriate multiplicity has to be identified. One employee works for one department, or a department can have many employees working in it.

Object-Oriented Metrics

When a generalization and specialization hierarchy is identified, the superclass is identified, and the superclass can have sub-classes. Sub-class is identified only if the subclass has a specific attribute to it.

Generalization and specialization can be viewed as a superclass, subclass hierarchy. The subclass is identified only if there are attributes specific to it. All common attributes are modelled in the superclass.

Object-Oriented Metrics

Example: A company hires three different types of employees.

  1. Regular employee
  2. Consultant
  3. An employee on Daily wages

Attributes of the given employees

Regular Class AttributeConsultant AttributeDaily Wages Employees
Employee numberEmployee numberEmployee number
Employee nameEmployee nameEmployee name
GenderGenderGender
Date of birthDate of birthDate of birth
Date of joiningDate of joiningDate of joining
DesignationDesignationDesignation
Basic payConsultancy chargesWages per day

Attributes that are common (generalization) to a regular employee, consultant, and daily wages include:

  1. Employee number
  2. Employee name
  3. Date of birth
  4. Gender
  5. Date of joining
  6. Designation

Specific attributes to sub classes (Specialization)

  • Regular employee – Basic pay and pan
  • Consultant – Consultancy charges
  • An employee on wages – Wages per day
Object-Oriented Metrics

So, employee classes can be specialized into three subclasses.

  1. Employee subclasses
  2. Consultant subclasses
  3. Daily wages subclasses

“In object oriented modelling a modeller identifies objects of interest, their attributes and the relationship among the objects." The analysis model developed will be translated into a design model, and further design model is translated into source code.

Object-oriented metrics are a type of product metrics. It is a smart and advanced way of measuring software quality as its focus on the class and design characteristics of a program consisting of object-oriented functionality. It is different from other metrics due to having characteristics like inheritance, information hiding, localization, encapsulation, and object abstraction techniques.

Object-Oriented Metrics
  • Inheritance- It is a mechanism in which an object inherits the properties of one or another object. Inheritance decreases the number of operations and operators that reduces the complexity of a program.There are types of inheritance:-
  1. Single inheritance – An object is having characteristics of one object.
  2. Multiple inheritances - An object having characteristics from two or more other objects.

Metrics used to measure the inheritance in the program:-

  • Depth of Inheritance Tree (DIT)
  • Number of Children (NOC)
  • Encapsulation- Encapsulation term is defined as binding together or packaging of collection of items. Example:  records, arrays, and subprograms (low-level examples).

There are few objects which are encapsulated, like knowledge of state and advertised capabilities. Knowledge of the state can be statically maintained or calculated upon demand, or else and algorithms are used to complete these advertised capabilities.

In metrics, due to encapsulation, the basic unit cannot remain as a subprogram, and modified thinking is required for characterizing and estimating systems.

Two measure of encapsulations in metrics:-

  1. Method Hiding Factor (MHF) – As the name suggests, it measures the invisibilities of methods (percentage of total classes from which method is not visible) in classes.
  2. Attribute Hiding Factor ( AHF) measures the invisibility of attributes( percentage of total class from which attribute is not visible) in classes.
  • Information Hiding- Hiding detailed information, as generally necessary information is required to accomplish immediate goals. Therefore, detailed information is suppressed.

Information hiding has degrees ranging from partially restricted to total invisibility. Encapsulation and information hiding are different from each other as information hiding provides a degree of information hiding and does object coupling, but an encapsulated item can be obvious.

  • Localization- In this localization process, items are placed in close physical proximity to each other. Functional decomposition processes localize information around function. A data-driven approach localizes information around data, and object-oriented approaches localize information around objects.
Conventional Software localizationObject-oriented software localization
It focuses on program functions and their functionality. Metrics focus on the component (function) interrelationshipsThis localization is based on "objects" instead of the functionality of the object. There is no one-to-one function between functionality and object in localization.
  • Object abstraction techniques- Abstraction focus on essential details of a concept, not the inessential details. Abstraction is measured at two levels:-
  1. At a higher level of abstraction, a general view of a concept or item is provided.
  2. At a lower level of abstraction, a detailed view of the concept or item is provided.

Metrics used for software analysis are:

  • Coupling
  • Cohesion
  • Complexity
    • Weighted Methods/ Class (WMC)
  • Additional measures
    • Number of classes
    • Line of Code
  • Similarity
  • Volatility
  • Completeness
  • Sufficiency
  • Primitives
  • Size

Coupling

It was used for measuring the interdependency of two objects and was named as coupling factor.

Coupling Factor = Number of non- inheritance coupling / maximum number of coupling in a system.

Defects of solid coupling between software artifacts

  1. It becomes difficult to understand, enhance and maintain the individual artifacts.
  2. To achieve the satisfaction level of software, it becomes necessary to remove all the defects, and it requires more testing to reach desired reliability level of software.
  3. It is more significant the unexpected change and defect propagation across artifacts.

Cohesion

How closely the operation relayed to each other in a class is defined by cohesion. The cohesion of class defines the degree of the level at which local methods are related to a local instance in the class. It measures whether the attributes present in classes are focused or not.

A class must have some attribute and perform the same type of task. So cohesion must be high, and coupling must be low in the system program.

Object-Oriented Metrics

Complexity

Complexity is measured by weighted methods/ class, and it measures how classes are interrelated. Interrelated classes have many complexities because a class with more member functions results in more errors. A class has many methods that will have a significant impact on children in the class.

Additional measures

Number of classes

Projects with more classes are easily abstracted. It's necessary to measure the number of classes in a program to define a program's complexity.

Lines of code

 A project with fewer code lines is considered a unique design program and requires less maintenance. Less number of source code lines decreases the chances of error and increases the reliability of the program.

Similarity

It measures up to what degree two or more classes are similar. Similarity can be of structure, function, and behavior of two or more classes. More similarities between classes will raise various issues.

Volatility

This is used to measure the change in an articraft. Volatility must be low because if changes happen consistently, then more efforts will be applied.

Completeness

This metric is the same as the sufficiency metric, but it considers multiple points for full representation of the problem domain.

Sufficiency

This metric is used to measure the degree to which a design attain features inits abstraction form in the current application point of view. Sufficiency answers that a class has all the necessary properties of the problem domain.

Primitives (simplicity)

Primitives measures tell the degree to which an operation is atomic (class operations must be composed of other operations). One single operation should be performing one single task.

Size

In object-oriented design, size metric includes the volume, length, population, and functionality of classes in a program.

  • Population refers to the # of classes and operations
  • Volume includes dynamic object count
  • The length refers to the depth of inheritance
  • The functionality contains # of user function

This table defines the various metrics desirable values required for a good quality of software.

MetrixDesirable Value
Coupling factorLower
Lack of Cohesion of methodLower
Cyclomatic ComplexityLower
Attribute hiding factorHigher
Method hiding factorHigher
Depth of inheritance treeLow(trade off)
Number of childrenLow(trade off)
Weighted method per classLow(trade off)
Number of classesHigher
Lines of codeLower



ADVERTISEMENT
ADVERTISEMENT