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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T05:25:57+00:00 2026-06-02T05:25:57+00:00

Im building a relatively large object-oriented program. I have a class called AerodynamicCalculator that

  • 0

Im building a relatively large object-oriented program. I have a class called AerodynamicCalculator that performs numerous calculations and distributes the results around the system. My main concern is that my constructor signature is getting larger and larger as I add mor parameters to it.

As shown below I already have nine object references being passed into this constructor, but I need a further seven. Am I correctly creating this object? My understanding is that you pass the associated object references to the constructor and assign the class’es local variable to the object references. If this is the case the only way to get my class properly initialized with all the required objects is to pass them to the constructor, which is leading to a very long signature.

public AreodynamicCalculator(AircraftConfiguration config, AileronOne aOne,
        AileronTwo aTwo, ElevatorOne eOne, ElevatorTwo eTwo, Rudder r,
        Rudder rr, RateGyros rG) {
    // ...
}

Any advice on this approach would be very helpful, 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-02T05:26:01+00:00Added an answer on June 2, 2026 at 5:26 am

    As mentioned – this may be a sign your class is doing too much, however, there is a commonly used ‘solution’ to this problem.

    The builder pattern is often used in this situation, but it’s also very useful when you have many constructors with different arguments, the builder is good because it makes the meaning of the arguments clearer, particularly when boolean literals are used.

    Here is the builder pattern, the way this works is like this:

    AreodynamicCalculator calc = AreodynamicCalculator.builder()
        .config(theAircraftConfiguration)
        .addAileron(aileronOne)
        .addAileron(aileronTwo)
        .addElevator(elevatorOne)
        .addElevator(elevatorTwo)
        .addRudder(rudderOne)
        .addRudder(rudderTwo)
        .build()
    

    Internally, the builder will store all these fields, and when build() is called it will call a (now private) constructor that takes these fields:

    class AreodynamicCalculator {
        public static class Builder {
            AircraftConfiguration config;
            Aileron aileronOne;
            Aileron aileronTwo;
            Elevator elevatorOne;
            Elevator elevatorTwo;
            ...
    
            public Builder config(AircraftConfiguration config) {
                this.config = config;
                return this;
            }
    
            public Builder addAileron(Aileron aileron) {
                if (this.aileronOne == null) {
                    this.aileronOne = aileron;
                } else {
                    this.aileronTwo = aileron;
                }
                return this;
            }
    
            // adders / setters for other fields.
    
            public AreodynamicCalculator build() {
                return new AreodynamicCalculator(config, aileronOne, aileronTwo ... );
            }
        }
    
        // this is the AircraftConfiguration constructor, it's now private because
        // the way to create AircraftConfiguration objects is via the builder
        //
        private AircraftConfiguration config, AileronOne aOne, AileronTwo aTwo, ElevatorOne eOne, ElevatorTwo eTwo, Rudder r, Rudder rr, RateGyros rG) {
            /// assign fields
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a relatively small app that Im building using vb.net 2.0, and nant.
I'm building a relatively simple class (ex: Person) for an ASP.NET application that has
When building a relatively large website, the CSS structure ought to be properly scoped
My company and I are building a new system for a relatively large client.
Let me clarify: I am building a relatively simple brochure site that has multiple
I'm building a component of a web page that needs relatively constant database polling.
I'm building an application which uses relatively large tables to do its work (
I am just about to undertake building a relatively large PHP system, I just
I've got a relatively large Xcode project that produces a single app. However, I
I'm building some relatively simple functions in PROLOG that take one input and one

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.