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 92887
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T23:15:28+00:00 2026-05-10T23:15:28+00:00

When reviewing our codebase, I found an inheritance structure that resembles the following pattern:

  • 0

When reviewing our codebase, I found an inheritance structure that resembles the following pattern:

interface IBase {     void Method1();     void Method2(); }  interface IInterface2 : IBase {     void Method3(); }  class Class1 : IInterface2 {     ... }  class Class2 : IInterface2 {     ... }  class Class3 : IInterface2 {      ... } 

In Class2, Method1 throws NotImplementedException.

Questions:

  • What do you think in general about inheriting interfaces?
  • Does the relationship between IBase and Class2 violate the Liskov Substitution Principle?
  • 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-10T23:15:29+00:00Added an answer on May 10, 2026 at 11:15 pm

    Well, first of all, I’m generally against implementing an interface by throwing NotImplementedException exceptions. It is basically like saying ‘Well, this class can also function as a calculator, err, almost’.

    But in some cases it really is the only way to do something ‘the right way’, so I’m not 100% against it.

    Just something to be aware of.

    An interface is a contract, by implementing the interface you say that you abide by the contract. If you then start negating parts of the contract, it sounds to me as the contract, or the implementation of it, was poorly thought out.


    Edit: After seing Greg Beech‘s answer: If an interface specifically says that implementations should throw these exceptions, then it’s part of the contract, then I agree that the class is fully allowed to do it.


    As for the substitution principle, it states that:

    Let q(x) be a property provable about objects x of type T. Then q(y) should be true for objects y of type S where S is a subtype of T.

    In this context, it violates the principle just as much as overriding a method from a base class does, if you change what the method does in the descendant type.

    The principle is more detailed on the wikipedia page, like the following points (parenthesis and emphasis on my comments):

    • Preconditions cannot be strengthened in a subclass. (A precondition could be that ‘the class is ready for a call to this method at this point’)
    • Postconditions cannot be weakened in a subclass. (A postcondition could be that after calling the method, something is true about the state of the class)

    Since you have not shown the full contract of your interfaces, only the declarative part that the compiler can check, it is impossible to know wether the principle holds for your implementation of not.

    For instance, if your Method2 has the following conditions attached to it:

    • Can be called at all times
    • Modifies the state of the object to be ready for the next event in a chain of events

    Then throwing a NotImplementedException violates the principles.

    However, if the contract also states that:

    • For classes that doesn’t support chains of events, this method should throw NotImplementedException or NotSupportedException

    Then it probably does not.

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

Sidebar

Ask A Question

Stats

  • Questions 70k
  • Answers 70k
  • 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
  • added an answer I would stay away from anything that would run too… May 11, 2026 at 1:05 pm
  • added an answer You may be able to use a PageMethod to call… May 11, 2026 at 1:05 pm
  • added an answer Search for 'Identifiers' in your SQL Books online, and you… May 11, 2026 at 1:05 pm

Related Questions

When reviewing, I sometimes encounter this kind of loop: i = begin while (
When editing XAML in VS2008 SP1, the editor is really slow. devenv process seems
When should I include PDB files for a production release? Should I use the
When using jQuery 's ajax method to submit form data, what is the best
Below are two ways of reading in the commandline parameters. The first is the
OK... I'm a VB.NET WinForms guy trying to understand WPF and all of its
What does it mean when we say an application can run in CGI mode?

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.