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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T10:44:31+00:00 2026-05-13T10:44:31+00:00

In a base class object, I have an overridable subroutine that I would like

  • 0

In a base class object, I have an overridable subroutine that I would like all derived objects to have the ability to include. However, they don’t have to, and if it’s not necessary for them to use it, I don’t want them to be forced to declare it. To enforce this, I’ve left the default behavior empty. For example, here’s my whole sub:

Protected Overridable Sub MySubroutine(ByVal someObject As Object)
End Sub

Is this bad practice? I don’t want to declare it as MustOverride, but I don’t want default behavior. Is there a “better” way of doing this, or is this perfectly acceptable? I don’t want to be that hack programmer… just trying to learn 🙂

  • 1 1 Answer
  • 1 View
  • 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-05-13T10:44:31+00:00Added an answer on May 13, 2026 at 10:44 am

    Yes, this is perfectly acceptable. A MustOverride member can often be too strict of a requirement for an inheriting class so if you want a virtual member without default implementation this is the proper thing to do.

    Anyone who is inheriting from this class will appreciate the fact that you have defined a virtual member as a “hook” into your class like this. Also the fact that you have declared this method as Protected is also a good idea as public virtual members can be problematic from a maintenance standpoint.

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

Sidebar

Related Questions

I have a tree of active record objects, something like: class Part < ActiveRecord::Base
I have a base class pointer pointing to a derived class object. I am
I have a base class object array into which I have typecasted many different
Suppose I have a base class B, and a derived class D. I wish
I have an overridable sub in my base class Project1: Public Class BaseClass Protected
I have a base class Foo that has an Update() function, which I want
I have the following models. # app/models/domain/domain_object.rb class Domain::DomainObject < ActiveRecord::Base has_many :links_from, :class_name
Fragile base class is one of the most common point that gets popped up
I have a base class with an optional virtual function class Base { virtual
I have an abstract base class which acts as an interface. I have two

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.