![](https://img-blog.csdnimg.cn/20201014180756919.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
设计模式
平头哥阿威
coding....
展开
-
抽象工厂
抽象工厂 抽象工厂模式(Abstract Factory Pattern)是围绕一个超级工厂创建其他工厂。该超级工厂又称为其他工厂的工厂。这种类型的设计模式属于创建型模式,它提供了一种创建对象的最佳方式。 在抽象工厂模式中,接口是负责创建一个相关对象的工厂,不需要显式指定它们的类。每个生成的工厂都能按照工厂模式提供对象。 意图:提供一个创建一系列相关或相互依赖对象的接口,而无需指定它们具体的类。 主要解决:主要解决接口选择的问题。 何时使用:系统的产品有多于一个的产品族,而系统只消费其中某一族的产品。 如何原创 2020-09-05 23:02:48 · 184 阅读 · 0 评论 -
简单工厂模式
简单工厂 package main import "fmt" type Food interface { Eat() } type Rice struct { } func (r *Rice) Eat() { fmt.Println("Eat rice") } type Noodles struct { } func (r *Noodles) Eat() { fmt.Println("Eat Noodles") } func NewFood(choose string) Food { i原创 2020-09-01 09:00:30 · 175 阅读 · 0 评论 -
设计模式0
Golang语言是面向接口语言,并非面向对象语言。为了方便使用,有了接口:https://blog.csdn.net/Vickers_xiaowei/article/details/104630797 文章目录封装继承多态 封装 import包封装隔离,大小写实现封装,小写对象外不可见,大写对象外可见。 type Human struct{ name string } func(h* Human...原创 2020-04-28 11:06:01 · 209 阅读 · 0 评论