设计模式

Abstract factory

You want to create objects of a selected family of classes but you don’t want the client to be affected by the choice.

Adapter

You want to convert one interface to another because they do not match and cannot be changed.

Bridge

You want to switch between different implementations at run time without affecting the client.

Builder

You want an abstraction of a process and a set of steps to build a product so that you can combine implementations of the two at run time to produce various categories of products using different processes.

Chain of responsibility

You want to pass a request along a reconfigurable chain of handlers until one that handles it.

Command

You want to encapsulate requests as (command) objects so that you can: (1) delegate the requests to the command objects, (2) queue the requests and execute them at a different time, (3) generate a plan of actions dynamically, and/or (4) stack the requests to support undo and redo.

Composite

You want to represent components with recursive part-whole relationships and allow the client to interact with components and composites uniformly.

Decorator

You want to dynamically add/remove functionality to/from objects.

Facade

You want to simplify a client's interface and interaction  to a web of components.

Factory method

You want to create/use objects of a chosen class but you don't want to know, make, or be affected by the choice.

Flyweight

You want to save time and space incurred in the creation, initialization, and storage of many occurrences of an object.

Interpreter

You want dynamic modification of a portion of your program but you don't want to recompile the system.

Iterator

You want a traversal mechanism that hides the structure traversed.

Mediator

You want to replace m-m or component to component interaction with m-1 or component to mediator interaction.

Memento

You want to store and restore the state of an object but you don't want to expose the internals of the state to a third party.

Observer

You want to decouple change and related responses so that you can add or remove such dependencies freely and dynamically.

Prototype

You want to: (1) reduce object creation and initialization costs, (2) reduce number of classes, or (3) use dynamically loaded classes.

Proxy

You want to: (1) hide the use of a remote object, (2)  defer creation of an object until it is actually used, (3) control access to an object, or (4) keep track of references or update to an object. 

Singleton

You want to create at most one or a limited number of globally accessible instances of a class.

State

You want a low complexity and easy to extend solution to implement a state machine.

Strategy

You want to let the client select an algorithm from available algorithms to accomplish a given task.

Template method

You want the steps of a computation to vary but you don't want to do so with conditional statements.

Visitor

You want to decouple certain functionality from a class structure so that it can be applied to other class structures as well.



龚老师的总结



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值