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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T05:24:22+00:00 2026-05-31T05:24:22+00:00

There is an abstract class called AbstractAgent and currently there are 27 classes who

  • 0

There is an abstract class called AbstractAgent and currently there are 27 classes who are extending this class.

I have started developing some agents and all my 5 agents are extending AbstractAgent class.

Now I observed that there is a getFilePath() which I am copy-pasting in all my 5 agents. Then I realized that out of existing 27 classes also there were many classes who had this method. I thought it would be a good idea to put this method in the base class AbstractAgent and let everybody use this method. But I dont want all existing classes to change their code I have changed the method name so that going forward anyone can use it.

The person who did my code review suggested me not to touch AbstractAgent class because it is already being used by existing clients and put this method is some utility class.

I am not convinced by his argument. Anybody want to pitch in their thoughts.

  • 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-05-31T05:24:23+00:00Added an answer on May 31, 2026 at 5:24 am

    If the getFilePath() method is exactly the same for all of AbstractAgent‘s subclasses, then by all means go ahead and pull it up to the abstract class (use your IDE’s refactoring tools), delete it from the subclasses then run unit tests (you do have unit tests, right?) and check that everything is working fine.

    If there are differences between some implementations of getFilePath(), but most of them are identical, it’s still a good idea to pull the most common implementation up to the abstract class, delete it from the subclasses that use it and override the method in the subclasses in those cases where the implementation differs.

    Now, if there’s just too much variability between the different implementations of the method, leave the code base untouched.

    Defining a static method in a utility class (say, FileUtil) makes sense only if the method is not directly related to the functionality of the Agent classes, or if the method could be of use in some other part of the object hierarchy, not directly related to agents.

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

Sidebar

Related Questions

I have some abstract class called IClass (has pure virtual function). There are some
I have an abstract base class called Curve . There are three classes that
Let's say I have an abstract parent class called shape, and that there are
I have an abstract class Entity . Every class extending Entity will need some
Are there some practical programming situations for someone to declare a class abstract when
Is there a way to require that a class have a particular abstract member?
I have this (shortened): abstract class MyModel { const DBID = ; const TOKEN
Let's say I have three classes set up as follows: abstract Class A {
I have an abstract class called DatabaseRow that, after being derived and constructed, is
I have an abstract entity base class defined like this: public abstract class SessionItem

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.