Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail From: Jim Janney Newsgroups: comp.lang.java.programmer Subject: Re: "Program to an interface" - When to break a design pattern Date: Thu, 05 May 2011 16:00:54 -0600 Organization: As little as possible Lines: 25 Message-ID: <2pbozgq02x.fsf@shell.xmission.com> References: <9dt5s6dalhetgfe99qs92c02hf0dbas44e@4ax.com> <2psjssq4zj.fsf@shell.xmission.com> <2poc3gq3p2.fsf@shell.xmission.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: mx01.eternal-september.org; posting-host="dZdavj/jUDynNQgDq5jkeA"; logging-data="21045"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18czkqXa6ss5SZWZ6Eay6Tr" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:TbrBhXh9FtZRRxHe8rQHu7i5nRo= sha1:QR2TlgK7jZxbosLmKpGMz27/OEs= Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:3607 Lew writes: > Jim Janney wrote: >> The justification is not in the code shown, but in the accompanying >> remark "I need the map to retain the insertion order." There's no >> interface in the JRE that promises this, > > other than > > you mean. > >> and only one class that provides it, which makes encapsulation, shall we say, difficult. > > Oh, really? > > Two are listed in the API docs for that "nonexistent" interface, and > neither one is 'LinkedHashMap'. > > Knowing the collections API is a prerequisite for effective Java programming. The original poster said very plainly, "I need the map to retain the insertion order." A SortedMap does not do this. -- Jim Janney