0% found this document useful (0 votes)
16 views11 pages

Cohesion and Coupling in Software Design

Software design transforms user requirements into implementable forms for programmers, focusing on correctness, completeness, efficiency, flexibility, consistency, and maintainability. Modularity divides software into manageable components, promoting parallel development and easier maintenance, while also presenting advantages and disadvantages. Key design strategies include top-down and bottom-up approaches, with an emphasis on achieving low coupling and high cohesion among modules to enhance software quality.

Uploaded by

21Aryan Kamal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views11 pages

Cohesion and Coupling in Software Design

Software design transforms user requirements into implementable forms for programmers, focusing on correctness, completeness, efficiency, flexibility, consistency, and maintainability. Modularity divides software into manageable components, promoting parallel development and easier maintenance, while also presenting advantages and disadvantages. Key design strategies include top-down and bottom-up approaches, with an emphasis on achieving low coupling and high cohesion among modules to enhance software quality.

Uploaded by

21Aryan Kamal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Software Design

Software design is a mechanism to transform user requirements into some suitable


form, which helps the programmer in software coding and implementation. It deals with
representing the client's requirement, as described in SRS (Software Requirement
Specification) document, into a form, i.e., easily implementable using programming
language.

The software design phase is the first step in SDLC (Software Design Life Cycle), which
moves the concentration from the problem domain to the solution domain. In software
design, we consider the system to be a set of components or modules with clearly
defined behaviors & boundaries.

Objectives of Software Design


Following are the purposes of Software design:
1. Correctness:Software design should be correct as per requirement.
2. Completeness:The design should have all components like data structures,
modules, and external interfaces, etc.
3. Efficiency:Resources should be used efficiently by the program.
4. Flexibility:Able to modify on changing needs.
5. Consistency:There should not be any inconsistency in the design.
6. Maintainability: The design should be so simple so that it can be easily
maintainable by other designers.

Modularity
Modularity specifies to the division of software into separate modules which are
differently named and addressed and are integrated later on in to obtain the completely
functional software. It is the only property that allows a program to be intellectually
manageable. Single large programs are difficult to understand and read due to a large
number of reference variables, control paths, global variables, etc.

The desirable properties of a modular system are:

o Each module is a well-defined system that can be used with other applications.
o Each module has single specified objectives.
o Modules can be separately compiled and saved in the library.
o Modules should be easier to use than to build.
o Modules are simpler from outside than inside.

Advantages and Disadvantages of Modularity

Advantages of Modularity

There are several advantages of Modularity

o It allows large programs to be written by several or different people


o It encourages the creation of commonly used routines to be placed in the library and
used by other programs.
o It simplifies the overlay procedure of loading a large program into main storage.
o It provides more checkpoints to measure progress.
o It provides a framework for complete testing, more accessible to test
o It produced the well designed and more readable program.

Disadvantages of Modularity

There are several disadvantages of Modularity

o Execution time maybe, but not certainly, longer


o Storage size perhaps, but is not certainly, increased
o Compilation and loading time may be longer
o Inter-module communication problems may be increased
o More linkage required, run-time may be longer, more source lines must be written, and
more documentation has to be done

Modular Design

Modular design reduces the design complexity and results in easier and faster
implementation by allowing parallel development of various parts of a system. We
discuss a different section of modular design in detail in this section:

1. Functional Independence: Functional independence is achieved by developing


functions that perform only one kind of task and do not excessively interact with other
modules. Independence is important because it makes implementation more accessible
and faster. The independent modules are easier to maintain, test, and reduce error
propagation and can be reused in other programs as well. Thus, functional
independence is a good design feature which ensures software quality.

It is measured using two criteria:

o Cohesion: It measures the relative function strength of a module.


o Coupling: It measures the relative interdependence among modules.

2. Information hiding: The fundamental of Information hiding suggests that modules


can be characterized by the design decisions that protect from the others, i.e., In other
words, modules should be specified that data include within a module is inaccessible to
other modules that do not need for such information.

The use of information hiding as design criteria for modular system provides the most
significant benefits when modifications are required during testing's and later during
software maintenance. This is because as most data and procedures are hidden from
other parts of the software, inadvertent errors introduced during modifications are less
likely to propagate to different locations within the software.

Strategy of Design
A good system design strategy is to organize the program modules in such a method
that are easy to develop and latter too, change. Structured design methods help
developers to deal with the size and complexity of programs. Analysts generate
instructions for the developers about how code should be composed and how pieces of
code should fit together to form a program.

To design a system, there are two possible approaches:

1. Top-down Approach
2. Bottom-up Approach

1. Top-down Approach: This approach starts with the identification of the main
components and then decomposing them into their more detailed sub-components.
2. Bottom-up Approach: A bottom-up approach begins with the lower details and
moves towards up the hierarchy, as shown in fig. This approach is suitable in case of an
existing system.

Coupling and Cohesion


Module Coupling
In software engineering, the coupling is the degree of interdependence between
software modules. Two modules that are tightly coupled are strongly dependent on
each other. However, two modules that are loosely coupled are not dependent on each
other. Uncoupled modules have no interdependence at all within them.
The various types of coupling techniques are shown in fig:

A good design is the one that has low coupling. Coupling is measured by the number of
relations between the modules. That is, the coupling increases as the number of calls
between modules increase or the amount of shared data is large. Thus, it can be said
that a design with high coupling will have more errors.
Types of Module Coupling

1. No Direct Coupling: There is no direct coupling between M1 and M2.

In this case, modules are subordinates to different modules. Therefore, no direct


coupling.

2. Data Coupling: When data of one module is passed to another module, this is called
data coupling.
3. Stamp Coupling: Two modules are stamp coupled if they communicate using
composite data items such as structure, objects, etc. When the module passes non-
global data structure or entire structure to another module, they are said to be stamp
coupled. For example, passing structure variable in C or object in C++ language to a
module.

4. Control Coupling: Control Coupling exists among two modules if data from one
module is used to direct the structure of instruction execution in another.

5. External Coupling: External Coupling arises when two modules share an externally
imposed data format, communication protocols, or device interface. This is related to
communication to external tools and devices.

6. Common Coupling: Two modules are common coupled if they share information
through some global data items.

7. Content Coupling: Content Coupling exists among two modules if they share code,
e.g., a branch from one module into another module.
Module Cohesion
In computer programming, cohesion defines to the degree to which the elements of a
module belong together. Thus, cohesion measures the strength of relationships
between pieces of functionality within a given module. For example, in highly cohesive
systems, functionality is strongly related.

Cohesion is an ordinal type of measurement and is generally described as "high


cohesion" or "low cohesion."
Types of Modules Cohesion

1. Functional Cohesion: Functional Cohesion is said to exist if the different elements of a


module, cooperate to achieve a single function.
2. Sequential Cohesion: A module is said to possess sequential cohesion if the element of
a module form the components of the sequence, where the output from one component
of the sequence is input to the next.
3. Communicational Cohesion: A module is said to have communicational cohesion, if all
tasks of the module refer to or update the same data structure, e.g., the set of functions
defined on an array or a stack.
4. Procedural Cohesion: A module is said to be procedural cohesion if the set of purpose
of the module are all parts of a procedure in which particular sequence of steps has to
be carried out for achieving a goal, e.g., the algorithm for decoding a message.
5. Temporal Cohesion: When a module includes functions that are associated by the fact
that all the methods must be executed in the same time, the module is said to exhibit
temporal cohesion.
6. Logical Cohesion: A module is said to be logically cohesive if all the elements of the
module perform a similar operation. For example Error handling, data input and data
output, etc.
7. Coincidental Cohesion: A module is said to have coincidental cohesion if it performs a
set of tasks that are associated with each other very loosely, if at all.

Differentiate between Coupling and Cohesion

Coupling Cohesion

Coupling is also called Inter-Module Cohesion is also called Intra-Module Binding.


Binding.

Coupling shows the relationships Cohesion shows the relationship within the module.
between modules.

Coupling shows the Cohesion shows the module's


relative independence between the relative functional strength.
modules.

While creating, you should aim for low While creating you should aim for high cohesion, i.e., a
coupling, i.e., dependency among cohesive component/ module focuses on a single
modules should be less. function (i.e., single-mindedness) with little interaction
with other modules of the system.

In coupling, modules are linked to the In cohesion, the module focuses on a single thing.
other modules.

Common questions

Powered by AI

To manage the complexity and size of software programs effectively, structured design strategies such as modularization, top-down, and bottom-up approaches should be adopted . Modularization reduces complexity by segmenting the program into well-defined, interdependent modules, each addressing a specific aspect of the system . The top-down approach begins with defining system-wide objectives and breaking them into detailed components, ensuring alignment with goals and simplifying system comprehension . Conversely, the bottom-up approach focuses on assembling systems from individual components, useful for integrating improvements within existing systems . Employing these strategies in tandem with principles like functional independence, cohesion, and coupling, ensures that programs are not only simpler to develop and maintain but are also scalable and adaptable over time .

Modular design plays a crucial role in enhancing maintainability by enabling functional independence through the separation of a program into distinct modules that perform a single function with minimal interactions with other modules. This reduces complexity, making the software easier to maintain and test . High cohesion within modules ensures that each module focuses on a single task, which simplifies maintenance and reduces errors . The use of information hiding further aids in maintenance by protecting module-specific details from spreading through the system, thereby minimizing error propagation during modifications .

Information hiding significantly impacts system design by encapsulating module-specific information, thereby restricting access to data from other modules that do not require it. This principle reduces the chances of unintended interactions and errors, thereby simplifying the modification and maintenance of software systems . During software maintenance, this separation is crucial as it allows updates or changes to be made within a module without affecting or propagating errors to other parts of the system . By isolating module details and promoting independent development, information hiding facilitates smoother updates and more reliable code modifications, ultimately optimizing overall system stability and resilience against errors .

Coupling affects software error rates as higher coupling indicates greater interdependence among modules, which can lead to increased error propagation when changes or faults occur . High coupling complicates error tracing and module replacement because tightly linked modules may inadvertently affect each other, resulting in cascading failures . To improve software quality, coupling should be minimized. This can be achieved by designing with principles like loose coupling and adherence to modularity guidelines, ensuring reduced dependencies among modules . Additionally, employing information hiding and clearly defined module interfaces can protect internal module processes and interactions, thereby optimizing coupling and ultimately enhancing overall software reliability and maintainability .

The top-down approach is considered beneficial in modular system development because it begins with the identification and definition of main components, ensuring that the system architecture is aligned with overall strategic objectives. It incrementally breaks down these components into more detailed sub-components, which facilitates thorough analysis and understanding of each module before development . This approach allows for the systematic identification of dependencies and aids in establishing a clear hierarchy, which supports modularity and reduces complexity during implementation . Additionally, starting with a broad perspective helps ensure that all system requirements are addressed, thereby minimizing gaps in the development process .

Modularity offers several advantages in software design, such as simplifying complex systems by dividing them into manageable modules, facilitating parallel development, and making testing, debugging, and maintenance more straightforward . It increases comprehension by encapsulating functionality and can enhance software quality through reusable code libraries . However, the potential drawbacks include increased execution time due to added interfaces and possible overheads, as well as increased storage size and complexity in inter-module communication, which may prolong compilation and loading times . These drawbacks can impact performance by potentially increasing runtime and resource consumption, necessitating careful design to mitigate these effects .

Functional independence enhances software quality by allowing each module to perform a self-contained, specific task with minimal interaction with other modules, reducing error propagation through independent functional execution . This principle underpins modularity, ensuring that modules are easier to understand, maintain, and test, which collectively improve reliability and robustness. Functional independence encourages module reusability across different applications, which not only reduces redundancy but also aligns with agile methodologies for adaptable system development . By focusing on single-task functions, functional independence helps maintain high cohesion and low coupling, which are key parameters in maintaining high software quality .

Coupling and cohesion serve as pivotal principles in system design to manage module interdependence and intra-module functionality. High cohesion within a module implies strong functional correlation among module elements, leading to robust module performance and execution . High cohesion enhances readability and maintenance, promoting modular integrity . Conversely, low coupling indicates limited interdependence between modules, facilitating module independence which is critical for flexibility and modular interchangeability. Minimizing coupling reduces complexity, interaction constraints, and subsequent errors . Designing for high cohesion and low coupling results in a well-structured, efficient, and adaptable system .

Cohesion quantifies how closely related elements within a module are in performing tasks, which directly influences modular design goals like simplification, reusability, and reliability . Types of cohesion such as functional, sequential, communicational, and procedural cohesion support achieving modular objectives by organizing module tasks based on specific functional objectives . High cohesion, particularly functional cohesion, ensures that every component within a module works collaboratively to fulfill a single purpose, aligning with modular design principles that emphasize clarity and efficiency . Procedural and communicational cohesion further enhance a system's ability to maintain task alignment and ensure data-handling remains centralized, supporting better data integrity across processes . By effectively applying different cohesion types, software engineers can isolate functionality within modules, optimizing performance while maintaining design simplicity and adaptability .

A bottom-up approach is particularly suited for existing systems as it focuses on leveraging and integrating existing components and functionalities to build or improve systems . This approach works well when modifications or extensions are necessary but complete restructuring is not viable. By starting at the component level, it allows developers to optimize and enhance parts of the system incrementally, thus preserving the existing architecture and investments while incrementally upgrading system capabilities . For new systems, starting with a top-down approach aligning with strategic objectives might be more effective, as it allows for creating a unified architecture from the outset . However, for existing systems, the bottom-up approach is efficient for adding new features and integrating technologies without extensive reengineering .

You might also like