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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T16:45:03+00:00 2026-05-10T16:45:03+00:00

I have never seen a way to do this nicely, i would be interested

  • 0

I have never seen a way to do this nicely, i would be interested in seeing how others do it. Currently i format it like this:

public Booking createVehicleBooking(Long officeId,                                      Long start,                                      Long end,                                     String origin,                                      String destination,                                      String purpose,                                              String requirements,                                      Integer numberOfPassengers) throws ServiceException { /*..Code..*/ } 
  • 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. 2026-05-10T16:45:04+00:00Added an answer on May 10, 2026 at 4:45 pm

    A large set of parameters like this is often (but not always) an indicator that you could be using an object to represent the parameter set. This is especially true if either:

    • There are several methods with similar large parameter sets, that can be replaced with a single method taking a parameter object.

    • The method is called create...

    So your above code could become (pardon my C++, I’m a Java developer):

    class BuildVehicleBooking {     Long officeId;     Long start;     Long end;     String origin;     String destination;     String purpose;                  String requirements;     Integer numberOfPassengers;      Booking createVehicleBooking () throws ServiceException { ... } } 

    This is the Builder Pattern. The advantage of this pattern is that you can build up a complex set of parameters in pieces, including multiple variations on how the parameters relate to each other, and even overwriting parameters as new information becomes available, before finally calling the create method at the end.

    Another potential advantage is that you could add a verifyParameters method that checked their consistence before you go as far as creating the final object. This is applicable in cases where creating the object involves non-reversible steps, such as writing to a file or database.

    Note that, as with all patterns, this doesn’t apply in every case and may not apply in yours. If your code is simple enough then this pattern may be over-engineering it. If the code is getting messy, refactoring into this pattern can be a good way to simplify it.

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

Sidebar

Related Questions

I'm wondering why I have never seen the following way to implement templates in
I have never seen this before, the rows will be sequential but I have
I am not strong on my PHP knowledge, but I have never seen this
I have seen this talked about but never answered. Maybe it has and I'm
I have never seen this before. I have a simple custom view that has
This has never happened before. Never have I seen ANY of these warnings. There
I have never seen a buffer overflow exploit in live action. Suppose I found
I have never seen the usecase for pre-increment and post-increment in actual code. The
I have seen many souce codes but I have never ever come across a
I would like to use Android phones as a way to do some processing

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.