天天看点

设计模式学习之路-工厂模式实际使用场景

工厂模式属于创建型模式,目的为创建对象提供过渡接口,以便将创建对象的具体过程屏蔽隔离起来,提高灵活性。

工厂模式分为三类(从上到下越来越抽象):

简单工厂模式 simple factory 又称静态工厂方法模式

工厂方法模式 factory method

抽象工厂模式 abstract factory

spring核心容器的主要组件是beanfactory,它是工厂模式的实现。

参考链接

<a href="http://design-patterns.readthedocs.io/zh_cn/latest/creational_patterns/simple_factory.html">http://design-patterns.readthedocs.io/zh_cn/latest/creational_patterns/simple_factory.html</a>

<a href="https://yq.aliyun.com/articles/109934">https://yq.aliyun.com/articles/109934</a>