Why does Abstract Factory use abstract class instead of interface?

后端 未结 4 540
故里飘歌
故里飘歌 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:17

    An abstract class can, with care, be extended in a non-breaking manner; all changes to an interface are breaking changes.

    Update:
    In contrast, an interface can be an in or out type-parameter and an abstract class cannot. Sometimes one or the other is more appropriate for a given design, and sometimes it is a toss-up.

提交回复
热议问题