Modules and module complexity Flashcards
Pathological module coupling
Pathological module coupling refers to a situation where modules or components in a software system are overly dependent on each other, resulting in tight coupling and reduced modularity. This can make the system difficult to maintain, test, and extend.
For following write out a very simple example code fragment in Python that illustrates it with clear comments in the code to explain why it illustrates that item: Pathological module coupling
Show example where class A instantiates class B directly and uses a method directly on class B with comments.
Communicational module cohesion
Communicational module cohesion refers to a situation where elements within a module are grouped together because they operate on the same input data or produce related output.
For following write out a very simple example code fragment in Python that illustrates it with clear comments in the code to explain why it illustrates that item: Communicational module cohesion
In this example, the DataProcessor class encapsulates functions that operate on the same input data (input_data list).
The process_data() method serves as the entry point and orchestrates the processing of the input data.
The _normalize_data(), _filter_data(), and _aggregate_data() methods are grouped together within the DataProcessor class because they all manipulate the input data in some way.
Module coupling
Module coupling refers to the degree of interdependence between modules or components within a software system. It measures how closely connected or reliant one module is on another.
Module cohesion
Module cohesion refers to the degree to which elements within a module are logically related and work together to achieve a common purpose or functionality. It measures how well the elements within a module are integrated and focused on a single task or responsibility. Cohesion is a key aspect of modular design and helps determine the quality and maintainability of software systems.
You are part of a team writing a system which keeps track of parcels in a delivery company.
State and describe TWO types of beneficial module couplings that may be present in this piece of software.
Functional coupling occurs when modules collaborate to achieve a common functionality or feature. In the parcel tracking system, functional coupling can be beneficially employed to ensure that related functions work together seamlessly to handle different aspects of parcel tracking.
Data coupling occurs when modules communicate by passing data as parameters or return values, without sharing internal details or state. In the parcel tracking system, data coupling can be beneficially used to ensure that modules exchange parcel-related information without direct dependencies on each other’s internal implementations.
You are part of a team writing a system which keeps track of parcels in a delivery company.
It has the following functions: generateBarcode(), createDatabaseRecord(), updateDatabaseRecord(), decodeBarcodeAndUpdateParcelPosition(), getParcelPosition().
For each function, pick an example of possible module cohesion and explain the type
of that module cohesion.
generateBarcode(): Functional Cohesion
createDatabaseRecord(): Communicational Cohesion
updateDatabaseRecord(): Procedural Cohesion
decodeBarcodeAndUpdateParcelPosition(): Sequential Cohesion
getParcelPosition(): Data Cohesion
Functional Cohesion
Modules with functional cohesion have elements that are grouped together to perform a single, well-defined function or task.
Communicational Cohesion
Modules with communicational cohesion have elements that operate on the same data or input/output parameters.
Procedural Cohesion
Modules with procedural cohesion have elements that are grouped together because they are part of a sequence of steps within a procedure or algorithm.
Sequential Cohesion
Modules with sequential cohesion have elements that are executed in a specific order, with the output of one element being the input of the next.
Data Cohesion
Data cohesion is a type of module cohesion that occurs when elements within a module are grouped together because they operate on the same set of data or share common data structures.
We know that function updateDatabaseRecord() alters the actions of function createDatabaseRecord().
State and describe the type of module coupling that exists in the code containing these two functions.
Content coupling occurs when one module directly modifies or relies on the internal workings or data of another module.
You are part of a team writing a system which keeps track of the bags at an airport, routing them between check-in, planes, and baggage collection. The software has the following functions: updateDatabaseRecord(), decodeBarcodeAndUpdateBagPosition(), getBagPosition(), countBagsAtLocation().
Define and describe each functions cohesion.
updateDatabaseRecord(): Functional cohesion
decodeBarcodeAndUpdateBagPosition(): Sequential Cohesion
getBagPosition(): Communicational Cohesion
countBagsAtLocation(): Sequential Cohesion