`
tianyalinfeng
  • 浏览: 432549 次
  • 性别: Icon_minigender_1
  • 来自: 苏州
社区版块
存档分类
最新评论

DesignPattern

    博客分类:
  • Java
 
阅读更多

* A pattern has four elements:

1.Pattern name

2.Problem

3.Solution

4.Consequences

 

* Patterns are divided into three types:

1.Creational patterns

 

Factory Method

provides a simple decision making class that returns one of several possible subclasses of an abstract base class depending on the data that are provided.

 

Abstract Factory

provides an interface to create and return one of several families of related objects.

 

Builder

separates the construction of a complex object from its representation, so that several different representations can be created depending on the needs of the program.

 

Prototype

starts with an initialized and instantiated class and copies or clones it to make new instances rather than creating new instances.

 

Singleton

is a class of which there can be no more than one instance. It provides a single global point of access to that instance.

 

2.Structural patterns

 

Adapter 

Bridge 

Composite 

Decorator 

Facade 

Flyweight 

Proxy

 

3.Behavioral patterns

 

Chain of Responsibility

Command

Interpreter

Iterator

Mediator

Memento

Observer

State

Strategy

Template Method

Visitor

 

 

*Major precepts

1.Program to an interface and not to an implementation

2.Favor object composition over inheritance 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics