Re: Abstract Class Theory

From: Nick Malik (nickmalik_at_hotmail.nospam.com)
Date: 11/01/04


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



Relevant Pages

  • Re: Abstract Class Theory
    ... >> there would be no need for abstract methods, and no abstract classes. ... >> the derived class will be overriding, or even overloading, the base class ... > class inherit from both. ... Actually you are confusing abstract classes and interfaces. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: What the diff between a virtual method and an inheirited method
    ... To inherit a method from a base class defined as virtual is ... > to allow the derived classes to define their own unique ... functional programming, and believe me it will make you a better ...
    (comp.lang.cpp)
  • Re: Visual Studio 2003, CollectionBase.RemoveAt Method
    ... You don't think of it as such because Microsoft also hid the ... The VB Collection class does not inherit System.Collections.CollectionBase. ... you must explicitly define a "RemoveAt" method in order to ... you can't hide anything in a derived class from a base class. ...
    (microsoft.public.vsnet.general)
  • Re: Dynamic class creation at runtime
    ... dinamically a new type that inherit directly from the base class. ... I have in my assembly the base class and 2 inherited classes: ... >> classes for each single algorithm. ... >> dynamic definition of Assemblies, but I do not want to create a new Assembly, ...
    (microsoft.public.dotnet.framework.clr)
  • Re: interfaces
    ... abstract classes serves the purpose and have all good things then what is ... but you can implement as many interfaces as you like. ... if you are creating a "Dog" class you might inherit from ... "IChaseParkedCars" were abstract classes rather than interfaces. ...
    (microsoft.public.dotnet.languages.csharp)

Loading