Six design principles of design patterns

Six design principles

1. The principle of opening and closing (open for expansion, closed for modification)

2. Richter's substitution principle (wherever the base class can appear, subclasses must appear) 3. Dependency inversion principle (rely on interface programming, rely on abstraction rather than concrete.)

4. The principle of interface isolation (using multiple isolated interfaces is better than using a single interface)

5. Dimit's law (: an entity should interact with other entities as little as possible to make the system functional modules relatively independent)

6. The principle of composition reuse (the principle is to use composition/aggregation as much as possible instead of using inheritance.)

Design Patterns

Creation mode

Factory method mode (a subclass of ReturnNew of a factory class), abstract factory mode (a subclass of a factory), singleton mode (bad guy, lazy guy), builder mode (combination), prototype mode (Cloneable shallow interface, Serializable deep interface ).

Structural model

A total of seven types: adapter mode (new interface with old implementation class), decorator mode (same as proxy, enhanced), proxy mode (before and after the method), appearance mode (computer includes...), bridge mode (intermediate table), combination mode ( Tree), Flyweight mode (shared pool).

Behavioral model

A total of eleven types: strategy mode (Calculator subclass), template method mode (elephant refrigerator), observer mode (list of observers), iteration sub mode, chain of responsibility mode, command mode (layer by layer), Memo mode (memorandum class contains memorandum object), status mode (IF), visitor mode (visit appearance mode), intermediary mode (join), interpreter mode (interpretation formula).

HeadFirst Design Pattern
6 Principles
Design Pattern Overview: Six Design Principles

Guess you like

Origin blog.csdn.net/u011148116/article/details/71617486