学海无涯

导航

随笔分类 -  设计模式

Template Method 和 Strategy 策略模式
摘要:Template Method 模式和 Strategy 模式所有解决的问题是类似的,通常可以互换使用。不过 Template Mothod 模式使用抽象类来解决问题,而 Strategy 使用接口来解决问题。 Strategy 模式:为了遵循依赖倒置原则(DIP),我们想确保这个通用的算法不要依赖 阅读全文

posted @ 2022-11-14 16:03 宁静致远. 阅读(99) 评论(0) 推荐(0)

23种常用的设计模式
摘要:一、创建型 单例(Singleton) 工厂模式 简单工厂(Simple Factory) 工厂方法(Factory Method) 抽象工厂(Abstract Factory) 生成器(Builder) 原型模式(Prototype) 二、行为型 责任链(Chain Of Responsibili 阅读全文

posted @ 2022-09-20 15:46 宁静致远. 阅读(48) 评论(0) 推荐(0)