Modules and module complexity Flashcards

1
Q

Pathological module coupling

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

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

A

Show example where class A instantiates class B directly and uses a method directly on class B with comments.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Communicational module cohesion

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

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

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Module coupling

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Module cohesion

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

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.

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

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.

A

generateBarcode(): Functional Cohesion
createDatabaseRecord(): Communicational Cohesion
updateDatabaseRecord(): Procedural Cohesion
decodeBarcodeAndUpdateParcelPosition(): Sequential Cohesion
getParcelPosition(): Data Cohesion

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Functional Cohesion

A

Modules with functional cohesion have elements that are grouped together to perform a single, well-defined function or task.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Communicational Cohesion

A

Modules with communicational cohesion have elements that operate on the same data or input/output parameters.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Procedural Cohesion

A

Modules with procedural cohesion have elements that are grouped together because they are part of a sequence of steps within a procedure or algorithm.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Sequential Cohesion

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Data Cohesion

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

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.

A

Content coupling occurs when one module directly modifies or relies on the internal workings or data of another module.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

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.

A

updateDatabaseRecord(): Functional cohesion

decodeBarcodeAndUpdateBagPosition(): Sequential Cohesion

getBagPosition(): Communicational Cohesion

countBagsAtLocation(): Sequential Cohesion

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

State and describe two types of coupling that you should try to avoid when implementing a program.

A

Common coupling: When multiple modules share the same global data or resources, such as global variables.

Content coupling: When one module directly accesses or modifies the internal implementation details (e.g., variables, functions, data structures) of another module.

17
Q

Loose coupling

A

It refers to the degree of interdependence between modules, where low coupling indicates that modules are relatively independent and changes in one module have minimal impact on other modules.

18
Q

Tight coupling

A

In a tightly coupled system, modules are highly dependent on each other, often relying on specific details of each other’s implementation. Changes to one module can have a significant impact on other modules, making the system less flexible and more difficult to maintain.

19
Q

Modular Programming in Python

A

Python supports modules, packages, and namespaces and it’s module system allows for code to be organised into reusable and maintainable units. The import system and package management tools like pip promote the use of third-party libraries and external dependencies, further enhancing modularity.

20
Q

Modular Programming in Javascript

A

JavaScript supports modules (ES6 modules) and CommonJS modules, which helps organising code into separate files or modules. Tools like npm and webpack, fosters a modular approach to development by facilitating dependency management, bundling, and code splitting.

21
Q

In “Structural Epochs in the Complexity of Software over Time” (2008), Sangwan et al. introduce the concepts of ‘Fat’ and ‘Tangle’. Explain these terms, as they refer to module coupling.

A

A module is considered “fat” when it exhibits high coupling with other modules within the software system. Fat modules typically have numerous dependencies on other modules, leading to a dense network of interconnections.

In a tangle, modules exhibit high coupling, with dependencies spanning across multiple modules in a non-linear and tangled manner. This makes it challenging to understand the flow of data and control within the system and can lead to difficulties in managing and modifying the codebase.

22
Q

You find that one function in the code you have found, alters the actions of another function.

State and describe the type of module coupling present in the
code.

A

Content Coupling occurs when one module (function) directly modifies or accesses the internal variables or logic of another module. In this type of coupling, the modules are tightly intertwined, and changes to one module can have direct effects on the behavior or state of another module.

23
Q

Content Coupling

A

Content coupling occurs when one module directly accesses or modifies the internal implementation details (e.g., variables, functions, data structures) of another module.

24
Q

Common Coupling

A

Common coupling occurs when multiple modules share the same global data or resources, such as global variables, files, or databases.

25
Q

Control Coupling

A

Control coupling occurs when one module passes control information (e.g., flags, status codes) to another module to influence its behavior.

26
Q

Stamp Coupling

A

Stamp coupling occurs when modules communicate by passing a large data structure or record containing multiple fields, but only a subset of the fields is used by the receiving module.

27
Q

Data Coupling

A

Data coupling occurs when modules communicate by passing data parameters or arguments to each other.

28
Q

External Coupling

A

External coupling occurs when modules depend on external entities, such as files, databases, or external libraries.