Path: csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!nx02.iad01.newshosting.com!newshosting.com!69.16.185.16.MISMATCH!npeer02.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!post01.iad.highwinds-media.com!newsfe01.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: 27 Message-ID: X-Complaints-To: abuse@newsgroups-download.com NNTP-Posting-Date: Fri, 06 May 2011 22:43:31 UTC Organization: Public Usenet Newsgroup Access Date: Fri, 06 May 2011 19:43:31 -0300 Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:3725 On 11-05-06 06:37 PM, Daniele Futtorovic wrote: [ SNIP ] > And I argued it should be Map. Because it being a LinkedHashMap does not > add any significant functional knowledge. The method, as you rightly > observed some posts ago, does not take an argument, so it is reasonable > to assume that the caller has no prior knowledge of the returned data's > ordering. Therefore, since it being a LinkedHashMap does not add any > predictability unless you know the order, and since that's the only > functional peculiarity of a LinkedHashap, I concluded that knowing it's > a LinkedHashMap is irrelevant. And since one ought to use types as broad > as possible and as narrow as necessary, I opined that the return-type > ought to be Map. > > As I said, I believe the only exception to this is if the caller itself > is the one inserting in that Map from somewhere else and needs to retain > the prior order. [ SNIP ] OP quote: "I need the map to retain the insertion order". That's all I need right there. All efforts to convince him to return a Map are simply efforts to convince him to abandon that requirement. There's no reason to assume that the insertion order is unknown, actually; we don't _know_, so I'm content to go with what the OP did say. AHS