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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T22:35:43+00:00 2026-06-06T22:35:43+00:00

I execute some tests within my application, but before doing that I have to

  • 0

I execute some tests within my application, but before doing that I have to initialize my response information (Execution directory, used resources..etc).

After a specific point I will be able to identify the test type I’m about to execute so now I have to have an appropriate response instance, but this forces me to copy the fields from the old object to the new one manually which causes bugs when things change.

For example, assume I have the following classes:

class BaseResponse{
    private int port;
    private int trials;
    protected BaseResponse(BaseResponse response){
        this.port = response.port;
        this.trials = response.port;
    }
}
class TcpResponse extends BaseResponse{
    public TcpResponse(BaseResponse response){
        super(response);
    }
    private int tcpSpecificMetric;
}

So as a start I initialize the BaseResponse class, fill it up, then when I find out I’ll be running a TCP test, I have to initialize a new TcpResponse !

Would someone advice about a good design for this ?
Thanks in advance.

  • 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-06T22:35:44+00:00Added an answer on June 6, 2026 at 10:35 pm

    Write a factory (aka virtual constructor) or builder that knows how to create different types of BaseResponse based on the parameters passed to it.

    public class BaseResponseFactory {
        private static BaseResponseFactory INSTANCE = new BaseResponseFactory();
    
        private BaseResponseFactory() {}
    
        public static BaseResponseFactory getInstance() { return INSTANCE; }
    
        public BaseResponse create(int port, int trials) { return new BaseResponse(port, trials); }
    
        public BaseResponse create(int port, int trials, int tcpMetric) { return new TcpResponse(port, trials, tcpMetric); }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a post build event that runs nunit-console to execute some tests. some
I have finished the majority of my application that I am working on, but
i want to execute some commands using NSIS script , but for the commands
I need execute some code before Windows shutdown process each time. So, I want
I have to execute some code in the context of the main thread. I
I have written a java program that tests the speed of a couple of
I need to execute some dynamically generated code in Python and ensure that this
Suppose that I have a Java program within an IDE (Eclipse in this case).
I used to have a standalone script with some unit tests to test data
I'm new to Python and I'm doing some tests with it. What I need

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.