Looking for Interface Inheritance Implementation 
Author Message
 Looking for Interface Inheritance Implementation

I am looking for alternatives for implementing Interface Inheritance in
Smalltalk.  Here is the problem I am trying to solve:  I have two
concrete classes A and B with methods mA and mB respectively.  I have an
abstract class C with method mC (to be implemented by its concrete
implementor).  Class C is a subclass of A and B.  I want to be able to
call mA and mB from C but I do not want to burden of manually writing
explicit methods mA and mB.  I would prefer instead to develop a method
that catches an C>"does not understand" exception and then dispatches
to  A or B based upon its knowledge of A and B.  Seen anything like
this?
Jerry


Wed, 18 Jun 1902 08:00:00 GMT  
 Looking for Interface Inheritance Implementation

Quote:

> I am looking for alternatives for implementing Interface Inheritance in
> Smalltalk.  Here is the problem I am trying to solve:  I have two
> concrete classes A and B with methods mA and mB respectively.  I have an
> abstract class C with method mC (to be implemented by its concrete
> implementor).  Class C is a subclass of A and B.  I want to be able to
> call mA and mB from C but I do not want to burden of manually writing
> explicit methods mA and mB.  I would prefer instead to develop a method
> that catches an C>"does not understand" exception and then dispatches
> to  A or B based upon its knowledge of A and B.  Seen anything like
> this?
> Jerry

One thing you could do if have C hold onto an instance of A and and
instance of B.  C could then overload #doesNotUnderstand:.  C could use
#respondsTo: to test both a and b to seee if either of them implements
the message.  If neither does, you raise the exception up the chain.  If
one implements the method, dispatcv to that object.  If both implement
the method, raise an 'ambigious message' error. (If you're really
clever,check to see that if they both respond to the message that they
are not  just inheriting it from a common superclass...)

Take care,

--
Jay O'Connor

http://www.roadrunner.com/~joconnor
http://www.ezboard.com

"God himself plays the bass strings first when He tunes the soul"



Wed, 18 Jun 1902 08:00:00 GMT  
 Looking for Interface Inheritance Implementation
Thanks Jay!
Jerry


Wed, 18 Jun 1902 08:00:00 GMT  
 Looking for Interface Inheritance Implementation
Take a look at the Orbix implementation for an example of using the does not
understand message in the way you describe.

Joe

Quote:


>> I am looking for alternatives for implementing Interface Inheritance in
>> Smalltalk.  Here is the problem I am trying to solve:  I have two
>> concrete classes A and B with methods mA and mB respectively.  I have an
>> abstract class C with method mC (to be implemented by its concrete
>> implementor).  Class C is a subclass of A and B.  I want to be able to
>> call mA and mB from C but I do not want to burden of manually writing
>> explicit methods mA and mB.  I would prefer instead to develop a method
>> that catches an C>"does not understand" exception and then dispatches
>> to  A or B based upon its knowledge of A and B.  Seen anything like
>> this?
>> Jerry

>One thing you could do if have C hold onto an instance of A and and
>instance of B.  C could then overload #doesNotUnderstand:.  C could use
>#respondsTo: to test both a and b to seee if either of them implements
>the message.  If neither does, you raise the exception up the chain.  If
>one implements the method, dispatcv to that object.  If both implement
>the method, raise an 'ambigious message' error. (If you're really
>clever,check to see that if they both respond to the message that they
>are not  just inheriting it from a common superclass...)

>Take care,

>--
>Jay O'Connor

>http://www.roadrunner.com/~joconnor
>http://www.ezboard.com

>"God himself plays the bass strings first when He tunes the soul"



Wed, 18 Jun 1902 08:00:00 GMT  
 Looking for Interface Inheritance Implementation
Quote:

>One thing you could do if have C hold onto an instance of A and and
>instance of B.  C could then overload #doesNotUnderstand:.  C could use
>#respondsTo: to test both a and b to seee if either of them implements
>the message.  If neither does, you raise the exception up the chain.  If
>one implements the method, dispatcv to that object.  If both implement
>the method, raise an 'ambigious message' error. (If you're really
>clever,check to see that if they both respond to the message that they
>are not  just inheriting it from a common superclass...)

Also consider subclassing from nil instead of Object.
That way everything traps into the doesNotUnderstand:.
It can make your code cleaner for dealing with common superclass
methods, etc. There are a few standard methods that have to be
in every object (reimplemented in the nil subclass). We can help you
with these.


Wed, 18 Jun 1902 08:00:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Inheritance: Interface vs Implementation (was: Questions on inheritance)

2. newbie question: implementation inheritance and interface specifications in Haskell 98

3. Renaming an implementation of a deferred feature. (inheritance)

4. implementation inheritance

5. Problem with current implementation of repeated inheritance

6. implementation inheritance question (maybe)

7. Multiple Inheritance Good/Bad: Typing or implementation?

8. Replacing Multiple Inheritance with Java's Interfaces

9. Inheritance of Interfaces ("like in Java")

10. Replacing Multiple Inheritance with Java's Interfaces

11. Multiple Dispatch (was Re: Replacing Multiple Inheritance with Java's Interfaces)

12. Suggestion for Ada 200x - Interface inheritance

 

 
Powered by phpBB® Forum Software