Re: Abstract classes and methods
Re: Abstract classes and methods
- Subject: Re: Abstract classes and methods
- From: "Michael B. Johnson" <email@hidden>
- Date: Wed, 29 Aug 2001 08:12:58 -0700
- Organization: Pixar Animation Studios
stuartbryson wrote:
>
Date: Thu, 30 Aug 2001 22:55:48 +1000
>
From: stuartbryson <email@hidden>
>
To: Cocoa Developer <email@hidden>
>
Subject: Re: Abstract classes and methods
>
>
I find it quite amusing that this is the exact example that I need it
>
for (except that I am working in 3D rather than 2D). I have a 3DObject
>
and then Sphere and Cube both inherit from 3DObject. I do not want
>
anyone (me) to be able to instantiate 3d object. It is easy to say
>
"Please don't instantiate 3DObject" to those who might use my code, but
>
if I could force it like in C++ this would ensure the quality of the
>
program etc etc.
>
>
Stuart
The way I did this exact thing in WavesWorld way back when was by having a formal "Renderable"
protocol - any object that implemented the various methods defined in the protocol was, by
definition, renderable. This let me mix things like cameras and geometry that didn't have a common
base class in a very nice way, where in C++ I would have defined an abstract base class with all
pure virtual functions and then done a mix in with the appropriate concrete superclass.
From my language agnostic perspective, this is the same thing.
--> Michael B. Johnson, Ph.D. -- email@hidden
--> Studio Tools, Pixar Animation Studios
-->
http://xenia.media.mit.edu/~wave