Internal Poly
Definition: How tightly the inner elements of a module are bound to each other.
Classification:
- Accidental cohesion (coincidental cohesion)
- Logic cohesion (Logical cohesion)
- Time to gather (temporal cohesion)
- In-Process poly (procedural cohesion)
- Information Cohesion (informational cohesion)
- Sequential cohesion (sequential cohesion)
- Feature cohesion (functional cohesion): Elements are all designed to accomplish the same single task. One of the best ways to get cohesive.
Coupling
Definition: the degree to which the modules depend on each other
Classification:
- No coupling
- Message coupling: A more ideal coupling
- Data coupling
- Data structure coupling
- Control coupling: such as factory class
- External coupling: Two modules are not directly aware of the other modules, and there is no direct interaction between the two modules, but through the conventional "Protocol", "format", "Interface" and so on to complete the Division of labor
- Global coupling
- Content coupling: When a module relies on the internal content of another module (primarily data members), it is called content coupling. Is the worst kind of coupling.
Cohesion Poly-Low coupling
Why high cohesion and low coupling: reducing complexity
Cohesion the low coupling means that the higher the cohesion the better, the lower the coupling the better: not because the high cohesion and the low coupling are conflicting.
Class design principles (SOLID)
- srp-single Duty principle (Responsibility Principle)
- ocp-Opening and closing principle (open-closed Principle)
- lsp-Richter Replacement principle (Liskov Substitution Principle)
- Isp-Interface Isolation principle (Interface segregation Principle)
- dip-Dependency Reversal principle (Dependency inversion Principle)
Object-Oriented design principles