Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!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: Fri, 06 May 2011 18:25:31 +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: Fri, 6 May 2011 16:25:33 +0000 (UTC) Injection-Info: mx01.eternal-september.org; posting-host="Zjm1/7nnVMUmB9baN8E6xQ"; logging-data="12452"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19iTzjq85xNY+RgW14vOKcO" 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:k/5C0LjNbDFY4GBp9/ptB9jzft4= Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:3698 On 06/05/2011 08:25, Zapanaz allegedly wrote: > On Thu, 05 May 2011 22:48:21 +0200, Daniele Futtorovic > wrote: > >> But the code that *calls* >> getSortedMap() doesn't have to care about whether or not it's a >> LinkedHashMap > > yes, it does. > > The code that calls getSortedMap() has to know whether the results > will be sorted or not. Not unless the calling code inserts in that Map *and iterates* over it, it doesn't. A LinkedHashMap is not sorted. At least not in the absolute sense. It is sorted relatively to another sorting, viz. it (possibly) replicates the iteration order of another Map. But as I have tried to explain before, knowing that it's a LinkedHashMap *without knowing in what order the insertion took place* doesn't tell you *anything* about the iteration order. -- DF. An escaped convict once said to me: "Alcatraz is the place to be"