Re: Abstract classes and methods
Re: Abstract classes and methods
- Subject: Re: Abstract classes and methods
- From: Ondra Cada <email@hidden>
- Date: Wed, 29 Aug 2001 19:58:27 +0200
Michael,
>
>>>>> Michael B. Johnson (MBJ) wrote at Wed, 29 Aug 2001 08:12:58 -0700:
MBJ> The way I did this exact thing in WavesWorld way back when was by having
MBJ> a formal "Renderable" protocol - any object that implemented the various
MBJ> methods defined in the protocol was, by definition, renderable. This let
MBJ> me mix things like cameras and geometry that didn't have a common base
MBJ> class in a very nice way, where in C++ I would have defined an abstract
MBJ> base class with all pure virtual functions and then done a mix in with
MBJ> the appropriate concrete superclass.
Right. The only drawback is that you can't have *any* implementation in
protocol, not even something utterly type-independent like
-(int)rightmost { return [self leftmost]+[self width]; }
(don't please beat me over head by NSRect, I hope you see the point)
which might get quite handy on ocassions, and which is the only thing
protocols do lack when compared with multiple inheritance.
In practice, this problem can be of course solved through categories, but it
is not quite elegant.
---
Ondra Cada
OCSoftware: email@hidden
http://www.ocs.cz
private email@hidden
http://www.ocs.cz/oc