No registered users in community xowiki
in last 10 minutes
in last 10 minutes
Re: [Xotcl] Abstract class
From: Kristoffer Lawson <setok_at_scred.com>
Date: Fri, 4 Apr 2008 16:26:17 +0300
On 1 Apr 2008, at 23:35, Victor Mayevski wrote:
> Can somebody please update the XOTcl tutorial/reference to explain in
> detail what abstract class is and how to use it (examples of usage)?
> I've been looking everywhere and can't find the info.
I'm not a core XOTcl developer, but the general case for abstract
classes is that you want to have a superclass for a variety of other
classes and this superclass provides some of the methods, but not
all. The rest, or a small subset, can be specified as 'abstract'
methods. With these only the 'style' of the method is described --
what arguments it takes, what it is named, perhaps what it returns
and what it does. The sub-classes are then required to do the actual
implementation of these methods.
So say you have a general 'GraphOb' class. It has an abstract method
'draw'. It cannot draw itself, or anything else, but it expects the
sub-classes to implement this method. You might then have
'Rectangle' and 'Circle' which are subclasses of GraphOb and each of
these have a 'draw' method which draws the rectangle or circle on to
the screen.
Some classes might only have abstract methods...
Hope this explains it a bit.
/ http://www.scred.com/
/ http://www.fishpool.com/~setok/
Date: Fri, 4 Apr 2008 16:26:17 +0300
On 1 Apr 2008, at 23:35, Victor Mayevski wrote:
> Can somebody please update the XOTcl tutorial/reference to explain in
> detail what abstract class is and how to use it (examples of usage)?
> I've been looking everywhere and can't find the info.
I'm not a core XOTcl developer, but the general case for abstract
classes is that you want to have a superclass for a variety of other
classes and this superclass provides some of the methods, but not
all. The rest, or a small subset, can be specified as 'abstract'
methods. With these only the 'style' of the method is described --
what arguments it takes, what it is named, perhaps what it returns
and what it does. The sub-classes are then required to do the actual
implementation of these methods.
So say you have a general 'GraphOb' class. It has an abstract method
'draw'. It cannot draw itself, or anything else, but it expects the
sub-classes to implement this method. You might then have
'Rectangle' and 'Circle' which are subclasses of GraphOb and each of
these have a 'draw' method which draws the rectangle or circle on to
the screen.
Some classes might only have abstract methods...
Hope this explains it a bit.
/ http://www.scred.com/
/ http://www.fishpool.com/~setok/