Path: csiph.com!x330-a1.tempe.blueboxinc.net!aioe.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: Tue, 10 May 2011 21:31:49 +0200 Organization: A noiseless patient Spider Lines: 29 Message-ID: References: <9dt5s6dalhetgfe99qs92c02hf0dbas44e@4ax.com> <2psjssq4zj.fsf@shell.xmission.com> <2poc3gq3p2.fsf@shell.xmission.com> <2paaeuml6w.fsf@shell.xmission.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Tue, 10 May 2011 19:31:49 +0000 (UTC) Injection-Info: mx03.eternal-september.org; posting-host="3ontdQOwqTpoXYF7H7NQoA"; logging-data="9857"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX185PzGJNIqlPUpItdBMavvk" 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: <2paaeuml6w.fsf@shell.xmission.com> Cancel-Lock: sha1:KZcJzLHug6/bAJxT3GfdtrS3Ywc= Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:3935 On 10/05/2011 21:04, Jim Janney allegedly wrote: > markspace<-@.> writes: >> As an example, here's a method in the Java API that returns an array -- >> something with NO constraints on data order -- and yet the docs for >> the method say the order is guaranteed. >> >> >> >> It's even a relatively recently added method too, not some historical >> oddity. So I agree it's legit to document, but not enforce by type, >> ordering or other invariants on the objects a method returns. > > Not an analogous case. When an array is ordered, the ordering is a > property only of that particular instance, one that may cease to hold if > the array is modified. In contrast, every instance of LinkedHashMap > always preserves the order of insertion, since this is a property that > the class promises to maintain at all times. > M*r*. Futtorovic's argument holds only if callers to getOrderedMap() never > add new entries to it. ... while having an interest in its iteration order. But otherwise entirely correct and agreed. -- DF. An escaped convict once said to me: "Alcatraz is the place to be"