Topic 2 Flashcards
Module Cohesion
What does cohesion measure in a module?
The degree to which the elements within a module are related to each other.
- Highly cohesive = perform single task/grp of related task
- Low cohesion = perform variety of unrelated task
What characterizes a highly cohesive module?
It performs a single task or a group of related tasks.
What characterizes a module with low cohesion?
It performs a variety of unrelated tasks.
What are the four aspects to consider in module cohesion?
- Strength
- Content
- Interrelatedness
(degree of tasks performed within a module related to each other) - Association
(extent of things within a module associated w each other)
What does high cohesion indicate about a module’s focus?
A highly cohesive module is focused on a specific responsibility or functionality.
- Low cohesion = Divergence
High cohesion = Focus
What is an example of high module cohesion in an e-commerce system?
A user management module that handles only user-related operations.
What is an example of low module cohesion?
A class that multiplies two numbers and also creates a pop-up window displaying the result.
What are the 12 factors to consider for cohesion maintenance?
- Single Responsibility
- Functional Consistency
- Data and Operation Grouping
- Interface Simplicity
- Internal Dependencies
- Ease of Understanding
- Code Reusability
- Encapsulation
- Change Impact
- Consistency
- Granularity
- Responsibility Clarity
What is the benefit of single responsibility (1) in a module?
Ensure that changes to the module affect only 1 part of the system
- Makes it easier to understand & maintain
What is the benefit of functional consistency (2) in a module?
Promotes logical grouping of related operations
*Enhances readability and usability
What does data and operation grouping (3) facilitate?
Encapsulation and reduces the need for exposing internal details of the module.
What is the benefit of interface simplicity (4) in module design?
Simplifies interaction with other parts of the system and reduces potential for misuse or errors.
What does high internal dependency (5) within a module suggest?
It often means that components are tightly coupled within the module but loosely coupled with others.
What is the benefit of ease of understanding (6) for a module?
Facilitates easier debugging, modification, and enhancement.
What is a key benefit of code reusability (7) in modules?
Encourages the creation of modular, adaptable components.
What does encapsulation (8) enhance in a module?
Maintainability and reduces the risk of unintended interactions with other modules.
What is the impact of change (9) on modules with high cohesion?
Minimizes the ripple effect of changes, making modifications easier.
What does consistency (10) in module design increase?
Readability and reduces the learning curve for developers.
What is granularity (11) in module design?
The level of detail or size of the module.
- Modules too granular
= cumbersome - Modules too broad
= complex
What does responsibility clarity (12) in a module help with?
Easier management, extension, and debugging of the module.
What are the levels of cohesion, from high to low?
- Function
- Communication
- Coincidental
- Logical
- Sequence
- Procedural
- Temporal
- Function (Highest)
- Sequence
- Communication
- Procedural
- Temporal
- Logical
- Coincidental (Lowest)
What is functional cohesion?
When the module performs a single, well-defined task.
- process is same, so same output every time regardless of input
What is an example of sequential cohesion?
A module that processes data by reading input, transforming it, and writing the output.
- Useful for processes where operations are closely related and need to be executed in specific order
What characterizes communicational cohesion?
When the module performs a series of operations on the same data.