Lecture 8 - Design Concepts and Principles Flashcards
(41 cards)
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