Re: subclass with static constructor

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



On Sat, 14 Mar 2009 18:21:16 -0700, John A Grandy <johnagrandy@g-mail-dot-com> wrote:

Here is what I'm attempting to accomplish ( and I am agnostic as to the implementation details ).

I have a variety of data-access functionality , meant to be accessed statically.

Why statically? Is that a firm requirement? If it's meant to be accessed statically, how does the fact that your base class has instance members (I'm assuming it does, since you are inheriting it, and you can't inherit a static class) fit into that?

From your description, it seems to me that you have an inheritance relationship between the functionality. But you can only inherit with instances. So, why not just make the classes instantiable? If you want to ensure only one instance per database, then you can use the singleton pattern to ensure that.

It seems to me that the closest next alternative would be to replicate the entire general-purpose API found in the base class, as static members in the database-specific classes. Then those members can delegate the general-purpose functionality to the base class. But, this is a pretty awkward approach IMHO...it requires a lot of extra work, for no apparent benefit that I can see.

Pete
.



Relevant Pages

  • How can I hide base class members that are public
    ... the features of the base class. ... the members of the base class library i.e. only expose those members that I ... is not to inherit the base class but simply create an instance of it and use ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: How can I hide base class members that are public
    ... > the features of the base class. ... > the members of the base class library i.e. only expose those members that I ... members, don't inherit from it. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: subclass with static constructor
    ... Instance classes and singletons is what I have presently. ... But you can only inherit with instances. ... It seems to me that the closest next alternative would be to replicate the entire general-purpose API found in the base class, as static members in the database-specific classes. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Removing properties from usercontrol
    ... > the features of the base class. ... > the members of the base class library i.e. only expose those members that ... members, don't inherit from it. ... I basically want it to work like using interfaces, you know, expose ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: inheritence
    ... I wrote a Base class to dealer with Text Files ... i want to inherit this class to extend its functionality ... i want to inherit a class. ... public class Achild ...
    (microsoft.public.dotnet.languages.csharp)