Re: Abstract classes and methods
Re: Abstract classes and methods
- Subject: Re: Abstract classes and methods
- From: Marco Scheurer <email@hidden>
- Date: Wed, 29 Aug 2001 19:24:31 +0200
On Wednesday, August 29, 2001, at 02:55 PM, Ondra Cada wrote:
Is it? Let's say, is NSView really meaningless on its own? Would it be
sensible to prevent its instantiation?
SB> but if you subclass it e.g. Square,
SB> Circle etc. then those classes can be used.
Right. Very common case. But where comes the useability of the
abstractness from?
Either the Shape class would have no -initWith... and
+shapeWith...methods;
if so, nobody would try to instantiate it directly anyway. Or it might
have a
number of -initWith... and +shapeWith... methods which actually return
subclasses, and we are speaking class clusters.
I think you are mixing issues here: why would the Shape class have no
initWith... method? The NSView class has a initWithFrame: method, even
though it can be considered abstract. Support for abstractness is
related to alloc rather than init (as demonstrated by Greg Titus
implementation of such a feature), but why bother?
Of course, I agree 100% with you that language level support for
abstract classes is unneeded, and does not fit with Objective C dynamic
aspects. Furthermore, NSObject, NSView are abstract classes, and nobody
will stop you from instantiating an NSObject, and this is OK with me:
doing otherwise would fall in the same know-it-all arrogance as "final"
in Java and non virtual functions in C++.
Marco Scheurer
Sen:te, Lausanne, Switzerland
http://www.sente.ch