X-FeedAbuse: http://nntpfeed.proxad.net/abuse.pl feeded by 88.191.16.109 Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.dougwise.org!nntpfeed.proxad.net!nospam.fr.eu.org!usenet-fr.net!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!news.glorb.com!npeer02.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!post01.iad.highwinds-media.com!newsfe02.iad.POSTED!8ad76e89!not-for-mail From: Arved Sandstrom User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.17) Gecko/20110424 Lightning/1.0b2 Thunderbird/3.1.10 MIME-Version: 1.0 Newsgroups: comp.lang.java.programmer Subject: Re: "Program to an interface" - When to break a design pattern References: <9dt5s6dalhetgfe99qs92c02hf0dbas44e@4ax.com> <2psjssq4zj.fsf@shell.xmission.com> <2poc3gq3p2.fsf@shell.xmission.com> <2pk4e4q2sq.fsf@shell.xmission.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Lines: 54 Message-ID: X-Complaints-To: abuse@newsgroups-download.com NNTP-Posting-Date: Fri, 06 May 2011 20:50:52 UTC Organization: Public Usenet Newsgroup Access Date: Fri, 06 May 2011 17:50:51 -0300 Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:3714 On 11-05-06 01:56 PM, Daniele Futtorovic wrote: > On 06/05/2011 12:24, Arved Sandstrom allegedly wrote: [ SNIP ] >> It's not about providing a Map with the same iteration order as >> "another". There might be no "other". In the case of a stock >> LinkedHashMap we know that the predictable iteration order is insertion >> order. But mainly the contract we're after is predictable iteration >> order, regardless of how the map was loaded. That is what the Javadoc >> says. > > True, there might be no other: the Map may have been constructed and > filled in the method itself. > > But I maintain that the iteration order of a LinkedHashMap is *not > predictable*, *unless* you know the order in which elements were > inserted in it (or can make reasonable assumptions as to that). > >> As far as your nuance is concerned, I'm interested (the _OP_ is >> interested) in providing a map with predictable insertion order. Map >> does not satisfy that; LinkedHashMap does. If I return Map then I am >> making a mistake. >> >>> The return type being a LinkedHashMap, itself, doesn't tell you >>> _anything_ about its iteration order. >> >> ??? It tells me that it has a predictable iteration order (which happens >> to be insertion order). It's the _predictable_ bit that is important. >> That it happens to be insertion order is a bonus but not the key point. > > I repeat: the iteration order is *not predictable* if you don't happen > to know the insertion order (unlike e.g. a SortedMap). [ SNIP ] I'm not ignoring the rest of the post here, by any means, Daniele. I do respect you as a knowledgeable debater actually. Although if you make a forceful case expect a forceful counter-case if I think you're wrong. :-) I believe that we are somewhat at cross-purposes here. I think you're reading more into the use of the word "predictable" than is deserved. All I read into this is that, assuming that I have a default LinkedHashMap that tracks insertion order (there is a constructor that lets you specify access order with a boolean flag), that (1) *if* I know the insertion order then I know ahead of time what an iterator on that map will do, and (2) as corollary, if I've otherwise captured that knowledge with one iteration, and then subsequently track insertions, I can also predict what future iterations will do. Do I know what the iteration order will be if I don't know the order of insertions, and haven't iterated at least once? No, obviously not. It might have been more accurate for the API Javadocs to describe LinkedHashMap as having conditionally predictable iteration order. AHS