随笔分类 - 设计模式
摘要:一、建造者模式 建造者模式,也叫生成器模式,定义为:Separate the construction of a complex object from its representation so that the same construction process can create diffe
阅读全文
摘要:一、模板方法模式 模板方法模式。定义为:Define the skeleton of an algorithm in an operation,deferring some steps to subclasses.Template Method lets subclasses redefine ce
阅读全文
摘要:一、工厂方法模式 工厂方法模式。定义为:Define an interface for creating an object,but let subclasses decide which class toinstantiate.Factory Method lets a class defer i
阅读全文
摘要:一、单例模式 单例模式(Singleton Pattern)是一个比较简单的模式,其定义如下:Ensure a class has only one instance, and provide a global point of access to it.(确保某一个类只有一个实例,而且自行实例化并
阅读全文
摘要:1.单一职责(SRP) 单一职责原则(Single Responsibility Principle)定义: 应该有且仅有一个原因引起类的变更。 使用单一职责的优点: 1. 类的复杂性降低,实现什么职责都有清晰明确的定义; 2. 可读性提高,复杂性降低; 3.可维护性提高,可读性提高; 4.变更引起
阅读全文
浙公网安备 33010602011771号