Factory Method

how does the factory method pattern apply to the reality?

where can we find a factory method application in real life?

 

let me guess:

 

there's a factory, which manufactures a set type of products. it means the products it produces is of one type. so the consumer who wants several products of one type doesn't need to go to different places for serval products of one type.

 

client objects do not need to know the existence of the different implementers of the Product interface and their associated functionality.

 

Q: why does the factory method pattern need an abstract factory?

A: for the OCP, when it needs to add a new product, a new concrete factory then is needed to accommodate to the newly added product without changing the originally existing factory structure.

 

and think what is the essence of the factory method pattern even up to all the pattern?

i think it is “集束”, and perhaps make class of the things, just like all the IM does, you see, workmates, classmates, others, etc. otherwise you cannot find them easily in a big one group.

 

 

but why it's called method ?

 

你可能感兴趣的:(Go)