设计模式之笼统工厂模式(Abstract Factory)
来源:     阅读:396
织梦模板店
发布于 2021-03-20 04:43
查看主页

概述

The Abstract Factory provides an interface for creating families of related or dependent objects without the need to specify their concrete classes.

意思是笼统工厂提供一个接口,这个接口可以创立一系列相关依赖的对象,并且不用指定他需要创立的哪一个具体的类。总而言之,就是一个笼统接口可以获取好几种不同类别的对象。

菜鸟教程的例子很好

类图(画的不标准)

最重要的一步是

根据笼统接口获取形状

In the example above, the ShapeFactory can be used to create objects based on the String shapeType. So, we do not need to specify the concrete class, but only need to pass the type string. This pattern uses inheritance to define the factories that create objects.

根据笼统接口获取颜色

本文GitHub代码地址    

推荐看这篇文章

免责声明:本文为用户发表,不代表网站立场,仅供参考,不构成引导等用途。 系统环境 软件环境
相关推荐
Alpine Linux 3.8.0 发布,轻量级Linux发行版
1024程序员节:向改变世界的程序员致敬
Python 从零搭建 Conf_Web 配置管理平台
九神带你入门JVM(下)
GO 语言交叉编译
首页
搜索
订单
购物车
我的