tmrts / go-patterns

Curated list of Go design patterns, recipes and idioms

Home Page:http://tmrts.com/go-patterns

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Factory Method Pattern

wtask opened this issue · comments

Factory Method Pattern in Go is function which returns an interface (something what is implementing an interface)... that's all. This means you should not think about this pattern and use a pattern when you known patterns. You should make only a function like func NewXXX(arguments) <interface> {...} for your needs (or in ideal case package.New()). And every gofer are making this everyday. And it is not a pattern. This is Interface builder or Interface constructor as you like.
I affirm that Go does not require knowledge of any patterns (as OOP requires), but it requires an understanding of SOLID principles and having a mind.