Real world examples of Factory Method pattern

后端 未结 6 2027
醉话见心
醉话见心 2020-12-13 02:03

I just read Factory Method. I understand that it provides a way to delegate the instantiation to sub-classes. But I couldn\'t understand the possible uses in a real-world sc

6条回答
  •  星月不相逢
    2020-12-13 03:04

    One example from the .NET Base Class Library (BCL) is Control.CreateControlsInstance, which is is used by many other members of the (Windows Forms) Control class.

    You can override this protected method to provide your own collection of controls, e.g. when you are implementing a custom control.

提交回复
热议问题