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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T20:23:05+00:00 2026-06-09T20:23:05+00:00

I am working on existing code to enhance the functionality. In existing code I

  • 0

I am working on existing code to enhance the functionality.

In existing code I saw there are multiple constructors with string parameters. like

public class A {
    public A(String a){
    }

    public A(String a, String b){
    }

    public A(String a, String b, String c){
    }
}

While enhancement i found that i need to add another string parameter to the constructor.
However this seems to be problem, there could be another enhancement in that i have to add anther string.

I want to avoid such scenario.

What could be the best design to avoid such scenario?

Is good solution is to use HashMap?

  • 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-09T20:23:06+00:00Added an answer on June 9, 2026 at 8:23 pm

    Is good solution is to use HashMap?

    It’s not really clear what problem you’re trying to solve, but you might want to consider encapsulating the parameters in another class – perhaps one which is mutable, following the builder pattern. That would leave you with something like:

    FooParams params = new FooParams().withA("a value")
                                      .withB("b value")
                                      .withC("c value");
    Foo foo = new Foo(params);
    

    (You could even have a buildFoo() method in FooParams to keep the whole thing fluent.)

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

Sidebar

Related Questions

existing code which I cannot modify, here expand class is a just a functionality
Working on existing code, I recently found smt like this: if(Config.ExceptionBehavior.DEBUG_EXCEPTIONS) { foo.Foo(); }
I'm working on some existing code. After a few hours, I've boiled this problem
I'm working on some existing c++ code that appears to be written poorly, and
I'm working on modifying some existing code for a payment gateway and I'm not
Currently, I am working on restructuring an existing code base. I'm new to php
I'm working on an existing code base and got back an object with an
I am working on a project with existing code which uses mainly C++ but
I am working on a web application with an existing code base that has
I'm new to SQL Server. Currently I'm working on an existing source code and

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.