Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!gegeweb.org!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail From: Daniele Futtorovic Newsgroups: comp.lang.java.programmer Subject: Re: "Program to an interface" - When to break a design pattern Date: Wed, 11 May 2011 19:55:17 +0200 Organization: A noiseless patient Spider Lines: 26 Message-ID: References: <9dt5s6dalhetgfe99qs92c02hf0dbas44e@4ax.com> <2psjssq4zj.fsf@shell.xmission.com> <2poc3gq3p2.fsf@shell.xmission.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Wed, 11 May 2011 17:55:16 +0000 (UTC) Injection-Info: mx01.eternal-september.org; posting-host="Ifi0zMlPPHi1edxcIMhOmQ"; logging-data="3657"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/KaYInW5smEQ/U6xqFzJE+" User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.2.17) Gecko/20110414 Thunderbird/3.1.10 In-Reply-To: Cancel-Lock: sha1:ldVT+FETVwgbbrcsbV/DuyvZMGw= Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:3983 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. -- DF. An escaped convict once said to me: "Alcatraz is the place to be"