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

  • Home
  • SEARCH
  • 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 8776661
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T19:06:37+00:00 2026-06-13T19:06:37+00:00

i am having a constructor with Factory pattern. i am passing to many parameters.

  • 0

i am having a constructor with Factory pattern. i am passing to many parameters. how to refactor it.

ServerFactory serverFactory = new ServerFactory();
CalendarResults calResults= serverFactory.getResults(serverName,locale, Day, week,     
                            month,vdate,results,uri, EmailShare, inc, upperLimit, 
                            endLimit,exchWD, YearMonthDay,WeekMonthDate);
results=calResults.serverNameDay(serverName,locale, Day, week, month,vdate,
        results,uri, EmailShare, inc, upperLimit, endLimit, exchWD, YearMonthDay);

public class ServerFactory {
    public CalendarResults getResults(String serverName,String locale, String day,    
                     String week, String month, 
             boolean vdate, ArrayList<CalendarOutput> results, String uri, 
                     List<String> emailShare, int inc, int upperLimit, 
             int endLimit, NexWebDav exchWD, String yearMonth, boolean 
                     weekMonthDate){

        CalendarResults calresults=null;
        if(serverName.equals("www.google.com")){
            calresults=new Google();
        }else{
            calresults=new Exchange();
        }
        return calresults;
    }
 }
  • 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-13T19:06:39+00:00Added an answer on June 13, 2026 at 7:06 pm

    Hard to tell since you don’t show all the code (I assume) where all these parameters get used.

    But here are some things to consider:

    • Replaces arguments of primitive type with value objects, this makes it much clearer what parameter is expected in what position.

    • combine multiple related arguments to value objects. One example that seems obvious is upperLimit, endLimit (and maybe inc) which might end up in an object called Intervall.

    • replace booleans with different methods. Often booleans are used to perform different algorithms. If that’s the case drop the booleans an make seperate methods instead.

    • If you have still to many and to confusing arguments, you might want to go with a Builder Pattern. This and the following blog posts might be helpfull: http://blog.schauderhaft.de/2012/07/29/named-parameters-in-java/

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

Sidebar

Related Questions

I am having an issue where the base constructor for a derived class is
I'm having trouble getting a simple class constructor to work. // In XModule.h class
I'm having trouble implementing a nested class who's constructor is initialized with some of
I'm extending a constructor class' functionality via the prototype method, but I'm having trouble
Is it a common pattern/idiom to use free functions as pseudo-constructors to avoid having
Is this a good pattern? It has a code smell to me with having
I'm having difficulties finding out how to implement a 'configurable' behavior in a factory
I'm having problems with my Spring controllers - I'm getting no default constructor found
Does the C# factory pattern require an upcast? I want God in class library
I've never really looked at the Factory pattern and today decided to take the

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.