Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.albasani.net!.POSTED!not-for-mail From: Lew Newsgroups: comp.lang.java.programmer Subject: Re: "Program to an interface" - When to break a design pattern Date: Thu, 05 May 2011 18:23:19 -0400 Organization: albasani.net Lines: 21 Message-ID: References: <9dt5s6dalhetgfe99qs92c02hf0dbas44e@4ax.com> <2psjssq4zj.fsf@shell.xmission.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: news.albasani.net lTxjph2ZZkqMbfzd39Adtj56aHXljDWIF8c7NVRIMrAorP2eiCEIXdbda/dbXC3rAx3rPsn92qBzMsBc0XE9xQ== NNTP-Posting-Date: Thu, 5 May 2011 22:23:17 +0000 (UTC) Injection-Info: news.albasani.net; logging-data="JzfIekckAFPLl+saW3oF/fSg940o8BhdbA4Thlhz5azcYZUPQAK6VVmJ996Y5oxdAols37PMKhYEMl26VLX6H1UqlUSrykObJKpIpi4BSO2KMKJEeDKw9EPYHKBYbVBe"; mail-complaints-to="abuse@albasani.net" User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.14) Gecko/20110223 Thunderbird/3.1.8 In-Reply-To: Cancel-Lock: sha1:ul4cEJXFCtXngHphVrPJdEtAak8= Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:3613 Arved Sandstrom wrote: > Lew wrote: >> Actually, in this case programming to the interface is the /right/ thing >> to do. Please don't mislead the OP. >> > Well, no. The OP has stated that he needs the map to obey the contract > of LinkedHashMap: "where I'm creating sortedMap above, I need the map to > retain the insertion order". This is the normal behaviour of > LinkedHashMap, that its predictable iteration ordering is > insertion-order. If he wants a map that has this iterator ordering, he > wants LinkedHashMap (and possibly no other maps qualify actually; I am > not 100% certain on this). Yes, Jim Janney already corrected me on this. Mea culpa. -- Lew Honi soit qui mal y pense. http://upload.wikimedia.org/wikipedia/commons/c/cf/Friz.jpg