随笔- 254
文章- 1
评论- 10
阅读-
34万
随笔分类 - Design patterns
abstract factory -- 创建相互关联的类
摘要:Function:Provide an interface for creating families of related or dependent objects without specifying their concrete classes. Participants:AbstractFactory(ContinentFactory) declares an interface for ...
阅读全文
template -- 自定义执行顺序固定的几个方法
摘要:Function:Lets subclasses redefine certain steps of an algorithm without changing the algorithm's structureActor:
阅读全文
singleton -- 创建static类型的对象
摘要:Function: Make sure that in an application exists only one instance of a class.Actors:
阅读全文
facade -- 对于有很多接口的提供一个简单的接口
摘要:Function:A facade is an object that provides a simplified interface to a larger body of code, such as a class library. A facade can:make a software library easier to use and understand, since the faca...
阅读全文
decorate -- 通过反复包含对像,并对已包含对象方法添加功能
摘要:Function:The decorator pattern can be used to make it possible to extend (decorate) the functionality of a class at runtime.Actors:FunctionInterface, BasicFunctionClass, decorator, concreteDecoratorSu...
阅读全文
command -- 把动作封装成类
摘要:Function: Decouple the object that invokers the operation, by creating class for operations.Actors:Client, Invoker, command, concreteCommand, receiverSummary:
阅读全文
Adapter --连接连个不同接口
摘要:Function:Create a new interface(like a adapter or wrapper) between client and class of library. So when use another library, just need to modify the adapter without letting the client knows the change...
阅读全文
Visitor -- 对于相似对象全部添加相应的处理方法
摘要:访问者 visitor的本质是创建若干个各个类型Element的子类SubElement,子类中提供visit(Vistior v)方法,因为SubElement知道自己的类型,所以可以在visit(v)方法中自己决定visitor调用哪个方法来处理SubElement.而不需要在Visitor中根据Element的类型来判断需要执行哪个方法 (instanceof)
阅读全文