Lecture 8 - Design Concepts and Principles Flashcards
Compartmentalization of data and function in software represents…
Modularity
What is a procedure in software?
Algorithm that achieves a function
The degree to which a module performs one and only one function describes which Functional Independence?
Cohesion
The degree to which a module is “connected” to other modules in the system describes which Functional Independence?
Coupling
When one module directly accesses or modifies the internal data or methods of another module, what type of coupling is it?
Content coupling
class ModuleA { public int data; public void setData(int value) { this.data = value; } } class ModuleB { public void modifyData(ModuleA ma) { moduleA.data = 42; } }
The following is an example of what type of coupling?
Content coupling
Multiple modules sharing the same global data/resource where changes to shared resource can affect multiple modules is what type of coupling?
Common coupling
TF: Common coupling has a high level of interdependence
True
class CommonData { public static int sharedValue = 0; } class ModuleA { public void incrementSharedValue() { CommonData.sharedValue++; } } class ModuleB { public void decrementSharedValue() { CommonData.sharedValue--; } }
The following is an example of what type of coupling?
Common coupling
One module influencing the control flow of another module, usually passing control information (flags, parameters) is what type of coupling?
Control coupling
class ModuleA { public void process(boolean flag) { if (flag) { // Perform certain actions } else { // Perform other actions } } } class ModuleB { public void controlModuleA() { ModuleA moduleA = new ModuleA(); moduleA.process(true); // Control flag passed } }
The following is an example of what type of coupling?
Control coupling
Modules sharing data structures such as records or arrays and only use a portion of that data is what type of coupling?
Stamp Coupling
What is one disadvantage of Stamp coupling?
Sharing of data structures and only using parts of it can lead to inefficiencies and unnecessary dependencies
Modules communicating by passing data as parameters or through method calls is what kind of coupling?
Data coupling
class ModuleA { public int add(int x, int y) { return x + y; } } class ModuleB { public void performOperation() { ModuleA moduleA = new ModuleA(); int result = moduleA.add(3, 4); System.out.println("Result: " + result); } }
The following is an example of what type of coupling?
Data coupling
Modules communicating by sending messages to each other, using queues or events is what kind of coupling?
Message coupling
TF: Message coupling is a worse design practice than data coupling
False. Better design since reduces direct dependencies between modules
Modules that are entirely independent of each other is what kind of coupling?
No coupling
TF: Coincidental cohesion is the strongest cohesion
False. Weakest cohesion
What is coincidental cohesion?
When elements of a module doesn’t share any common purpose, grouped arbitrarily
Elements within a module are grouped together because they perform related tasks describes what type of cohesion?
Logical cohesion
public class CohesionExample { public void validateInput() { // Validate user input } public void calculateResult() { // Perform calculations } public void displayOutput() { // Display the result } }
This is an example of what type of cohesion?
Logical cohesion
Execution of elements is at the same time - such as during a single function call or at a specific event - is considered what type of cohesion?
Temporal cohesion
public class CohesionExample { public void processOrder() { // Validate order // Calculate total // Generate invoice } }
This is an example of what type of cohesion?
Temporal cohesion
Components of a module grouped together because they always follow a specific sequence of execution is considered what type of cohesion?
Procedural cohesion
public class CohesionExample { public void performInitialization() { // Initialize variables // Load configuration } public void performCleanup() { // Close connections // Clean up resources } }
This is an example of what type of cohesion?
Procedural cohesion
Components of a module grouped together because they operate on the same input data or communicate with same external entity is considered what type of cohesion?
Communicational cohesion
public class CohesionExample { public void readData() { // Read data from a file } public void processData() { // Process the read data } }
This is an example of what type of cohesion?
Communicational cohesion
Components of a module grouped together such that the output of one element serves as the input for the next is considered what type of cohesion?
Sequential cohesion
public class CohesionExample { public void performStep1() { // Step 1 of a multi-step process } public void performStep2() { // Step 2 of the process } }
This is an example of what type of cohesion?
Sequential cohesion
All components of a module working together to perform a single, well-defined task or function, where each module contributes to overall purpose is considered what type of cohesion?
Functional cohesion
TF: Functional cohesion is the strongest cohesion
True
public class CohesionExample { public void calculateTotal(int[] items) { // Calculate the total cost of items } }
This is an example of what type of cohesion?
Functional cohesion
Elements of a module grouped together because they operate on the same data or share a common data structure is considered what type of cohesion?
Informational cohesion
When is informational cohesion most commonly used in?
Data-centric modules
public class CohesionExample { private int[] data; public void processData() { // Process data stored in the 'data' array } }
This is an example of what type of cohesion?
Informational cohesion
TF: Temporal cohesion is considered strong cohesion when elements in a module are executed together at same time, and their execution order crucial to achieving module’s specific purpose
True
What aspect of architectural design representation defines the components of a system (modules, objects) and how they are packaged to encapsulate both data and processing of the data?
Structural properties
What architectural design description addresses how design architecture achieves requirements for performance, capacity, reliability, etc.?
Extra-functional properties
What aspect architectural design draws upon repeatable patterns that are commonly encountered in design of similar systems?
Families of related systems
“Design should have the ability to reuse architectural building blocks” relates to what aspect of architectural design?
Families of related systems