• why factory?
    • 1)当客户程序不需要知道要使用对象的创建过程。
    • 处理在不指定对象具体类型的情况下创建对象的问题
    • 实质是“定义一个创建对象的接口,但让实现这个接口的类来决定实例化哪个类。工厂方法让类的实例化推迟到子类中进行。”
    • Many factories are created because “Maybe, one day, I will need to create those classes differently” in mind. Which is a clear violation of YAGNI.
    • And factories become obsolete when you introduce IoC framework, because IoC is just a kind of factory. And many IoC frameworks are able to create implementations of specific factories.
    • minimize code duplication, by using an interface and being able to add new widgets quickly and easily. Put all the specifics in the specialized class
  • is it so complicated to create instance?
  • url
This entry was posted in DesignPattern. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s