Why does Abstract Factory use abstract class instead of interface?

后端 未结 4 542
故里飘歌
故里飘歌 2021-01-12 02:37

I am learning about design patterns and the first example in the book is about Abstract Factory. I have built the exercise in VS and all looks good, but there is one questio

4条回答
  •  梦谈多话
    2021-01-12 03:31

    "Abstract" in "abstract factory" has nothing to do with "abstract" in abstract class. Abstract factory is "base" for concrete factory, but design pattern itself does not enforce any particular implementation. Abstract factory can be abstract or even concrete class, interface or some form of duck typed object depending on language you use.

    Indeed in C# interface is very reasonable way to specify Abstract Factory.

提交回复
热议问题