Re: Modifier mixture



AD <adriaandavel@xxxxxxxxxxx> wrote:
What I'm trying to do is to use a class as an abstract class, but still
be able to use the class as a normal class. This is sounding like a
virtual class, but with the virtual class overrides are optional.

Well, I'm not sure what you mean by a virtual class here...

My current design is that my base class carries the "generic"
functionality of most applications developed by our company, so when it
is inherited it exposes that functionality to all consumer classes. Now
I would also like my base class to enforce certain functions in all
consumer classes (for example a function called "Install" that will
create all SQL Stored procs used by the module) to improve consistancy
across classes and open up some reflection possibilities.

Well, you can have a protected method that all the implementations can
call for the common things.

The only way I see this happening is creating a copy of my base class
as a true abstract class and consumer inheriting that, but that would
cause code duplication that I'm trying to avoid.

Does this make any sense?

I have to say, I'm not sure that inheritance is the best course here. I
tend to be wary of overuse of inheritance. See
http://msmvps.com/jon.skeet/archive/2006/03/04/inheritancetax.aspx
for more information on this.

However, I don't see that you need a copy of the class, even if you do
use inheritance. If you want a concrete class which has "dummy"
implementations, you can always create one which implements the
abstract methods from the base class.

--
Jon Skeet - <skeet@xxxxxxxxx>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
.



Relevant Pages

  • Re: Code reuse
    ... You asked specifically about 2 things: Inheritance and Interfaces. ... functionality, rather than functions existing outside of any class. ... re-use the base class and its functionality in each derived class. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: multiple inheritance
    ... Top level specification of state space in multiple inheritance ... The PI design technique is a wrapper for functionality around ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: multiple inheritance
    ... Top level specification of state space in multiple inheritance ... The PI design technique is a wrapper for functionality around ... The re-write of your code shows the 'statically false' ...
    (microsoft.public.dotnet.languages.csharp)
  • New OO module idea - looking for suggestions
    ... I've been working on a module that provides encapsulation, inheritance ... Another key piece of functionality is that when a method is overridden ... perl developer to explore and perhaps even enjoy some of the features ...
    (comp.lang.perl.modules)