![](https://img-blog.csdnimg.cn/20201014180756930.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
设计模式
MurphySL
这个作者很懒,什么都没留下…
展开
-
设计模式——模板方法模式
定义Define the skeleton of an algorithm in an operation , deferring some steps to subclass. Template Method lets subclasses redefine certain steps of an algorithm without changing the algorithm’ s struct原创 2017-03-27 22:25:53 · 384 阅读 · 0 评论 -
设计模式——建造者模式
定义Separate the construction of a complex object from its representation so that the same construction process can create different representations.使用场景 相同方法,不同执行顺序,产生不同事件结果。 多个部件或零件可以装配到一个对象中,对产生的运行结果不原创 2017-03-30 18:14:06 · 302 阅读 · 0 评论 -
设计模式——抽象工厂模式
抽象工厂模式定义Provide an interface for creating families of related or dependent objects without specifying their concrete classes.使用场景一个对象族(或一组无任何关系的对象),具有相同约束。UML示例抽象产品类public abstract class Product {原创 2017-03-26 10:36:35 · 365 阅读 · 0 评论 -
设计模式——工厂方法模式
工厂方法模式定义Define an interface for creating an object, but let subclass decide which class to instantiate. Factory Method lets a class defer instantiation to subclass.使用场景 所有需要生成对象的地方均可使用,但需考虑代码复杂度的增加。 需要原创 2017-03-26 10:34:00 · 316 阅读 · 0 评论 -
设计模式——单例模式
单例模式定义Ensure a class has only one instance, and provide a global point of access to it.使用场景要求一个类有且只有一个对象。具体场景如下: * 要求生成唯一序号的环境。 * 需要共享访问点或者共享数据,要求线程安全。 * 创建对象消耗资源过多,如 IO ,数据库资源等。 * 需要定义大量静态常量或静态方法的原创 2017-03-26 12:23:20 · 378 阅读 · 0 评论