Interface vs. Class
- A class can implement multiple interfaces
- the shape of a thing, without specifying identity or implementation
- class is a collection of data and methods - strict and closed
- if a
Bird
canFly()
then all birds must fly, but what about penguins? - So, define interface
ICanFly
andICanSwim
, and thenBird
can focus on the specifics of the creature - injecting interfaces creates looser coupling in Dependency Injection