• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Abstract classes and methods
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: Abstract classes and methods
      • From: "Michael B. Johnson" <email@hidden>
References: 
 >Re: Abstract classes and methods (From: "Michael B. Johnson" <email@hidden>)

  • Prev by Date: Looking for a workaround for a Bug in Cocoa Window
  • Next by Date: Re: Another Cocoa Bug!! :<
  • Previous by thread: Re: Abstract classes and methods
  • Next by thread: Re: Abstract classes and methods
  • Index(es):
    • Date
    • Thread