随笔分类 - 设计模式
摘要:Intent (定义) Given a language, define a representation for its grammar along with an interpreter that uses the representation to interpret sentences in
阅读全文
摘要:Intent(定义) Encapsulate a request as an object, thereby letting you parameterize clients with different requests, queue or log requests, and support un
阅读全文
摘要:Intent (定义) Avoid coupling the sender of a request to its receiver by giving more than one object a chance to handle the request. Chain the receiving
阅读全文
摘要:Intent (定义) Provide a surrogate or placeholder for another object to control access to it.(为另一个对象提供代理或占位符,以控制对它的访问。) Also Known As (别名) Surrogate Moti
阅读全文
摘要:Intent (定义) Use sharing to support large numbers of fine-grained objects efficiently(使用共享可以有效地支持大量的细粒度对象。) Motivation (详细说明) 如下图所示,这是一个文档编辑器,有字符对象,列对象
阅读全文
摘要:Intent (定义) Provide a unified interface to a set of interfaces in a subsystem. Facade defines a higher-level interface that makes the subsystem easier
阅读全文
摘要:Intent (定义) Attach additional responsibilities to an object dynamically. Decorators provide a flexible alternative to subclassing for extending functi
阅读全文
摘要:Intent (定义) Compose objects into tree structures to represent part-whole hierarchies. Composite lets clients treat individual objects and compositions
阅读全文
摘要:Intent (定义) Decouple an abstraction from its implementation so that the two can vary independently. (从实现中分离出抽象,使两者可以独立变化) Also Known As (别名) Handle/Bo
阅读全文
摘要:Intent (定义) Convert the interface of a class into another interface clients expect. (将一个接口转换为客户端希望的另一个接口)Adapter lets classes work together that could
阅读全文
摘要:观察者模式 有上面这个案例,也是我最近听到的一个案例,新浪天气和百度天气都是观察者,气象局如果有数据改变,那么调用notifyObserver通知其他观察者,然后其他观察者就可以进行改变。 疑问 这是一个很理想的状态,但是真实情况是,SinaWeather和BaiduWeather每隔一段时间去监听
阅读全文
摘要:Intent (定义) Ensure a class only has one instance, and provide a global point of access to it.(确保一个类只有一个实例,并提供全局访问的通道) Motivation (案例) How do we ensure
阅读全文
摘要:Intent (定义) Specify the kinds of objects to create using a prototypical instance, and create new objects by copying this prototype.(指定使用原型实例创建的对象类型,并通
阅读全文
摘要:Intent (定义) Define an interface for creating an object(定义一个接口去创建对象), but let subclasses decide which class to instantiate.(但是由子类决定哪个类将被实例化) Factory Me
阅读全文
摘要:Intent (定义) Separate the construction of a complex object from its representation,so that the same construction process can create different represent
阅读全文
摘要:Intent (定义) Provide an interface for creating families of related or dependent objects without specifying their concrete classes. (提供一个接口去创建相关联或者依赖的对象
阅读全文
摘要:design patterns elements of reusable object-oriented softwar_Java知识分享网-免费Java资源下载 整理了一下自己目前所理解的设计模式,然后再去看以前的视频温顾了下设计模式。 但是我发现,无论是以前看的视频,还是目前新找的设
阅读全文
摘要:创建型模式 顾名思义,用来创建对象使用。 工厂模式,建造者模式,单例模式 结构型模式 用来改变类的结构,包一层或者组合一些东西进去。 适配器模式,装饰器模式,代理模式,桥接模式,外观模式,组合模式,享元模式。 行为型模式 用于描述某些类之间的职责划分和相互协作关系。 策略模式、模板模式、观察者模式、
阅读全文
摘要:定义: 提供对语言的语法定义,并说明此语法的作用。 比如SQL语句,mysql怎么知道where就是条件查询呢? insert into 就是插入数据呢? 这就是先定义了select,where这些关键词的语义,然后规定语法,在用户正确书写后可以对SQL语句进行拆分和转换其中关键词的含义。 此模式我
阅读全文
摘要:顾名思义,买房和卖房的人一般会委托中介,而不是直接去找卖主,卖主也不会接触买主。 那么在设计模式中这个中介对象,就是简化原有对象之间的交互关系,降低对象间的耦合度,使原有对象之间不必相互了解。 如果像上面这样,对象与对象之间的交互形成了网状结构,各自相互依赖。关系很是复杂,有时候都不知道调用哪。 引
阅读全文