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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T18:40:21+00:00 2026-06-08T18:40:21+00:00

I am facing the following problem: I defined an abstract class that contains the

  • 0

I am facing the following problem:

I defined an abstract class that contains the public generate, clone, etc. methods that must be implemented by the subclass. However I would like to ensure that when these public methods are called certain other methods are also executed within the abstract class.

An obvious solution would be to make a protected abstract method to be implemented and a public non-abstract method that calls the abstract one and all the other methods that I need.

For example:

abstract class Representation {

    public void generate(int variable) {
        myFunction();
        generateAbstract(variable);
    }

    protected abstract void generateAbstract(int variable);

    private void myFunction() {
        //do something
    }
}

My question is how to solve it a nicer way, or if this is the way to go how to name the function in a user-friendly way.

Thanks!

  • 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-08T18:40:22+00:00Added an answer on June 8, 2026 at 6:40 pm

    I would do it as you are doing it. I would make the wrapper method either

    1. final so I can’t be blown away in a subclass, or
    2. document the hell out of the methods, indicating that the abstract method MUST be called…
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im facing the following problem: public class StatCounterService extends Service { private TimerTask updateTask_ref
I am facing the following problem. Let's say I have a file, which contains
I am facing the following problem on a GeForce GTX 580 (Fermi-class) GPU. Just
I am facing a following problem: I need to generate detailed reports for Objective-C
Our team (QA) is facing the following problem: We have a database that is
I have the following model defined in .NET: Public Class Request <Key()> Public Property
I'm facing the following problem: I have one module in my webapp that needs
I'm facing the following problem. i have a servlet that serves a client request
Im facing following problem I have created mentioned condition, but when I choose y
I am facing Following problem, since i m a newbie to ruby on rails

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.