本文发表在 rolia.net 枫下论坛* Interface only contains unimplemented methods /properties. You cannot specify fields in an interface. On the other hand, abstract class has full features of class, such as normal/virtual/static methods/properties, and fields, in addition abstract methods/properties for child class to implement.
* If the functionality you are creating will be useful across a wide range of disparate objects, use an interface. Abstract classes should be used primarily for objects that are closely related, whereas interfaces are best suited for providing common functionality to unrelated classes.
* If you are designing small, concise bits of functionality, use interfaces. If you are designing large functional units, use an abstract class.
* If you want to provide common, implemented functionality among all implementations of your component, use an abstract class. Abstract classes allow you to partially implement your class, whereas interfaces contain no implementation for any members.
* If you anticipate creating multiple versions of your component, create an abstract class. Abstract classes provide a simple and easy way to version your components. By updating the base class, all inheriting classes are automatically updated with the change. Interfaces, on the other hand, cannot be changed once created. If a new version of an interface is required, you must create a whole new interface.更多精彩文章及讨论,请光临枫下论坛 rolia.net
* If the functionality you are creating will be useful across a wide range of disparate objects, use an interface. Abstract classes should be used primarily for objects that are closely related, whereas interfaces are best suited for providing common functionality to unrelated classes.
* If you are designing small, concise bits of functionality, use interfaces. If you are designing large functional units, use an abstract class.
* If you want to provide common, implemented functionality among all implementations of your component, use an abstract class. Abstract classes allow you to partially implement your class, whereas interfaces contain no implementation for any members.
* If you anticipate creating multiple versions of your component, create an abstract class. Abstract classes provide a simple and easy way to version your components. By updating the base class, all inheriting classes are automatically updated with the change. Interfaces, on the other hand, cannot be changed once created. If a new version of an interface is required, you must create a whole new interface.更多精彩文章及讨论,请光临枫下论坛 rolia.net