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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T19:36:18+00:00 2026-05-10T19:36:18+00:00

I have a class called Ship and a class called Lifeboat Lifeboat inherits from

  • 0

I have a class called Ship and a class called Lifeboat

Lifeboat inherits from Ship.

Ship contains a method called Validate() which is called before save and it has an abstract method called FurtherValidate() which it calls from Validate. The reason this is in place is so when you call validate on the base it also validates the class that is inheriting. So we have

public class Ship  public bool Validate() {     //validate properties only found on a ship      FurtherValidate(); }  public abstract bool FurtherValidate(); 

So Lifeboat has

public override bool FurtherValidate() {     //validate properties only found on a lifeboat } 

This means anyone implementing Ship also needs to provide their own validation for their class and it’s guaranteed to be called on the save as the base ship. Validate() is called which in turns calls the inherited validate.

How can we re work this so we still force inherited classes to implement FurtherValidate() but FurtherValidate() can never be called by the programmer. Currently you can called Lifeboat.FurtherValidate() and I want to somehow prevent this.

  • 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-10T19:36:18+00:00Added an answer on May 10, 2026 at 7:36 pm

    The exact scenario you describe isn’t possible. You can restrict access to the FurtherValidate method to only derived classes by using the protected access modifier. You could also restrict it to only classes in the same assembly by using the internal modifier, but this would still allow the programmer writing the derived class to call FurtherValidate any time they wish. Using both protected and internal combines the two and really means that is restricted to derived classes or classes defined in the same assembly.

    Using the [EditorBrowsable] attribute is an IDE trick that will hide the method from IntelliSense (unless the other programmer has turned on the right options in VS). That will effectively prevent most people from calling it (if they can’t see it, it doesn’t exist).

    You could possibly achieve this using reflection to interrogate who your caller is, but I think the performance costs of doing this would be too high compared to the benefit.

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

Sidebar

Ask A Question

Stats

  • Questions 62k
  • Answers 62k
  • 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 Focus events might work; you might also want to consider… May 11, 2026 at 10:10 am
  • added an answer is it safe to send login info via ajax You… May 11, 2026 at 10:10 am
  • added an answer Its not the NOCOUNT thats causing this, your stored procedures… May 11, 2026 at 10:10 am

Related Questions

I have a class called Ship and a class called Lifeboat Lifeboat inherits from
I have a class called EventConsumer which defines an event EventConsumed and a method
I have a class called DatabaseHelper that wraps a DbConnection. What's the proper way
I have a class called User with static function loginRequired(), which returns false if
Say I have a class called PermissionManager which should only exist once for my
Let's say I have a class called Store that has many Employees. My RESTful
i have a module (a single .py file, actually), with a class called HashedDir.
In a C++ physics simulation, I have a class called Circle, and Square. These
I have a CSS class called grid which I place on my tables. I
Let's say I have a class in my web app called class Foo. It

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.