Re: Programming to an Interface



"GoogleEyeJoe" <crgsmrt@xxxxxxxxxxx> writes:
That's fine. I understand that. What does confuse me however, is the
notion that programming to an interface reduces the likelihood that
changing an object's implementation will break existing code (code
created by the client of the object (that implements the interface).
Why is this...?

I don't understand your parenthetical, but the three main reasons
that programming to an interface is good practice are:

- Defining the interface encourages you to think in terms of the
behavior you need to provide rather than how to implement it.
- The implementation of the behaviors exposed by the interface
can be changed without impacting users of the interface. The
implementation selection can even be deferred until runtime.
- Users of the interface are less likely to become coupled to
implementation-specific details.

You are, of course, correct that changing a method signature in the
interface would require changes to the users of that interface.

Regards,

Patrick

------------------------------------------------------------------------
S P Engineering, Inc. | The experts in large scale distributed OO
| systems design and implementation.
pjm@xxxxxxx | (C++, Java, Common Lisp, Jini, CORBA, UML)
.



Relevant Pages

  • Re: home made home security
    ... to interface to the RS485 master circuit. ... You do understand that the "master circuit" in this case needs to be a PC, ... What is the value of your time spent programming that you would ... Home security automation systems _don't_ cost thousands of dollars if you ...
    (comp.home.automation)
  • Re: Programming to an Interface
    ... it does not include member variants. ... form client of class depends on the codes from writer of class, ... 2)the mothod of coding makes sure the correctness of the programming from ... it is useful to program to an interface ...
    (comp.object)
  • Re: Good book on OOP? HELP!
    ... > honest good book that can give me some good fundamentals about programming ... Arrays are an easier way to handle lots of data, and data structures are ... A class is the pattern for an object, and specifies all the details exactly, ... will not break existing systems if you use the same interface. ...
    (borland.public.delphi.non-technical)
  • Re: [patch 00/13] Syslets, "Threadlets", generic AIO support, v3
    ... streaming interface. ... Eventually it will be reading some blocks from the disk ... state machine, but in reality it would just become a "user-level thread ... In contrast, if you start using thread-like programming to begin with, you ...
    (Linux-Kernel)
  • Re: Programming to an Interface
    ... Isn't this inherent in the design of the classes anyway? ... can be changed without impacting users of the interface. ... client of the object. ... found a reason why from programming to interfaces is better than ...
    (comp.object)