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

Ask A Question

Stats

  • Questions 123k
  • Answers 123k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer DB2 After Insert trigger: CREATE TRIGGER NEW_REVIEW AFTER INSERT ON… May 12, 2026 at 12:57 am
  • Editorial Team
    Editorial Team added an answer Well, I've finally worked out a solution to my problem.… May 12, 2026 at 12:57 am
  • Editorial Team
    Editorial Team added an answer You can create a singleton by adding your instance into… May 12, 2026 at 12:57 am

Related Questions

Say you have a 'post' object in a typical blog scenario. A blog post
In VS .NET, when you are selecting a folder for a project, a dialog
I am trying to decide if a string is a number in Ruby. This
I make extensive use of source control for anything that relates to a project

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.