Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8635815
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T10:04:03+00:00 2026-06-12T10:04:03+00:00

If I inherit from a base class, is there a rule which states only

  • 0

If I inherit from a base class, is there a rule which states “only inherit where you need to implement/use all (or X%) of the base classes functionality/methods”? I understand that if I inherit then I have inherited the lot, but that doesn’t mean I have to use it all.

Assume the following pattern:

public abstract class Template
{   
    public void LoadCustomer()
    {
        //Load customer logic
    }
    public virtual void LoadGrid()
    {
        //Logic   
    }
    public virtual void other()
   { //logic }

    public virtual void other2()
   { //logic }

    public virtual void other3()
   { //logic }

    public string WelcomeMessage()
    {
         //perform lots of complex logic
         return "Hello and welcome";
    }
}

If part of my application wants to only show the WelcomeMessage(), would it be wrong to inherit from the Template class above (I know I can only inherit once but that isn’t factor for this question) (also note, I’ve purposely not included any abstract methods/fields).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T10:04:04+00:00Added an answer on June 12, 2026 at 10:04 am

    I went down this road on quite a few of my projects before I “saw the light.”

    is there a rule which states “only inherit where you need to implement/use all (or X%) of the base classes functionality/methods”?

    Yes and no. No that there is no rule, but yes that there is a way to do what you want to do. It’s call favoring composition over inheritance and what that means is that you need to break off each block of functionality into a single class, and then (in what is currently your sub-classes) create an instance of that class and then delegate the needed work to it. Using this technique will allow you to easily make modifications to what is currently your super-class without having ripple effects on your current sub-classes.

    Bottom line, when in doubt (or if it just feels funny) don’t use inheritance. This is embodied by the Liskov substitution principle which states that any sub-class should be a full and proper substitute for it’s super class. (i.e. don’t have Boat subclass Plane just because they can both carry people).

    For more fun reading, check out the SOLID software engineering paradigm.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I use reflection find all the Classes in my project that Inherit from Packet.Base
I have two classes (MVC view model) which inherits from one abstract base class.
I have a bunch of stored, serialized classes (that all inherit from a base
I have a base class, SpecialClass . Lots of other classes inherit from it,
All of my controls inherit from a base class that creates and assigns a
I have two classes that inherit from the same base class but do not
In Visual Studio, How do I show all classes inherited from a base class?
I have two case classes that inherit from an abstract base class. I want
I have a series of composite user controls that inherit from a base class
I have two classes, one that inherits from the other. The base class is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.