×

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

Related Topics

Scope of software metrics

Scope, Benefit, and Cycle of Software Metrics Software metrics have tremendous scope in software development to understand and fulfill various aspects of the project process. Software metrics help in estimation of...

6 minutes read.

Some Important Quality Metrics

Important Quality Metrics The best quality of software has to pass through various software quality measures to attain standard in quality. The quality executive should consider these metrics to monitor the...

5 minutes read.

Project management activities

Project management activities Software project management involves many activities, including project planning, software product scope, cost estimation in various terms, scheduling of tasks and events, and resource management. Project management activities may include: Project PlanningScope ManagementProject...

2 minutes read.

Metrics for testing

There are different types of metrics used in software testing to measure different parameters. So, for different purposes, different metrics are used by the developer. For example: The type of metrics...

3 minutes read.

Twitter - System Design

You might have heard of Twitter, a widely used social media platform. Everybody tends to check it every few minutes. Imagine what you would do if you were asked to...

8 minutes read.

Prototype Model in Software Engineering

The prototype creation model is a method of developing the software in which a prototype of software or app is constructed, tested, and then reworked as needed until an acceptable result is obtained...

4 minutes read.

Structured Analysis and Design (SA/SD)

When the software systems keep getting bigger and more complex, you need a way to represent the model systematically. Structured Design and Structured Analysis, often referred to as SA/SD, is...

4 minutes read.

Information Flow Metrics

This metric is purely based on information. Information flow metric is different from size metric, and data structure metric as size metric is based on the final size of program...

4 minutes read.

What is System Design

System design is simply the systematic process used to design the basic architecture of an electronic control system by defining essential elements like modules or components and their interfaces. This...

3 minutes read.

Software Project Planning

Project planning is a management process that focuses on the activities required to complete a project successfully. Project planning helps to prevent problems that occur during the project development, such as a...

2 minutes read.

SDLC in Software Engineering

SDLC SDLC stands for the Software Development life cycle. It is a pictorial and diagrammatic representation of the software life cycle. A life cycle model represents all the techniques required to integrate software into the...

3 minutes read.

Waterfall Model in Software Engineering

The most popular model is the waterfall model. This model has five phases: Requirement analysis and specification DesignImplementation & unit testing Integration and system testing phaseOperation and maintenance These phases often occur one...

3 minutes read.

V-Model

The V-model is also known as the verification and validation model. The V-model is also known as the verification and validation model. In this, each phase of the SDLC must be completed before...

3 minutes read.

Software Configuration Management

Software Configuration Management The process of Software Configuration Management contains operations such as controlling, managing, and organizing the source-code, documents, and other essential components during the Software Development Life Cycle.SCM is essential for all project...

3 minutes read.

Software Quality Assurance (SQA)

Software Quality Assurance (SQA) is a process that ensures the quality of software while developing software. It also ensures that all processes, procedures, and activities are monitored and properly implemented. It works along...

3 minutes read.

Software Quality Metrics

In a software project, the software is designed to build a source code, but from time to time or step by step, checking source code is required. Check whether the work...

4 minutes read.

Project Monitoring and Control

Project Monitoring and Control Project monitoring and control process includes procedures which are performed to observe project performance so that potential problems are identified, and appropriate action can be taken to meet the desired performance...

3 minutes read.

Big-Bang Model in Software Engineering

In the Big-Bang Model, developers do not adopt any specific process. Development begins only with the necessary funds and efforts as input, and output is developed software that may or may not be...

1 minute read.

Software Metrics

Introduction Software metrics is the term used in software engineering. Software engineering is the detailed study of the step-by-step making of user-interactive software that fulfills users' needs. Let's discuss two terms...

4 minutes read.

Load Balancer – System Design

As software engineering students or IT enthusiasts, most of us have wondered how these huge IT applications handle the millions of simultaneous requests on their servers. The sheer hard work...

9 minutes read.