Interfaces are contracts that implementers must follow.
Abstract classes allow contracts plus shared implementations - something that Interfaces cannot have. Classes can implement and inherit multiple interfaces. Classes can only extend a single abstract class.
Why Interface
- You don't have default or shared code implementation
- You want to share data contracts (web services, SOA)
- You have different implementations for each interface implementer (
IDbCommand
has SqlCommand
and OracleCommand
which implement the interface in specific ways)
- You want to support multiple inheritance.
- Allow for multiple methods with the same name between interfaces, because hey, you have no conflicting implementation, just a signature.
Why Abstract
Comments
Post a Comment