职责驱动设计(Responsibility-Driven Design)
对私有封装数据的认知 knowing about private encapsulated data
对相关对象的认知 knowing about related objects
对其能够导出或计算的事物的认知 knowing about things it can derive or
对象的认知职责(Knowing responsibilities)包括:
初始化其他对象中的动作 initiating action in other objects
控制和协调其他对象中的活动 controlling and coordinating activities in other
自身执行一些行为,如创建或计算 doing something itself, such as creating an
object or doing a calculation
对象的行为职责(Doing responsibilities)包括:
Abstract Factory(抽象工厂)、Singleton(单实例)
Adapter(适配器)、Composite(组合)、Facade(外观)
Observer(观察者)、Strategy(策略)
通过中介适配器对象,将构件的原有接口转换为其他接口
适配器模式的宗旨是,保留现有类提供的服务,向客户提供接口,以满足客户的期
对于一个已经存在的类,如果它的接口与现有系统的需求不同时,可以考虑用适配
是GoF抽象工厂(Abstract Factory)模式的简化
解决方案:创建称为工厂的纯虚构对象来处理这些创建职责
问题:如何只创建唯一实例的类即“单实例类”?如何使对象具有全局可见性并且
评论0