Groups | Search | Server Info | Keyboard shortcuts | Login | Register


Groups > comp.lang.java.programmer > #4126

Re: "Program to an interface" - When to break a design pattern

From Arved Sandstrom <asandstrom3minus1@eastlink.ca>
Newsgroups comp.lang.java.programmer
Subject Re: "Program to an interface" - When to break a design pattern
References (12 earlier) <iq6l21$vuh$1@dont-email.me> <iqbihl$40p$1@dont-email.me> <Ysjyp.13$jc2.12@newsfe11.iad> <cP6dnVE0G8HAV1fQnZ2dnUVZ_rCdnZ2d@earthlink.com> <iqeii4$3i9$1@dont-email.me>
Message-ID <68Tzp.4573$4d6.3276@newsfe01.iad> (permalink)
Organization Public Usenet Newsgroup Access
Date 2011-05-15 13:25 -0300

Show all headers | View raw


On 11-05-11 02:55 PM, Daniele Futtorovic wrote:
> On 11/05/2011 19:41, Patricia Shanahan allegedly wrote:
>> I think some of the trouble might lie in the ambiguity, in a Java
>> context, of the sentence "Program to an interface.".
>>
>> Meaning 1: Users of some module (in the widest sense) should depend only
>> on what is declared and specified about the module, not on direct
>> knowledge of how it is currently implemented.
>>
>> Meaning 2: Java programs should depend only in Java interface types to
>> represent what is declared and specified about a module for the use of
>> its callers.
>>
>> I am very strongly in favor of meaning 1 of "Program to an interface.".
>> Everything any user of a module needs to know about it should be
>> declared and/or specified as part of its interface (in the general
>> sense), and using code should depend only on what is declared and
>> specified.
> 
> Absolutely. Isn't the wording "program to a contract rather to an
> implementation" also in use? I find that a much better one, because it
> doesn't evoke Java interfaces.
> 
Fervent agreement. Especially if we're talking about OOP languages that
actually have "interface" constructs.

The first time I had this concept introduced to me, "program to an
interface", I hadn't even started using Java because only about a dozen
people at Sun were using Java. :-) So "interface" to me means "contract".

In fact it was a bit of a surprise to me when I discovered, in the
course of doing intensive research during this thread, that many Java
eminences really do mean "Java interface" specifically when they
advocate "program to an interface". This is quite a strong principle -
stronger (or, shall we say, more selective) than the general one.

AHS

Back to comp.lang.java.programmer | Previous | NextPrevious in thread | Find similar


Thread

Re: "Program to an interface" - When to break a design pattern Zapanaz <http://joecosby.com/code/mail.pl@foo.com> - 2011-05-05 23:25 -0700
  Re: "Program to an interface" - When to break a design pattern Daniele Futtorovic <da.futt.news@laposte-dot-net.invalid> - 2011-05-06 18:25 +0200
    Re: "Program to an interface" - When to break a design pattern Zapanaz <http://joecosby.com/code/mail.pl@foo.com> - 2011-05-07 16:26 -0700
      Re: "Program to an interface" - When to break a design pattern Daniele Futtorovic <da.futt.news@laposte-dot-net.invalid> - 2011-05-08 03:28 +0200
        Re: "Program to an interface" - When to break a design pattern Arved Sandstrom <asandstrom3minus1@eastlink.ca> - 2011-05-08 00:05 -0300
          Re: "Program to an interface" - When to break a design pattern Daniele Futtorovic <da.futt.news@laposte-dot-net.invalid> - 2011-05-08 16:15 +0200
            Re: "Program to an interface" - When to break a design pattern Arved Sandstrom <asandstrom3minus1@eastlink.ca> - 2011-05-08 14:20 -0300
              Re: "Program to an interface" - When to break a design pattern Daniele Futtorovic <da.futt.news@laposte-dot-net.invalid> - 2011-05-08 19:48 +0200
                Re: "Program to an interface" - When to break a design pattern markspace <-@.> - 2011-05-10 07:36 -0700
                Re: "Program to an interface" - When to break a design pattern Jim Janney <jjanney@shell.xmission.com> - 2011-05-10 13:04 -0600
                Re: "Program to an interface" - When to break a design pattern Daniele Futtorovic <da.futt.news@laposte-dot-net.invalid> - 2011-05-10 21:31 +0200
                Re: "Program to an interface" - When to break a design pattern Arved Sandstrom <asandstrom3minus1@eastlink.ca> - 2011-05-10 20:01 -0300
                Re: "Program to an interface" - When to break a design pattern Daniele Futtorovic <da.futt.news@laposte-dot-net.invalid> - 2011-05-11 19:14 +0200
                Re: "Program to an interface" - When to break a design pattern Patricia Shanahan <pats@acm.org> - 2011-05-11 10:41 -0700
                Re: "Program to an interface" - When to break a design pattern Daniele Futtorovic <da.futt.news@laposte-dot-net.invalid> - 2011-05-11 19:55 +0200
                Re: "Program to an interface" - When to break a design pattern Lew <noone@lewscanon.com> - 2011-05-11 16:42 -0400
                Re: "Program to an interface" - When to break a design pattern Daniele Futtorovic <da.futt.news@laposte-dot-net.invalid> - 2011-05-11 23:34 +0200
                Re: "Program to an interface" - When to break a design pattern "John B. Matthews" <nospam@nospam.invalid> - 2011-05-12 00:51 -0400
                Re: "Program to an interface" - When to break a design pattern Lew <noone@lewscanon.com> - 2011-05-12 00:58 -0400
                Re: "Program to an interface" - When to break a design pattern Tom Anderson <twic@urchin.earth.li> - 2011-05-12 20:08 +0100
                Re: "Program to an interface" - When to break a design pattern Arved Sandstrom <asandstrom3minus1@eastlink.ca> - 2011-05-15 13:25 -0300

csiph-web