Path: csiph.com!x330-a1.tempe.blueboxinc.net!aioe.org!eternal-september.org!feeder.eternal-september.org!.POSTED.shell.xmission.com!not-for-mail From: Jim Janney Newsgroups: comp.lang.java.programmer Subject: Re: "Program to an interface" - When to break a design pattern Date: Tue, 10 May 2011 13:04:23 -0600 Organization: As little as possible Lines: 35 Message-ID: <2paaeuml6w.fsf@shell.xmission.com> References: <9dt5s6dalhetgfe99qs92c02hf0dbas44e@4ax.com> <2psjssq4zj.fsf@shell.xmission.com> <2poc3gq3p2.fsf@shell.xmission.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: mx01.eternal-september.org; posting-host="shell.xmission.com:2607:fa18:0:beef::4"; logging-data="26428"; mail-complaints-to="abuse@eternal-september.org" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:HHZT4APBgfJ2mYDFKByDUEINte4= Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:3930 markspace <-@.> writes: > On 5/8/2011 10:48 AM, Daniele Futtorovic wrote: > >> This is perhaps the sixth time I've written the same thing with a >> different wording. If it still doesn't get through to anyone, then yes, >> I'll declare pearls before swine. Sorry for not being 'diplomatic' more >> than the first half a dozen tries. > > > No, I think you're right, if I've been following the discussion > properly (it's gone a bit long winded). > > 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. Ms. Futtorovic's argument holds only if callers to getOrderedMap() never add new entries to it. That's not an assumption I'm willing to make, without more information than the original poster has given us. -- Jim Janney