开发者

Interface + Baseclass - What pattern is this?

I have defined an interface that is implemented by a base class. This base class provides basic functionalities. Now I have multiple implementations that implement the base class and expand these functionalities with more specifics. When I call those multiple implementations I cast the implementations to the interface (that is implemented in the base class).

Is there any pattern where this type of interface useag开发者_如何转开发e is described? Or is this kind of architecture counterproductive?

Greetings


If your base class is abstract, then there's a known pattern, The Abstract Class Pattern by one of its names. Your usage is valid because it hides the shenanigans introduced by the base class which are not part of the interface implementation, thus protecting client code from misusing your types.

More on this document.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜