Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #25527
| Path | csiph.com!eeepc.pasdenom.info!news.pasdenom.info!news.dougwise.org!news-transit.tcx.org.uk!tr22g12.aset.psu.edu!news.glorb.com!news2.glorb.com!npeer01.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!post01.iad.highwinds-media.com!newsfe13.iad.POSTED!00000000!not-for-mail |
|---|---|
| From | Owen Jacobson <angrybaldguy@gmail.com> |
| Newsgroups | comp.lang.java.programmer |
| Message-ID | <201102112200563996-angrybaldguy@gmailcom> (permalink) |
| References | <99453fde-6bb5-4b7d-9817-03ec1ffc7616@o13g2000yql.googlegroups.com> <ij4s70$3ho$1@news.eternal-september.org> |
| MIME-Version | 1.0 |
| Content-Type | text/plain; charset=iso-8859-1; format=flowed |
| Content-Transfer-Encoding | 8bit |
| Subject | Re: Default Interfaces: possible Java extension? |
| User-Agent | Unison/2.1.3 |
| Lines | 43 |
| X-Complaints-To | abuse@UsenetServer.com |
| NNTP-Posting-Date | Sat, 12 Feb 2011 03:00:56 UTC |
| Date | Fri, 11 Feb 2011 22:00:56 -0500 |
| Xref | csiph.com comp.lang.java.programmer:25527 |
Show key headers only | View raw
On 2011-02-11 21:44:14 -0500, Eric Sosman said: > On 2/11/2011 9:20 PM, Tom McGlynn wrote: ... >> Add a new optional element in the definition of an interface which >> defines a class that does the default implementation of the >> interface. ... >> Are there other ways to do this? A factory method requires knowing >> the class the factory resides in and I can't really think of other >> patterns that address this. E.g., one could add >> newSet(), newList() and newMap() methods to Collections but that's not >> especially elegant to my eye since there's no special language >> relation between the List interface and the Collections class. > > I think that's the crux: There's no special relationship between > an interface and its many implementations; the relationship is one-way. > Adding the other-way relation -- the ability of an interface to name a > class and say "This is My beloved Son, in Whom I am well pleased" -- > doesn't seem to me to add much utility. This proposal also "bakes in" a circular dependency between an interface (List<T>) and its default implementation (ArrayList<T>), such that there is no way to compile or load either class without the other. While such circularity is sometimes hard to avoid (enums with per-constant bodies, for example, are inherently circular), they're not recommended style and they can lead to hard-to-debug classloading problems if you're not careful. I can't think of a use case for this outside of the collection types, either, and there are already idioms for those. This feels like a sublimated complaint about the standard library's choice of naming conventions (List & ArrayList, rather than IList and List as with .Net or informal protocols and list() like Python). Interesting proposal, but I think it contains unfixable flaws. -o
Back to comp.lang.java.programmer | Previous | Next | Find similar | Unroll thread
Re: Default Interfaces: possible Java extension? Owen Jacobson <angrybaldguy@gmail.com> - 2011-02-11 22:00 -0500
csiph-web