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