Path: csiph.com!x330-a1.tempe.blueboxinc.net!feeder1.hal-mli.net!border3.nntp.dca.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!npeer01.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!post01.iad.highwinds-media.com!newsfe01.iad.POSTED!8ad76e89!not-for-mail From: Arved Sandstrom User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.17) Gecko/20110424 Lightning/1.0b2 Thunderbird/3.1.10 MIME-Version: 1.0 Newsgroups: comp.lang.java.programmer Subject: Re: "Program to an interface" - When to break a design pattern References: <9dt5s6dalhetgfe99qs92c02hf0dbas44e@4ax.com> <2psjssq4zj.fsf@shell.xmission.com> <2poc3gq3p2.fsf@shell.xmission.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Lines: 37 Message-ID: <68Tzp.4573$4d6.3276@newsfe01.iad> X-Complaints-To: abuse@newsgroups-download.com NNTP-Posting-Date: Sun, 15 May 2011 16:25:38 UTC Organization: Public Usenet Newsgroup Access Date: Sun, 15 May 2011 13:25:35 -0300 Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:4126 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