One of the Java design modes (summary)

xiaoxiao2021-03-18  200

Master the design model, which is conducive to the development, beneficial to the system's multiplexing. It can be said that the programmer only has the same design, understanding the essence, can play its own coding to the highest level. Due to the time relationship, it has not been able to read the design mode, and each time is intermittent. . . . Today, I have time to study, I plan to take time and energy to summarize the related usage in Java design mode, and summarize the information from some of the online information, plus some of the individual's experience and experience. Gossip doesn't have to say more, the words come forward.

In general, Java is divided into 23 design patterns. We classify two criteria.

The first criterion (purpose):

The mode is used to complete what work. It can be divided into: Create type (related to object creation), structural (handling class or object), behavioral type (how to interact with the class or object and how to assign responsibility).

Second Guidelines:

The specified mode is mainly used for classes or for objects. The relationship between class mode processing classes and subclasses, these relationships are built by inheriting, static, determining it when compiling. The relationship between the object mode processing objects, which can be varied, more dynamic. In a sense, almost all modes use the inheritance mechanism. "Class Mode" only refers to the model that focuses on the relationship between the processing class, and most of the models belong to the category of the object mode.

Overview

1.

Creating types of class mode Delayed the part of the object to the subclass, and the created object mode delays it into another object.

2.

The structural class mode uses the inheritance mechanism to combine classes, and the structural object mode describes the assembly method of the object.

3.

Behavioral type mode Use inheritors describing algorithms and control flows, and behavioral object modes describe how a set of objects do not complete with a single object.

As shown in the following table:

Creation

Structural type

Behavior

class

Factory method

(

Factory Method

)

adapter

(class:

Adapter

)

Interpreter

(

Interpreter

)

Template method

(

Template Method

)

Object

Abstract factory

(

Abstract Factory

)

Builder

(

Builder

)

prototype

(

Prototype

)

a piece

(

Singleton

)

adapter

(Object:

Adapter

)

bridging

(

Bridge

)

combination

(

Composite

)

decoration

(

Decorator

)

Exterior

(

FACADE

)

Enjoish

(

Flyweight

)

proxy

(

Proxy

)

Duties

(

Chain of Responsibilit

Y)

command

(

Command

)

Iterator

(

Iterator

)

Intermediaries

(

Mediator

)

memorandum

(

MEMENTO

)

Observers

(

Observer

)

status

(

State

Strategy

(

Strategy

)

Visitor

(

Visitor

)

转载请注明原文地址:https://www.9cbs.com/read-129827.html

New Post(0)