简介
常用的设计模式分三大类:
创建型模式(Creational Patterns)
结构型模式(Structural Patterns)
行为型模式(Behavioral Patterns)
本章主要来介绍下常用的5种创建型设计模式。
创建型模式(Creational Patterns)
创建型模式提供了一种创建对象同时又隐藏创建逻辑的方式,而不是使用new直接实例化对象。这使得程序在判断针对某个给定实例需要创建哪些对象时更加灵活。
共5种:
- 工厂方法模式(Factory Method Pattern)
- 抽象工厂模式(Abstract Factory Pattern)
- 单例模式(Singleton Pattern)
- 建造者模式(Builder Pattern)
- 原型模式(Prototype Pattern)