May 27, 2005
Sam wrote:
> Ahhh yes!  You are right!  I have used it for classes that only house static
> methods!  My bad!
<snip top of upside-down reply>

Is there really any point in that?  D isn't Java.  D has modules for grouping functions together.

Stewart.

-- 
My e-mail is valid but not my primary mailbox.  Please keep replies on the 'group where everyone may benefit.
May 27, 2005
Sam wrote:
> Question-
> 
> Why use 'abstract' on a class definition?  Why not make all classes abstract
> that have at least 1 abstract member?  This applies to the java, C#, and D
> languages.
> 
> When would you declare a class as 'abstract' that does not have any abstract
> members??  What would be the point of this?
> 
> I believe that allowing the developer to flag a class as 'abstract' is a
> mistake.  This allows for programming stupidity to occur.
<snip>

It also enables code to be self-documenting.

Suppose you have a class that has lots of methods.  Some may be abstract.  But should one have to look through the class (and any superclasses) to check whether the class is abstract?  We might as well have this information at the beginning of the class definition itself.

It's true that you can stick a comment up there, but allowing the programmer to declare the class with the abstract attribute makes it more elegant.

This provides a neat means of setting a class to be abstract even if it has no abstract methods.  Even if we knew no use for this, to disallow it would be an arbitrary restriction, and so the notation has this by-product.

Stewart.

-- 
My e-mail is valid but not my primary mailbox.  Please keep replies on the 'group where everyone may benefit.
1 2
Next ›   Last »