JAVA Design Patterns Learning 3 - Overview of Design Patterns

In the previous section, it was mentioned that design patterns are divided into creation patterns, structural patterns and behavior patterns. In this section, we will learn their definitions and which specific design patterns they contain.
First, the creation mode
Creation mode is the abstraction of the instantiation process of the class. In some systems, it may be necessary to dynamically decide how to create objects, which objects to create, and how to combine and represent those objects. Creation patterns describe how to structure and encapsulate these dynamic decisions.
The creation mode is divided into two types: class creation mode and object creation mode.
1. The creation mode of the class The creation mode of the class uses the inheritance relationship to delay the creation of the class to the subclass, thus encapsulating the information of which specific classes the client will get, and hiding how the instances of these classes are created and placed. together.
2. Object creation mode The object creation mode describes the dynamic delegation of the creation process of an object to another object, so as to dynamically determine which instances of specific classes are available to the client, and how instances of these classes are created and combined.
The creation mode mainly includes: simple factory mode, factory method mode, abstract factory mode, singleton mode, multi-instance mode, construction mode, primitive mode.

2. Structural Patterns
Structural patterns describe how to combine classes or objects to form larger structures. Structural patterns also include class structural patterns and object structural patterns.
1. The structural pattern of the class The structural pattern of the class uses inheritance to combine classes, interfaces, etc., to form a larger structure. When a class inherits from a parent class and implements an interface, the new class combines the structure of the parent class with the structure of the interface. The class structure pattern is static, and the classic example of a class structure pattern is the adapter pattern.
2. The structural pattern of the object The structural pattern of the object describes how to combine various types of objects together to achieve new functions. The structural schema of objects is dynamic.
Structural patterns mainly include: adapter pattern, default adapter pattern, synthetic pattern, decoration pattern, proxy pattern, flyweight pattern, facade pattern, bridge pattern.

3. Behavior Patterns
Behavior patterns are abstractions of dividing responsibilities and algorithms among different objects. Behavioral patterns are not just about classes and objects, but about the interactions between them.
1. Behavior patterns of classes The behavior patterns of classes use inheritance relationships to distribute behavior among several classes.
2. The behavior pattern of the object The behavior pattern of the object is assigned behavior using the object aggregation class.
Behavior patterns mainly include: invariant pattern, strategy pattern, template method pattern, observer pattern, iterative sub pattern, responsibility chain pattern, command pattern, memorandum pattern, state pattern, visitor pattern, interpreter pattern, mediator pattern.

from:http://alaric.iteye.com/blog/1722199

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326720850&siteId=291194637
Recommended