Re: Modifier mixture
- From: Jon Skeet [C# MVP] <skeet@xxxxxxxxx>
- Date: Tue, 12 Dec 2006 07:38:40 -0000
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
.
- References:
- Modifier mixture
- From: AD
- Re: Modifier mixture
- From: Jon Skeet [C# MVP]
- Re: Modifier mixture
- From: AD
- Modifier mixture
- Prev by Date: Re: Initializing static readonly methods
- Next by Date: how to get IPaddress's long value
- Previous by thread: Re: Modifier mixture
- Next by thread: Re: Modifier mixture
- Index(es):
Relevant Pages
|