Path: csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!feeder.news-service.com!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: Fri, 06 May 2011 12:19:05 -0400 Organization: albasani.net Lines: 19 Message-ID: References: <9dt5s6dalhetgfe99qs92c02hf0dbas44e@4ax.com> <73jb98-ki2.ln1@news.simpsonst.f2s.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: news.albasani.net m2Ns8yMh+IVCLCFdaKzSILeW2c4dp+IUm9LtFFmkFl11IUGucgd600gkNaYoORBwrn5rsNGSkJYM3E+92JhIbw== NNTP-Posting-Date: Fri, 6 May 2011 16:18:57 +0000 (UTC) Injection-Info: news.albasani.net; logging-data="nTBRm1OxEaGeLUucwB5pFPrmxTDtbZUN+yfrhjNv2rTfxnO80Ah+cSqY5tfpaS1dB7fldeWxDOSDNB7qJTdrmy1ad2t66AKW2Juj+JhgyhQjne0sNAAmCHv6rMrnY4lc"; 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:VMI8QPan5wMqjzlBC8xGiR9Vskw= Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:3696 Steven Simpson wrote: > Me too. Certainly, I would like to express these behavioural > guarantees/constraints in a compiler-checkable way, but I don't think > marker interfaces cut it. One reason is that behaviour may be > instance-specific rather than class-specific (as seen with > LinkedHashMap). Another is that guarantees may be dropped in subclasses > (as WeakHashMap/IdentityHashMap do regarding Object.equals - is that > wrong?). Yet another is that behaviours might be combined orthogonally, > e.g. InsertionOrdered, NullKeys, NullValues, and you'd need to create an > interface combining just those three - while using LinkedHashMap as the > return type might offer more behaviours than you wish to promise. I'm > resigned to leaving these issues as a matter of documentation. This sounds like a use case for annotations. -- Lew Honi soit qui mal y pense. http://upload.wikimedia.org/wikipedia/commons/c/cf/Friz.jpg