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

  • Home
  • SEARCH
  • 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 85029
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T22:01:30+00:00 2026-05-10T22:01:30+00:00

I am dealing with a large codebase that has a lot of classes and

  • 0

I am dealing with a large codebase that has a lot of classes and a lot of abstract methods on these classes. I am interested in peoples opinions about what I should do in the following situation.

If I have a class Parent-A with an abstract method. There will only be 2 children. If Child-B implements AbstractMethodA but Child-B does not as it doesnt apply.

Should I

  1. Remove the abstract keyword from parent and use virtual or dynamic?
  2. Provide a empty implementation of the method.
  3. Provide an implementation that raises an error if called.
  4. Ignore the warning.

Edit: Thanks for all the answers. It confirmed my suspicion that this shouldn’t happen. After further investigation it turns out the methods weren’t used at all so I have removed them entirely.

  • 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. 2026-05-10T22:01:30+00:00Added an answer on May 10, 2026 at 10:01 pm

    If AbstractMethodA does not apply to Child-B, then Child-B should not be inheriting from Parent-A.

    Or to take the contrapositive, if Child-B inherits from Parent-A, and AbstractMethodA does not apply to the child, then it should not be in the parent either.

    By putting a method in Parent-A, you are saying that the method applies to Parent-A and all its children. That’s what inheritance means, and if you use it to mean something different, you will end up in a serious dispute with your compiler.

    [Edit – that said, Mladen Prajdic’s answer is fine if the method does apply, but should do nothing for one or more of the classes involved. A method which does nothing is IMO not the same thing as a method which is not applicable, but maybe we don’t mean the same thing by ‘doesn’t apply’]

    Another technique is to implement the method in Child-B anyway, but have it do something drastic like always returning failure, or throw an exception, or something. It works, but should be regarded as a bit of a bodge rather than a clean design, since it means that callers need to know that the thing they have that they’re treating as Parent-A is really a child-B and hence they shouldn’t call AbstractMethodA. Basically you’ve discarded polymorphism, which is the main benefit of OO inheritance. Personally I prefer doing it this way over having an exception-throwing implementation in the base class, because then a child class can’t ‘accidentally’ behave badly by ‘forgetting’ to implement the method at all. It has to implement it, and if it implements it to not work then it does so explicitly. A bad situation should be noisy.

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

Sidebar

Ask A Question

Stats

  • Questions 121k
  • Answers 121k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer how about treating them as integer 1's and 0's, and… May 12, 2026 at 12:18 am
  • Editorial Team
    Editorial Team added an answer I think if you produce an application as an LLC… May 12, 2026 at 12:18 am
  • Editorial Team
    Editorial Team added an answer If your sql server supports it you can create an… May 12, 2026 at 12:18 am

Related Questions

I'm working on a large, aging code base for an MFC app. The code
I'm building a toy database in C# to learn more about compiler, optimizer, and
I have inherited a single project in svn: 30Gb in over 300 000 files.
site_id | start_date | end_date 1 | oct 1, 08 | oct 2, 08

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.