0% found this document useful (0 votes)
16 views

Cohesion

Uploaded by

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

Cohesion

Uploaded by

Utkarsh Gupta
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 6
A. COHESION * Cohesion may be viewed as the glue that keeps the module together. * It is a measure of the mutual affinity of the elements of a module. * Cohesion measures the strength of relationships between pieces of functionality within a given module. * Agood software design will have high cohesion. Module : : Strength Cohesion= Strength of relations within Modules » . Functional Cohesion Functional Cohesion is said to exist if the different elements | FUNCTIONAPart 1 of a module, cooperate to achieve a single function. FUNCTIONA Part 2 + All the elements within the module contribute to achieving the same objective. * This type of cohesion is considered the most desirable & strongest. + Examples — Reading transaction records, Seat assignment to an airline passenger FUNCTION A Part 3 2. Sequential Cohesion: + Elements are organized in a linear sequence, where the output of one element becomes the input of the next. + The elements are executed in a step-by-step manner to achieve a particular functionality. + Examples: — Cross-validated records & formatting of a module, raw records usage — Enter the number > Perform addition of that number > Display Addition FUNCTIONA FUNCTION 8 FUNCTION 3. Communicational Cohesion + Communicational cohesion occurs when the elements within a module operate on the same input data or share data through parameters. + The elements within the module work together by passing data to each other. + Example : DATA FUNCTION A FUNCTION B FUNCTION C — Amodule use the usage of a customer account number, then find the name of the customer and find the loan balance of the customer — The set of functions defined on an array or a stack. 4. Procedural Cohesion + Procedural cohesion occurs when the elements within a module are grouped based on a specific sequence of actions or steps. + Example FUNCTIONA FUNCTION B FUNCTION — Calculate student GPA, print student record, calculate cumulative GPA, print cumulative GPA 5. Temporal Cohesion * Temporal cohesion occurs when the elements TIME TO within a module are executed at the same time or TIME TO+A within the same timeframe. + The elements are related by their timing involved. + Example — Login and shutdown processes * Logical cohesion occurs when the elements within a module are logically related, but do not fit into any other cohesion types. + The elements are Jogically related and not functionally. + Example : — A component reads inputs from tape, disk, and network. TIME TO+2A FUNCTION A Viogic FUNCTION A { FUNCTION A 7. Coincidental Cohesion: FUNCTION | Coincidental cohesion occurs when the elements are not related to each other. Function + Example FUNCTION tm FUNCTION — print next line and reverse the characters of a string . ina single component. ® aT T7 eohes \g \g Kf [A 7 Coincidental cohesion Conditional cohesion Iterative cohesion Qs O° i] Ka ja al : ss i id a Pol coin Communication! cbson__Sequenta eesion Data Coupling =m Types of coupling (Dscecc) ero) No Direct Coupling: There is no direct coupling between M1 and M2. 1. Data Coupling: * Data coupling occurs when modules share data through parameters or arguments. + Each module maintains its own data and does not exactly access or modify the data of other modules. * This type of coupling promotes encapsulation & module interdependence. bale Module 1 “ Ne (Argument i | Module 2 ‘-isCarvaleble(sRertaReques 1 resereacen - eaten] 2. Stamp Coupling * Stamp coupling occurs between modules when data are passed by parameters using a data structure containing fields which may or may not be used. + No junk or unused data will be shared between the two coupling modules. Modulet | (Data structures) CS (contin ‘Module 2 io Module retrieves customer address using only customer id which is extracted from a parameter named customer details. 4. Control Coupling: Control coupling occurs when one module controls the behavior of another module. Control coupling occurs between modules when data are passed that influence the internal logic of a module (e.g,, flags and switches). This type of coupling implies that one module has knowledge of internal odie workings & decisions or another wens module, that makes the code more difficult to maintain. + When module 1 passes control data to’ module 2 then the module 2 will perform its complete function . So control is passed via a flag on which decisions are made from a super ordinate module toa cuhardinate madile 5. External Coupling: * External coupling can be described as a situation where the modules are interrelated with common external influencing factors. = They can be: — An external legacy application that sends the same set of data or contents to both modules — Ahardware requirement common for both modules — Acommon file/ folder in use by both modules — When both use same switch/router in the network for communication. 6. Common Coupling: * Common coupling occurs when two or more modules in | = the system share global data. ; Liss + The modules can access & manipulate the same global (Global data ) variables & the data structures. \ oe Update Grade 6. Content Coupling * Content coupling occurs when one module directly accesses or modifies the content of another module. * Content coupling should never be used when designing modules. * One module depends on the implementation of the other module. odie motes

You might also like