Final Flashcards
What are advantages of modularity?
Advantages of Modularity: - Minimizes Complexity - Reusability - Extensibility - Portability - Maintanability
What does SOLID stand for?
SOLID is a combination of principles: S - Solid Responsibility Principle O - Open/Closed Principle L - Liskov Substitution Principle I - Interface Segregation Principle D - Dependency Inversion Principle
State the single responsibility principle.
Single responsibility principle: a class should have only a single responsibility.
What is cohesion?
Cohesion refers to how closely the functions in a module are related.
What is cohesion?
Cohesion refers to how closely the functions in a module are related.
The Or-check.
A class description that describes a class in terms of alternatives is probably not a class but a set of classes.
Name 7 types of cohesion.
1) Coincidental cohesion (bad)
2) Logical cohesion (bad)
3) Temporal cohesion
4) Procedural cohesion
5) Communicational cohesion
6) Sequential cohesion (very good)
7) Functional cohesion (best)
What is the advantage and disadvantage of functional cohesion?
Functional cohesion.
Advantage: Cohesive objects are easy to reuse and understand.
Disadvantage: Functionally cohesive objects can proliferate and get very tiny.
What does coupling do?
Coupling assesses how tightly a module is related to other modules. Goal is loose coupling - modules should depend on as few other modules as possible.
Name 9 types of coupling.
Types of Coupling:
- Content Coupling (high)
- Stamp Coupling (Data-structured coupling)
- Common Coupling
- Data Coupling
- External Coupling
- Message Coupling (low)
- Control Coupling
- No Coupling
- Semantic Coupling
Desine semantic coupling.
Semantic coumpling is the most insidious kind of coupling, occurs when one module makes use not of some syntactic element of another module but of some semantic knowledge of another module’s inner workings.
Why is semantic coupling dangerous?
Semantic coupling is dangerous because changing code in the used module can break code in the using module in ways that are completely undetectable by the compiler. When code like this breaks, it breaks in subtle ways that seem unrelated to the change made in the used module, which turns debugging into a Sisyphean task.
State the open/closed principle.
A class must be closed for internal change, but must be open for extensions.
State the Liskov Substitution Principle.
Liskov Substitution Principle:
If S is a subtype of T, then objects of type T in a program may be replaced with objects of type S without altering any of the desirable properties of that program.
- Subclass has same or weaker preconditions
- Subclass has same or stronger postconditions
State the Interface Segregation Principle.
Interface Segregation Principle:
No client should be forced to depend on methods it does not use. Clients need only know about the methods that are of interest to them