Go实战--Design Patterns in Golang 之工厂模式(简单工厂、工厂方法、抽象工厂)
先看一下golang的Tiobe指数趋势:
可以看到在2017年7月,达到了最高点,之后略有下降。我坚信,2018年的7月,golang还会飙升。
生命不止,继续 go go go !!!
继续,golang中设计模式的探讨。
按照国际惯例,讲完单例模式,接下来就该轮到工厂模式。还是那句话,每个人对设计模式的理解都有所不同,欢迎各位探讨。
何为工厂模式
WIKI:
In class-based programming, the factory method pattern is a creational pattern that uses factory methods to deal with the problem of creating objects without having to specify the exact class of the object that will be created.
百度百科:
工厂模式是我们最常用的实例化对象模式了,是用工厂方法代替new操作的一种模式。
在面向对象的编程语言中(如java,C++)设计模式的概念广为人知, 应用的也非常广泛。设计模式让我们的代码变得灵活起来
还没有评论,来说两句吧...