标签:bre extends contract code abstract ace sep nts tip
Interface separates what a Class does and how does it work. List interface lets different type of List to implement its own method.
interface has more flexibility. A class can implements multiple interfaces but can only extends one class.
once interface is implemented by Class, we can not change interface, otherwise, we will break existing code. so interface is like "contract". For
abstract class, we can still add behavior without breaking existing code.
abstract class allows default implementation. In my project of tweet sentiment analysis, I use Classifier abstract class and in classify_many(), it
has default implementation but leaves any class that extends it to implement their own classify() method.
标签:bre extends contract code abstract ace sep nts tip
原文地址:http://www.cnblogs.com/touchdown/p/6159036.html