Inheritance的优缺点:
可以代码重用。但是子类的行为可能不一致,甚至有些根本就不具有这种行为,这是就需要对每个子类的具体实现进行
覆盖、修改。而且也不能动态对行为进行更换
Interface的优缺点:
灵活。但是代码不能重用
Principle 1:
Idnetify the aspects of your application that vary and separate them from what stays the same.
Principle 2:
Program to an interface, not an implmentation.
这里的interface应该是一个广义的词,supertype的意思
Principle 3:
Favor composition over inheritance.
Composition更具有灵活性,而且可以动态更换