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 can Fly() then all birds must fly, but what about penguins?
  • So, define interface ICanFly and ICanSwim, and then Bird can focus on the specifics of the creature
  • injecting interfaces creates looser coupling in Dependency Injection