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: Sun, 08 May 2011 03:28:03 +0200 Organization: A noiseless patient Spider Lines: 43 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: Sun, 8 May 2011 01:28:08 +0000 (UTC) Injection-Info: mx01.eternal-september.org; posting-host="QZUW/QG8TqIGXAkMGUpMMQ"; logging-data="19539"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/TVnNU2FALv1Mc2UoFZlB9" 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:a82gJ++WKf83o2KCbe1+efLwkoM= Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:3773 On 08/05/2011 01:26, Zapanaz allegedly wrote: > On Fri, 06 May 2011 18:25:31 +0200, Daniele Futtorovic > wrote: > >> 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. > > I am using the word "sorted" in an incorrect way, it's true. > > This is from a real-world application, the results in the map are > presented in a UI, and they do in fact have to be in a particular > order in that UI. They are ordered by an algorithm based on a set of > user-entered choices, and inserted in that order. So if that order > isn't preserved in the map, the way the items appear in the UI would > not be what the user had selected. This whole discussion is about the declared type, not the runtime type. Anyway, I've had enough of this. -- DF. An escaped convict once said to me: "Alcatraz is the place to be"