Experiment 07:Evaluate the cohesion and coupling of a software system by using Class
diagram
Learning Objective: Students will be able to evaluate the cohesion and coupling of a
software system by using Class diagram
Tools: StarUML
Theory:
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.
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.
Data Coupling: If the dependency between the modules is based on the fact that they
communicate by passing only data, then the modules are said to be data coupled. In data
coupling, the components are independent of each other and communicate through data. Module
communications don’t contain tramp data. Example-customer billing system.
Stamp Coupling In stamp coupling, the complete data structure is passed from one module to
another module. Therefore, it involves tramp data.
Control Coupling: If the modules communicate by passing control information, then they are
said to be control coupled. Example- sort function that takes comparison function as an
argument.
External Coupling: In external coupling, the modules depend on other modules, external to the
software being developed or to a particular type of hardware. Ex- protocol, external file, device
format, etc.
Common Coupling: The modules have shared data such as global data structures. The changes in
global data mean tracing back to all modules which access that data to evaluate the effect of the
change. So it has got disadvantages like difficulty in reusing modules, reduced ability to control
data accesses, and reduced maintainability.
Content Coupling: In a content coupling, one module can modify the data of another module, or
control flow is passed from one module to the other module. This is the worst form of coupling
and should be avoided.
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."
Functional Cohesion: Every essential element for a single computation is contained in the
component. A functional cohesion performs the task and functions. It is an ideal situation.
Sequential Cohesion: An element outputs some data that becomes the input for other element,
i.e., data flow between the parts. It occurs naturally in functional programming languages.
Communicational Cohesion: Two elements operate on the same input data or contribute towards
the same output data. Example- update record in the database and send it to the printer.
Procedural Cohesion: Elements of procedural cohesion ensure the order of execution. Actions
are still weakly connected and unlikely to be reusable. Ex- calculate student GPA, print student
record, calculate cumulative GPA, print cumulative GPA.
Temporal Cohesion: The elements are related by their timing involved. A module connected with
temporal cohesion all the tasks must be executed in the same time span. This cohesion contains
the code for initializing all the parts of the system. Lots of different activities occur, all at unit
time.
Logical Cohesion: The elements are logically related and not functionally. Ex- A component
reads inputs from tape, disk, and network. All the code for these functions is in the same
component. Operations are related, but the functions are significantly different.
Coincidental Cohesion: The elements are not related(unrelated). The elements have no
conceptual relationship other than location in source code. It is accidental and the worst form of
cohesion. Ex- print next line and reverse the characters of a string in a single component.
Implementation:
Result and discussion:
Cohesion Type: The Library Management System (LMS) primarily exhibits Functional
Cohesion. Each class, such as User, Librarian, Book, Transaction, and Review, encapsulates
functionality related to a specific aspect of the library system, like user management, book
management, and transaction handling.
Coupling Type: The LMS demonstrates moderate to low levels of Content Coupling. While
there are dependencies between classes, such as User-Transaction and Review-Book, these
dependencies are essential for the system's functionality and are relatively limited in scope. The
system aims to minimize direct dependencies between classes, favoring loose coupling where
possible to enhance flexibility and ease of maintenance.
Learning Outcomes: Students should have the ability to
LO 7.1:Understand Cohesion and Coupling
LO 7.2: Evaluate the level of Cohesion and Coupling using Class Diagram
LO 7.3: Understand the types of Cohesion and Coupling
Course Outcomes: Identify the design concepts and apply them to the project.
Conclusion:
Viva Questions:
Q.1 Differentiate between Cohesion and Coupling
Q.2 What are the different types of Coupling and Cohesion
For Faculty Use
Correction Formative Timely Attendance /
Parameters Assessmen completion of Learning
t [40%] Practical Attitude
[ 40%] [20%]
Marks
Obtained