Neil 啃设计模式(0x10)享元模式

2020-04-16
阅读 3 分钟
1.1k
“享元模式(Flyweight Pattern)是池技术的重要实现方式,其定义如下:Use sharing to support large numbers of fine-grained objects efficiently.(使用共享对象可有效地支持大量的细粒度的对象。)”Excerpt From: 秦小波 著. “设计模式之禅(第2版)(华章原创精品).” iBooks.“如果一个应用程序使用了大量的对象,...

Neil 啃设计模式(0x09)外观模式

2020-04-14
阅读 3 分钟
815
“Provide a unified interface to a set of interfaces in a subsystem.Facade defines a higher-level interface that makes the subsystem easier to use.(要求一个子系统的外部与其内部的通信必须通过一个统一的对象进行。门面模式提供一个高层次的接口,使得子系统更易于使用。)”

Neil 啃设计模式(0x08)装饰器模式

2020-04-13
阅读 5 分钟
1.3k
“Attach additional responsibilities to an object dynamically keeping the same interface.Decorators provide a flexible alternative to subclassing for extending functionality.(动态地给一个对象添加一些额外的职责。就增加功能来说,装饰模式相比生成子类更为灵活。)”

Neil 啃设计模式(0x07)适配器模式

2020-03-26
阅读 3 分钟
757
适配器模式,将一个接口转换客户希望的另一个接口。适配器将原本不能在一起工作的接口转换成可以在一起工作的接口”《大话设计模式》适配器模式一般应用在不能修改源码,在只提供库的情况下又要适配现有代码,则需要增加一层适配器层。个人理解就是在两个不完全比配的接口之间增加一层代码使之匹配。适配器出现的目的是为...

Neil 啃设计模式(0x06)原型模式

2020-03-15
阅读 3 分钟
1.2k
“Specify the kinds of objects to create using a prototypical instance,and create new objects by copying this prototype.(用原型实例指定创建对象的种类,并且通过拷贝这些原型创建新的对象。)”《设计模式之禅》原型模式可以减小new创建对象,降低性能损耗。原型模式直接执行二进制的内存拷贝。并且原型模式可以...

Neil 啃设计模式(0x05)模板模式

2020-02-26
阅读 3 分钟
935
Define the skeleton of an algorithm in an operation,deferring some steps to subclasses.Template Method lets subclasses redefine certain steps of an algorithm without changing the algorithm's structure.(定义一个操作中的算法的框架,而将一些步骤延迟到子类中。使得子类可以不改变一个算法的结构即可重定...

Neil 啃设计模式(0x04)建造者模式

2020-02-25
阅读 6 分钟
1.2k
Separate the construction of a complex object from its representation so that the same construction process can create different representations.(将一个复杂对象的构建与它的表示分离,使得同样的构建过程可以创建不同的表示。)《设计模式之禅》

Neil 啃设计模式(0x3)抽象工厂模式

2020-02-20
阅读 5 分钟
1k
Provide an interface for creating families of related or dependent objects without specifying their concrete classes.(为创建一组相关或相互依赖的对象提供一个接口,而且无须指定它们的具体类。)《设计模式之禅》

Neil 啃设计模式(0x02)工厂模式

2020-02-19
阅读 2 分钟
1k
Define an interface for creating an object,but let subclasses decide which class to instantiate.Factory Method lets a class defer instantiation to subclasses.(定义一个用于创建对象的接口,让子类决定实例化哪一个类。工厂方法使一个类的实例化延迟到其子类。)对于python这种运行时判断类型的脚本语言来说...

Neil啃设计模式(0x01)单例模式

2020-02-14
阅读 4 分钟
1.1k
“单例模式(Singleton Pattern)是一个比较简单的模式,其定义如下:Ensure a class has only one instance, and provide a global point of access to it.(确保某一个类只有一个实例,而且自行实例化并向整个系统提供这个实例。)”Excerpt From: 秦小波 著. “设计模式之禅(第 2 版)(华章原创精品).” iBooks.