Re: Abstract Class Theory
From: Daniel O'Connell [C# MVP] (onyxkirx_at_--NOSPAM--comcast.net)
Date: 11/01/04
- Next message: Nicholas Paldino [.NET/C# MVP]: "Re: Variable Name in C#..."
- Previous message: Fei Li: "Re: What a stupid design of FolderBrowserDialog"
- In reply to: Nick Malik: "Re: Abstract Class Theory"
- Next in thread: Daniel O'Connell [C# MVP]: "Re: Abstract Class Theory"
- Messages sorted by: [ date ] [ thread ]
Date: Mon, 1 Nov 2004 13:07:57 -0600
"Nick Malik" <nickmalik@hotmail.nospam.com> wrote in message
news:iTshd.42920$R05.11994@attbi_s53...
>
> "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.
>
Actually you are confusing abstract classes and interfaces.
A C# abstract class is a literal class and only one abstract class can be
inherited from just as any other base class acts. An interface, on the other
hand, I think more closely matches waht you are tying to get at here, where
any number of interfaces may be implemented by a given class.
- Next message: Nicholas Paldino [.NET/C# MVP]: "Re: Variable Name in C#..."
- Previous message: Fei Li: "Re: What a stupid design of FolderBrowserDialog"
- In reply to: Nick Malik: "Re: Abstract Class Theory"
- Next in thread: Daniel O'Connell [C# MVP]: "Re: Abstract Class Theory"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|