四巨头GoF的《设计模式》中23种设计模式的UML图 - 4 of 4

这篇博客详细介绍了设计模式中的四种经典模式:单例模式确保类只有一个实例并提供全局访问点;状态模式允许上下文对象在内部状态改变时改变其行为;策略模式定义一组算法并使它们在上下文中互换,让算法独立于使用它的客户;工厂方法模式由子类决定创建哪个类的对象,使类的实例化推迟到子类;外观模式为子系统提供统一接口,简化使用;组合模式将组件对象组成树形结构来表示部分-整体层次,使得客户端可以一致地处理单个对象和组合对象。
摘要由CSDN通过智能技术生成

Singleton: Ensure a SINGLETON class only has one instance, and provide a global point of access to it.




State: Allow a CONTEXT object to alter its behavior when its internal STATE changes. The CONTEXT object will appear to change its class.



*Strategy: A STRATEGY defines a family of algorithms, encapsulate each one, and make them interchangeable by holding a STRATEGY in a CONTEXT. Strategy lets the algorithm vary independently from clients that use it.


CCOR
5. Algorithmic dependencies. 
7. Extending functionality by subclassing. 


Facade: A FA?ADE provides a unified interface to a set of interfaces in a subsystem. Facade defines a higher-level interface that makes the subsystem easier to use.


CCOR
6. Tight coupling. 


*Factory Method: A CREATOR defines an interface for creating an object in a factory method, but let a subclassed CONCRETE CREATOR decide which class to instantiate. Factory Method lets a class defer instantiation to subclasses.


CCOR
1. Creating an object by specifying a class explicitly. 


Flyweight: A FLYWEIGHT FACTORY uses sharing in a pool to support large numbers of fine-grained CONCRETE FLYWEIGHT objects efficiently.
 


Chain of Responsibility: Avoid coupling the sender of a request to its receiver by giving more than one HANDLER object a chance to handle the request. The HANDLER chains the receiving objects by holding a successor HANDLER and pass the request along the chain until an object handles it.
 
CCOR

2. Dependence on specific operations. 
6. Tight coupling. 
7. Extending functionality by subclassing. 


Command: A CONCRETE COMMAND encapsulates a request action in a RECEIVER as a CONCRETE COMMAND object, thereby letting an INVOKER parameterize clients with different requests, queue or log requests, and support undoable operations in CONCRETE COMMANDS.
 

CCOR
2. Dependence on specific operations. 
6. Tight coupling. 


*Composite: A COMPOSITE composes COMPONENT objects into tree structures to represent part-whole hierarchies. Composite lets clients treat individual LEAF objects and compositions of COMPOSITE objects uniformly.
 

CCOR
7. Extending functionality by subclassing. 



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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值