Type design patterns

The reference design patterns Design Patterns - Elements of Reusable Object-Oriented Software (Chinese translation: Design Mode - object-oriented software elements, reusable) mentioned, a total of 23 design patterns. These patterns can be divided into three categories:

  ① create a schema (Creational Patterns)

  ② structural model (Structural Patterns)

  ③ type of model (Behavioral Patterns)


  ④J2EE design patterns.

1. Create a schema

  These designs provide a way to hide the pattern created while creating a logical object, rather than directly instantiated objects using the new operator. This makes the program more flexible when determining which objects need to be created for a given instance

2. Structural model

  These design patterns focus on a combination of classes and objects. The concept of inheritance is used to define a combination of interfaces and combinations of new features of the object.

3. behavioral patterns

  The design mode is particularly concerned about the communication between objects.

4. J2EE mode

  The design mode is particularly concerned about the presentation layer, the design pattern is identified by the Sun Java Center.

The relationship between design patterns:
The relationship between design patterns

Six principles of design patterns

1, the opening and closing principle (Open Close Principle)

  The principle of opening and closing means: open for extension, but closed for modification. When the program needs to expand, not to modify the existing code to achieve the effect of a hot-swappable. In short, it is to make good, easy to maintain and upgrade the extension of the program. Want to achieve this effect, we need to use interfaces and abstract classes, follow the detailed design, we will mention this point.

2, Richter substitution principle (Liskov Substitution Principle)

  Richter substitution principle is one of the basic principles of object-oriented design. Richter substitution principle in that place any base class can appear, sub-class will be able to appear. LSP is inherited cornerstone multiplexed only when the derived class can replace the base class, and the software unit of functionality is not affected, the base class can really be reused, and the derived class can add new on the basis of the base class on behavior. Richter substitution principle is the principle of complementarity closed off. Implement the principle of opening and closing is a key step in abstraction, inheritance and base class and sub-class is the abstract concrete realization, so Richter substitution principle is the specification for concrete steps to achieve the abstract.

3. Dependency Inversion Principle (Dependence Inversion Principle)

  This principle is the basis of the principle of opening and closing, the specific content: for interface programming, depend on the abstract rather than relying on specific.

4, the interface segregation principle (Interface Segregation Principle)

  This principle means that: a plurality of interface isolation, is better than using a single interface. It also has another meaning is: to reduce the coupling between classes. Thus, the fact that design patterns from large-scale software architecture, easy to upgrade and maintain the software design, which emphasizes reducing reliance, reduce coupling.

5, Demeter, also known as the least known principle (Demeter Principle)

  It refers to the least known principle: an entity should occur as little as possible interaction between the entity and the other, such that the independent function modules.

6, the synthesis of multiplexing principles (Composite Reuse Principle)

  Synthesis multiplexing principle is that: the way to make use of synthetic polymeric / instead of inheritance.

Source runoob.com  design patterns learning

Guess you like

Origin www.cnblogs.com/Java-Script/p/11089939.html