Ray's playground

 

Item 22: Prefer Defining and Implementing Interfaces to Inheritance(Effective C#)

Base classes describe and implement common behaviors across related concrete types. Interfaces describe atomic pieces of functionality that unrelated concrete types can implement. Both have their place. Classes define the types you create. Interfaces describe the behavior of those types as pieces of functionality. If you understand the differences, you will create more expressive designs that are more resilient in the face of change. Use class hierarchies to define related types. Expose functionality using interfaces implemented across those types.

posted on 2011-02-12 22:33  Ray Z  阅读(156)  评论(0编辑  收藏  举报

导航