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.
- Class name
- List of Attributes- Each attribute is associated with an excess specifier like private, public, and protected.
- 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.
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.
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.
Example: A company hires three different types of employees.
- Regular employee
- An employee on Daily wages
Attributes of the given employees
|Regular Class Attribute||Consultant Attribute||Daily Wages Employees|
|Employee number||Employee number||Employee number|
|Employee name||Employee name||Employee name|
|Date of birth||Date of birth||Date of birth|
|Date of joining||Date of joining||Date of joining|
|Basic pay||Consultancy charges||Wages per day|
Attributes that are common (generalization) to a regular employee, consultant, and daily wages include:
- Employee number
- Employee name
- Date of birth
- Date of joining
Specific attributes to sub classes (Specialization)
- Regular employee – Basic pay and pan
- Consultant – Consultancy charges
- An employee on wages – Wages per day
So, employee classes can be specialized into three subclasses.
- Employee subclasses
- Consultant subclasses
- 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.
- 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:-
- Single inheritance – An object is having characteristics of one object.
- 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:-
- 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.
- 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 localization||Object-oriented software localization|
|It focuses on program functions and their functionality. Metrics focus on the component (function) interrelationships||This 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:-
- At a higher level of abstraction, a general view of a concept or item is provided.
- At a lower level of abstraction, a detailed view of the concept or item is provided.
Metrics used for software analysis are:
- Weighted Methods/ Class (WMC)
- Additional measures
- Number of classes
- Line of Code
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
- It becomes difficult to understand, enhance and maintain the individual artifacts.
- 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.
- It is more significant the unexpected change and defect propagation across artifacts.
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.
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.
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.
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.
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.
This metric is the same as the sufficiency metric, but it considers multiple points for full representation of the problem domain.
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 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.
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.
|Lack of Cohesion of method||Lower|
|Attribute hiding factor||Higher|
|Method hiding factor||Higher|
|Depth of inheritance tree||Low(trade off)|
|Number of children||Low(trade off)|
|Weighted method per class||Low(trade off)|
|Number of classes||Higher|
|Lines of code||Lower|