avalon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Stephen McConnell" <mcconn...@osm.net>
Subject RE: ExcaliburComponentManager
Date Fri, 07 Dec 2001 16:37:13 GMT

From: Leo Sutic wrote:
> > From: Stephen McConnell [mailto:mcconnell@osm.net]
> >
> > What is interesting here is that ExcaliburComponentManager
> > implements the
> > Initializable and Composable interfaces without declaring the required
> > exceptions and yet this compiles ok (which I confess I don't
> > understand).
> Stephen,
> it is a basic thing about OO programming - a subclass should be able to
> stand in for a superclass anywhere. That is, if SuperClass is a superclass
> to SubClass, then:
> void myMethod (SuperClass sc) { ... }
> ...
> myMethod (new SubClass ());
> should be valid, as the contract for SuperClass is inherited down to
> SubClass. That is, SubClass must deliver at least as much as SuperClass.
> Proceeding with the notion of contracts - each class requires
> something and delivers something. This contract is inherited down the
> hierarchy, and a subclass must not require more and must not deliver
> less than a superclass.
> Thus, since Initializable can be seen as a superclass of
> ExcaliburComponentManager, ECM must not require more and must not deliver
> less than Initializable.
> Initializable has a method initialize () throws Exception.
> Requires: No parameters, ability for caller to handle Exception.
> Delivers: Initializes the class.
> Now, when ECM does *not* throw Exception:
> Requires: No parameters.
> Delivers: Initializes the class.
> So ECM actually requires *less* than Initializable. This is perfectly
> valid - the contract is upheld by the subclass. You class, however, does
> throw an Exception and thus requires *more* than its superclass (ECM).


Your quite right - the distinction here is that ECM does not need to throw
an exception relative to its own implementation characteristics.  However,
this limits the potential for supertypes because a supertype cannot
introduce anything that would potential raise an exception during initalize.
Conclusion - there isn't a fault in ECM in terms of its own internal
implementation - but elimination of the throws Exception delcaration
effectively eliminates the possibility for supertypes that need this (which
was my case).


To unsubscribe, e-mail:   <mailto:avalon-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:avalon-dev-help@jakarta.apache.org>

View raw message