Return-Path: Delivered-To: apmail-commons-dev-archive@www.apache.org Received: (qmail 70970 invoked from network); 5 Nov 2008 09:43:36 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 5 Nov 2008 09:43:36 -0000 Received: (qmail 20908 invoked by uid 500); 5 Nov 2008 09:43:41 -0000 Delivered-To: apmail-commons-dev-archive@commons.apache.org Received: (qmail 20487 invoked by uid 500); 5 Nov 2008 09:43:40 -0000 Mailing-List: contact dev-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Commons Developers List" Delivered-To: mailing list dev@commons.apache.org Received: (qmail 20476 invoked by uid 99); 5 Nov 2008 09:43:40 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 05 Nov 2008 01:43:40 -0800 X-ASF-Spam-Status: No, hits=1.2 required=10.0 tests=SPF_NEUTRAL X-Spam-Check-By: apache.org Received-SPF: neutral (athena.apache.org: local policy) Received: from [195.242.168.1] (HELO mgate.ops.co.at) (195.242.168.1) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 05 Nov 2008 09:42:21 +0000 Received: from smtp.ops.co.at (smtp.int.ops.co.at [172.27.0.4]) by mgate.ops.co.at (OPS Mail Gateway - authorized use only - NO UCE/UBE C=AT L=VIE) with ESMTP id 4F00EAFE58 for ; Wed, 5 Nov 2008 10:43:00 +0100 (CET) Received: by smtp.ops.co.at (Postfix, from userid 65534) id 3D5A16E023F; Wed, 5 Nov 2008 10:43:00 +0100 (CET) Received: from [172.27.1.104] (lints2.int.ops.co.at [172.27.1.104]) by smtp.ops.co.at (Postfix) with ESMTP id 040EB6E0234 for ; Wed, 5 Nov 2008 10:42:59 +0100 (CET) Message-ID: <49116AA2.50707@apache.org> Date: Wed, 05 Nov 2008 10:42:58 +0100 From: Simon Kitching User-Agent: Thunderbird 2.0.0.17 (X11/20080922) MIME-Version: 1.0 To: Commons Developers List Subject: Re: [configuration] Interface vs class References: <49095D30.60005@oliver-heger.de> <4909C006.7000306@dslextreme.com> <490C862C.2080000@oliver-heger.de> <490CA1AC.1070307@dslextreme.com> <4910BDBF.8020302@oliver-heger.de> <49116181.9070409@apache.org> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Spam-Checker-Version: SpamAssassin 2.64 (2004-01-11) on smtp.ops.co.at X-Spam-Level: X-Virus-Checked: Checked by ClamAV on apache.org X-Old-Spam-Status: No, hits=-3.9 required=7.0 tests=AWL,BAYES_00,LOCAL_SPAMWORDS, LOCAL_URI_FOUND_BOL autolearn=no version=2.64 James Carman schrieb: > On Wed, Nov 5, 2008 at 4:04 AM, Simon Kitching wrote: > >> So the rule would be: >> * the project provides both an interface and an abstract class that >> implements that interface. >> * code that *uses* the API should always use just the interface, ie >> *call* methods via the interface and pass instances around as the >> interface type >> * code that *implements* the API should always subclass the base class. >> >> The project reserves the right to add methods to the interface, but will >> always provide a concrete default implementation on the abstract >> subclass. Methods will *not* be added to the interface if a sensible >> default implementation cannot be provided. >> >> > > So, perhaps I can change Proxy to use an interface rather than a > class? We already have a default implementation based on JDK proxies. > The standard JDK interface-based proxying would certainly become more useful. One issue that the above doesn't deal with is applying the decorator pattern to such interfaces. If someone wants to decorate an existing implementation by intercepting one or more methods, then they certainly can do so by using dynamic proxying (via commons-proxy or similar), as the type is now an interface. If someone wants to hand-write a decorator class, though, then they are in trouble as the abstract base class won't help there and the project reserves the right to extend the interface. I suppose the project could *also* provide an abstract "delegator" class for each interface that simply delegates all methods. That's then *two* abstract classes for each interface though, which is getting a little clumsy. Or we could simply say "get with the modern world and use a dynamic proxy"... Regards, Simon -- -- Emails in "mixed" posting style will be ignored -- (http://en.wikipedia.org/wiki/Posting_style) --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org For additional commands, e-mail: dev-help@commons.apache.org