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.

4
  • That's a good point, and I hear this a lot in certain contexts. Commented Mar 14, 2014 at 14:17
  • 1
    I see your point. So let me see if I can adapt what you're saying to general programming: Let's say I have a class (class A) that uses functionality of abstract class B. Classes C and D inherit class B - they provide concrete implementation for what that class is said to do. If class A uses directly class C or D, it's called 'programming to an implementation', which isn't a very flexible solution. But if class A uses a reference to class B, that can later be set to the C implementation or the D implementation, it makes things more flexible and maintainable. Is this correct? Commented Mar 14, 2014 at 20:02
  • If this is correct, than my question is - Are there more concrete examples to 'programming to an interface', other than the 'using an interface reference rather than a concrete-class reference' common example? Commented Mar 14, 2014 at 20:03
  • 3
    @AvivCohn A little late in this reply, but one concrete example is the world wide web. During the browser wars (IE 4 era) web sites were written not towards what any specification said, but to the quirks of some browser (Netscape or IE). This was basically programming to the implementation instead of the interface. Commented Aug 23, 2016 at 8:35