Seven principles of object-oriented, six principles of design patterns

  • Single responsibility principle: the responsibility of the class should be single, and too many responsibilities cannot be put into one class

  • The principle of opening and closing: the software entity is open for expansion, but closed for modification, that is, to expand its functions without modifying a software entity

  • The principle of Richter's generation return: In a software system, a place that can accept a base class object must accept a subclass object

  • Dependency inversion principle: programming for the abstract layer (abstract class or interface) instead of programming for specific classes

  • Interface isolation principle: use a dedicated interface to replace a unified interface

  • Synthetic reuse principle: When multiplexing functions, you should try to use combination and aggregation relationships as much as possible, and use as little or no integration as possible.

  • The principle of Dimit's rule: the less references a software entity has to other entities, the better, or if two classes do not have to communicate directly with each other, then the two classes should not directly interact, but by introducing a third Indirect interaction

Note: The single responsibility principle is not a design principle

Single responsibility principle:

Every design object conforms to one or more object-oriented design principles

The responsibilities of the class mainly include two aspects: data responsibility (attribute reflection) and line) responsibility (method reflection)

Guess you like

Origin blog.csdn.net/qq_36138652/article/details/115294298