Re: Abstract Class Theory
From: Nick Malik (nickmalik_at_hotmail.nospam.com)
Date: 11/01/04
- Next message: Daniel Jin: "Re: Question about attributes..."
- Previous message: Zach: "Re: Visual style"
- In reply to: Dan Sikorsky: "Re: Abstract Class Theory"
- Next in thread: Daniel O'Connell [C# MVP]: "Re: Abstract Class Theory"
- Reply: Daniel O'Connell [C# MVP]: "Re: Abstract Class Theory"
- Messages sorted by: [ date ] [ thread ]
Date: Mon, 01 Nov 2004 15:46:22 GMT
"Dan Sikorsky" <dsikor@gte.net> wrote in message
news:OMWADrBwEHA.1204@TK2MSFTNGP10.phx.gbl...
> The purpose of my posting was to determine just what the benefits are for
> inclusion of an abstract class type in the language. We could propose that
> each class method have a default definition - if only to return true. Then
> there would be no need for abstract methods, and no abstract classes.
Again,
> the derived class will be overriding, or even overloading, the base class
> anyway.
>
> If you don't know the definition of a method until the base class is
> inherited by a derived class and the derived class overrides or overloads
> it; just supply a default definition by returning true, or false.
>
> What specific clear benefits to having abstract methods are there?
>
If you read into the Patterns literature, you can see that the requirement
to define an interface presents different benefits and costs than the option
of defining a base class. In many patterns, the creation of code in the
base class would defeat the pattern, or change the pattern to another, with
different attributes. Sometimes, the ONLY right answer is one in which the
abstract class is defined as purely abstract.
In addition, if you define two abstract classes, you can have a concrete
class inherit from both. On the other hand, you cannot have a concrete
class inherit from two base classes due to C#'s limitation against multiple
inheritance. Therefore, with the restriction against multiple inheritance,
the use of abstract classes is absolutely essential to the ability of a
developer to specify multiple interfaces for an object.
HTH,
--- Nick
- Next message: Daniel Jin: "Re: Question about attributes..."
- Previous message: Zach: "Re: Visual style"
- In reply to: Dan Sikorsky: "Re: Abstract Class Theory"
- Next in thread: Daniel O'Connell [C# MVP]: "Re: Abstract Class Theory"
- Reply: Daniel O'Connell [C# MVP]: "Re: Abstract Class Theory"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|