Software Design – Objectives and Metrics
What is Software Design?
Software design is the process of transforming software requirements into a detailed blueprint that
guides the development of the software system. It defines the architecture, components, interfaces,
data structures, and algorithms required to implement the system.
The main goal of software design is to create a system that is efficient, reliable, maintainable,
scalable, and easy to understand.
Objectives of Software Design
The objectives of software design are as follows:
1. Correctness
The design should satisfy all the functional and non-functional requirements.
It should correctly implement the system specifications.
Example: An online banking system should correctly process deposits, withdrawals, and fund
transfers.
2. Simplicity
The design should be easy to understand and implement.
Avoid unnecessary complexity.
Example: Using modular functions instead of writing all code in one large program.
3. Maintainability
The system should be easy to modify, update, and debug.
Changes should not affect unrelated modules.
Benefit: Reduces maintenance cost.
4. Reusability
Components should be designed so they can be reused in future projects.
Reusable modules reduce development time.
Example: A login authentication module used across multiple applications.
5. Modularity
Divide the software into independent modules.
Each module performs a specific function.
Advantages:
Easy testing
Easy debugging
Easy maintenance
Parallel development
6. Reliability
The software should perform consistently under specified conditions.
It should handle errors gracefully.
Example: ATM software should continue operating correctly even if the network connection is
temporarily interrupted.
7. Efficiency
The software should make effective use of:
o CPU
o Memory
o Disk space
o Network bandwidth
Objective: Achieve high performance with minimum resource consumption.
8. Flexibility
The software should accommodate future changes with minimal effort.
Example: Adding a new payment option to an e-commerce application without major redesign.
9. Scalability
The design should support growth in users, data, or transactions.
Example: A social media platform handling millions of users.
10. Security
Protect the system from unauthorized access.
Ensure confidentiality, integrity, and availability of data.
Example: Password encryption and multi-factor authentication.
11. Portability
The software should run on different hardware and operating systems with minimal changes.
Example: A Java application running on Windows, Linux, and macOS.
12. Testability
The design should make testing straightforward.
Modules should be independently testable.
Software Design Metrics
Software design metrics are quantitative measures used to evaluate the quality of a software design.
They help identify complexity, maintainability, modularity, and potential design issues.
1. Size Metrics
Measures the size of the software design.
Examples:
Number of classes
Number of methods
Number of modules
Number of packages
Purpose: Estimate development effort and maintenance requirements.
2. Complexity Metrics
Measures how difficult the design is to understand and maintain.
Cyclomatic Complexity
Measures the number of independent execution paths.
Higher values indicate more complex code.
Formula:
V (G)=E−N +2 P
Where:
E = Number of edges
N = Number of nodes
P = Number of connected components
Interpretation:
1–10: Simple
11–20: Moderate
20: Complex
3. Coupling Metrics
Measures the dependency between modules.
Low Coupling (Preferred)
Modules are independent.
Changes in one module have minimal impact on others.
High Coupling
Modules are highly dependent.
Maintenance becomes difficult.
4. Cohesion Metrics
Measures how closely related the functions within a module are.
High Cohesion (Preferred)
A module performs one well-defined task.
Low Cohesion
A module performs many unrelated tasks.
5. Fan-In Metric
Measures the number of modules that call a particular module.
High Fan-In
Indicates the module is widely reused.
6. Fan-Out Metric
Measures the number of modules called by a module.
High Fan-Out
Indicates greater dependency and increased complexity.
7. Depth of Inheritance Tree (DIT)
Measures the maximum inheritance depth of a class.
Advantages:
Encourages reuse through inheritance.
Disadvantages:
Deep inheritance can make systems harder to understand and debug.
8. Number of Children (NOC)
Measures the number of immediate subclasses of a class.
Interpretation:
High NOC indicates greater reuse but may also increase testing effort.
9. Response for a Class (RFC)
Measures the number of methods that can be executed in response to a message sent to an object.
Higher RFC
Greater complexity
More testing required
10. Lack of Cohesion in Methods (LCOM)
Measures how related the methods of a class are based on shared attributes.
Low LCOM: Good cohesion (desirable)
High LCOM: Poor cohesion; the class may need to be split.
Characteristics of a Good Software Design
A good software design should have:
✔ Correctness
✔ Simplicity
✔ Modularity
✔ High cohesion
✔ Low coupling
✔ Reliability
✔ Reusability
✔ Maintainability
✔ Scalability
✔ Security
✔ Testability
✔ Efficiency
Modularity
Definition
Modularity is the process of dividing a software system into smaller, independent modules, where
each module performs a specific function. Each module can be developed, tested, maintained, and
reused independently.
Definition (Exam Point)
Modularity is the decomposition of a software system into separate, manageable, and independent
modules that interact through well-defined interfaces.
Objectives of Modularity
Reduce software complexity
Improve readability
Simplify testing and debugging
Enhance maintainability
Increase reusability
Support parallel development
Improve scalability
Characteristics of a Good Module
Performs a single well-defined task
Has high cohesion
Has low coupling
Easy to understand
Easy to modify
Can be reused
Advantages of Modularity
Easier maintenance
Faster debugging
Better code reuse
Parallel development by multiple programmers
Improved software quality
Simplified testing
Easier implementation of changes
Example of Modularity
Online Shopping System
Online Shopping System
│
├── Login Module
├── Product Module
├── Cart Module
├── Payment Module
├── Order Module
└── Report Module
Each module performs one specific task and communicates with other modules through interfaces.
Coupling
Definition
Coupling is the degree of interdependence between two software modules.
Key Point
Low coupling → Better software design
High coupling → Poor software design
Types of Coupling
1. Content Coupling (Worst)
One module directly accesses or modifies the internal data or code of another module.
Example
Module A directly changes
internal variable of Module B.
Disadvantages
Very difficult to maintain
Highly dependent
Poor security
2. Common Coupling
Multiple modules share the same global data.
Example
Global Variable
│
┌────┴────┐
│ │
Module A Module B
Disadvantage
Changing the global variable affects all modules.
3. External Coupling
Modules communicate through externally imposed data formats, communication protocols, or device
interfaces.
Example
Printer Driver
↑
Application
4. Control Coupling
One module controls the behavior of another by passing control information.
Example
Display(type)
type = 1 → Student Details
type = 2 → Staff Details
The receiving module behaves differently depending on the control parameter.
5. Stamp Coupling (Data-Structure Coupling)
Modules share an entire data structure even though only part of it is needed.
Example
Student Record
----------------
ID
Name
Age
Marks
Address
A function only requires Name but receives the whole record.
6. Data Coupling (Best)
Modules communicate only by passing the necessary data through parameters.
Example
CalculateSalary(BasicSalary)
Only the required value is passed.
Advantages
Easy maintenance
Better security
Easy testing
Cohesion
Definition
Cohesion is the degree to which the elements within a module are related and work together to
perform a single task.
Key Point
High cohesion → Better software design
Low cohesion → Poor software design
Types of Cohesion
1. Coincidental Cohesion (Worst)
Unrelated tasks are grouped together.
Example
Utility Module
Print Report
Read File
Calculate Tax
Send Email
These functions have no meaningful relationship.
2. Logical Cohesion
Related functions are grouped together, and one is selected using a control flag.
Example
Input Module
Read Keyboard
Read Mouse
Read Scanner
3. Temporal Cohesion
Activities executed at the same time are grouped together.
Example
System Startup
Load Drivers
Initialize Memory
Start Network
4. Procedural Cohesion
Functions are grouped because they follow a particular sequence.
Example
Read Data
Validate Data
Display Data
5. Communicational Cohesion
Functions operate on the same input or output data.
Example
Student Record
Update Record
Print Record
Delete Record
All functions use the same student record.
6. Sequential Cohesion
The output of one function becomes the input of the next.
Example
Read Marks
↓
Calculate Average
↓
Generate Grade
7. Functional Cohesion (Best)
Every element in the module contributes to one specific function.
Example
Login Module
Validate Username
Validate Password
Authenticate User
All functions support the single purpose of user authentication.