SRP-single Responsibility Principle
- Full name: single Responsibility Principle
- Definition: the definition of each context object (class, function, variable, etc.) should only contain a single responsibility
- Description: objects are highly encapsulated with a single responsibility. Changes to objects depend only on changes to a single responsibility. They are defined based on high cohesion in software design.
- Source: Robert C. Martin (Uncle Bob )《Agile Software Development, principles, patterns, and practices"2002
- Source: Tom Demarco 《Structured Analysis and systems SpecificationProposed cohesion 1979
- Declaration: to make our classes more robust! A class shoshould have only one reason to change!
OCP-open-closed Principle
- Full name: open-closed Principle
- Definition: context objects (classes, modules, functions, etc.) should be open to extensions and closed to modifications.
- Description: uses the object-oriented polymorphism (polymorphic) to flexibly handle changes and embrace changes.
- Implementation: 1: Abstraction and inheritance; 2: interface-Oriented Programming
- Source: Robert C. Martin (Uncle Bob )《Agile Software Development, principles, patterns, and practices"2002
- Declaration: Protecting changes and embracing changes
LSP-liskov replacement principle
ISP-interface separation principle
- Full name: interface segregation principle
- Definition: users should not be forced to rely on methods they do not need
- Description: separates large coarse-grained interfaces into small-grained interfaces with clear specifications.
- Meaning: loose coupling facilitates reconstruction Iteration
- Interface: interface-oriented programming to reduce dependencies
- Source: Robert C. Martin (Uncle Bob )《Agile Software Development, principles, patterns, and practices"2002
Dip-Dependency inversion principle
- Full name: Dependency inversion principle
- Definition: dependent on abstraction, not on specifics, because abstraction is relatively stable
- Application: decoupling in applications through dependency Injection
- Advanced modules should not depend on low-level modules. Both of them should depend on abstraction.
- Abstraction should not depend on implementation details. Implementation Details should depend on abstraction.
- Meaning: Reuse low-level modules, reuse implementation, and remove Dependencies
- Implementation: through interfaces or abstract classes
- Others: plugin, service locator, or dependency Injection
- Source: Robert C. Martin (Uncle Bob )《Agile Software Development, principles, patterns, and practices"2002
Re-engineering -- object-oriented design principles -- s.o.l. I. D Design Principles