Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

7
  • 2
    Great explanation BB :) Commented Apr 23, 2012 at 6:12
  • 3
    This is the best definition out of the top 3. You've really got to the bottom of why it doesn't make sense to avoid implementing an interface. ie classes implementing interfaces can have their objects declared as the interface to pass to methods/ classes. Any other reasons? Commented Feb 11, 2014 at 19:34
  • very nice. helped my lots Commented Jul 23, 2015 at 3:49
  • 6
    In your example Dog is an interface, and Pug/Lab implement Dog, and you say We can say that a Pug is a Dog and a Lab is a dog. But no, an interface is not what you "are" it's what you "do". So Dog should have been a base class, because Pug/Lab ARE dogs, rather than being objects that implement dog behaviour. Commented Feb 9, 2016 at 20:20
  • 2
    @eurotrash From a theoretical perspective the only observable properties of a type are its behaviors. An interface is just a special name for a type which has no concrete behaviors. In a language that allows multiple inheritance, an interface is indistinguishable(modulo programming language warts) from a virtually inherited abstract base class, exactly for this reason. Commented Feb 26, 2018 at 16:55