Understanding Module Cohesion in Software Engineering

Where two modules work together to accomplish a single goal, the module is regarded as having high cohesion. High cohesion and minimal coupling are two of tidy module decomposition’s main properties. A module’s functional strength is gauged by its cohesion. A module is considered to be independently functioning from other modules if it exhibits strong cohesion and low coupling. Functional independence refers to a coherent module’s ability to carry out a single job or function. A module that is functionally autonomous interacts with other modules very little. While poor cohesion is difficult to test, reuse, even comprehend, and maintain, high cohesion has characteristics of dependability, robustness, and reusability.

Categorization of Cohesion

Cohesion is categorized from poorer cohesion to greater cohesion; a module may contain any of the following classifications, with coincidental cohesion being the lowest kind and functional cohesion being the greatest.

Coincidental cohesion:

When a module completes a group of tasks with just a tenuous connection to one another, it is said that it exhibits coincidental cohesion. In this instance, the module is made up of a random assortment of functions. The functions are probably there by sheer happenstance, without any planning or design, or just randomly arranged module components. Different modules’ functions do various tasks. For instance, the get-input, print-error, and summarize-members functions are all combined into one module in a transaction system for processing (TPS). The grouping has no bearing on how the issue is structured.

Logical cohesion:

The module is deemed logically cohesive if all of its components carry out comparable functions, such as managing errors, allowing for data input and output, etc. The arrangement of a group of print functions to produce various output reports into just one module, such as a module containing a group of print functions to produce various types of output reports like a salary, grade sheet, manual report, etc., is an example of logical cohesion. Here, modules’ components are systematically grouped to perform the same function.

Temporal Cohesion:

A module is considered to display temporal cohesion when it includes functions that are coupled to one another, and all of the functions must be run simultaneously. When a computer boots, for instance, a number of functions must be completed simultaneously and one after the other, such as initializing memory, devices, loading the operating system, etc. Temporal cohesion may be seen in the collection of functions in only one module that are in charge of initiating, starting, stopping, etc. certain processes. Another example that comes to mind is the functions that are executed once an exception is caught and which close opened files, notify the user, produce an error report, etc.

Procedural Cohesion:

A module is said to have procedural cohesion if its collection of functions all fall under a process (algorithm) that requires a certain order of actions to be taken in order to accomplish a goal, such as the algorithm for message decoding. The components and functions of the modules consistently run in the same order as described previously. Another example is the function that checks file permissions before opening. Additionally, the functions login (), place-order (), print bill (),… log-out(), etc., which work on distinct data but flow consecutively, may be found in the trading house’s activities.

Communicational Cohesion:

Informational cohesion is another name for communicational cohesion. Module components and functions that work on the same data are grouped together. If all of a module’s functions update or refer to the exact same information structure, such as the set of functions declared on an array or a stack, then the module has been defined as having communicational cohesion. Consider a module named student, which has functions like accepting students, entering grades, printing grade sheets, etc. All of the data is saved in an array named student records that is specified in a module. This is a further instance of informational cohesion.

Sequential Cohesion:

A module’s structure is said to have sequential cohesion if its components constitute the portions of a sequence in which one function’s result is input to the next. For instance, the get-input (), validate-input (), and sort-input () functions are all bundled into one module in a transaction-based processing system.

Functional Cohesion:

Functional cohesion is considered to occur when several components, parts, or functions of a module work together to complete a single job. Functional cohesion is shown with a module that includes all the functions needed to handle workers’ pay-roll, including compute-overtime(), compute-workhr(), compute-deduction(), etc. Although it is regarded as the module’s highest cohesion, there are times when it is not possible to achieve it, and communicational cohesion prevails over the solution.

4/5 - (1 vote)
Share:

Related Posts

Leave a Reply

Your email address will not be published. Required fields are marked *