Path: csiph.com!x330-a1.tempe.blueboxinc.net!aioe.org!news.glorb.com!postnews.google.com!news1.google.com!Xl.tags.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local2.nntp.dca.giganews.com!news.giganews.com.POSTED!not-for-mail NNTP-Posting-Date: Sat, 07 May 2011 18:26:16 -0500 From: Zapanaz Newsgroups: comp.lang.java.programmer Subject: Re: "Program to an interface" - When to break a design pattern Date: Sat, 07 May 2011 16:26:49 -0700 Message-ID: References: <9dt5s6dalhetgfe99qs92c02hf0dbas44e@4ax.com> <2psjssq4zj.fsf@shell.xmission.com> <2poc3gq3p2.fsf@shell.xmission.com> X-Newsreader: Forte Agent 6.00/32.1186 MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit Lines: 44 X-Usenet-Provider: http://www.giganews.com X-Trace: sv3-IeZZV5kg3xR1eBz4LTftMykQPsnmwXLXKjJTVdVDIKOlzzVSqtv2GtdfQbnqR2d/RFahDfUwDcBbLJL!gXkvv81GqO1xA36UJ2f2S3sYzd2h7k+wsaMPgIRBkyho5qREWGQCGSUndN217DDAyFr47yQ= X-Complaints-To: abuse@giganews.com X-DMCA-Notifications: http://www.giganews.com/info/dmca.html X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.40 X-Original-Bytes: 3042 Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:3771 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. -- Zapanaz International Satanic Conspiracy Customer Support Specialist http://joecosby.com/ You know you're in Saskatchewan when you can sit on your front porch and watch your dog run away for three days :: Currently listening to Todesfuge, 2003, by Diamanda Galás, from "Defixiones, Will and Testament"