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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T13:01:12+00:00 2026-05-20T13:01:12+00:00

I have a factory class that currently takes 6 params in it’s constructor, and

  • 0

I have a factory class that currently takes 6 params in it’s constructor, and I just hit a need to add another.

Normally, this would scream to me “Hey, your class has too many dependencies, therefore, it does too much!”

However, given this class is strictly a factory, is that really the case? Should I be concerned about the growing number of dependencies? If so, what strategies should I consider for refactoring this?

Update:
I had considered the builder pattern, but for a factory, isn’t that overkill?

(Ie., WidgetFactoryBuilder, which builds a factory which builds widgets.).

Additionally, I don’t understand how a builder really alleviates my dependencies – it just moves them from the constructor to methods — which seems to obfuscate things more — however this could be down to a poor understanding of how to apply the builder pattern in this situation.

  • 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-05-20T13:01:13+00:00Added an answer on May 20, 2026 at 1:01 pm

    First of all, I should mention that I don’t necessarily think six parameters are too many. But if you insist…

    I don’t think the problem at all lies in the number of parameters to the constructor.

    The builder pattern that others recommend is useful for classes that contain a lot of state. This is rarely the case for a factory. I am instead going to assume that the parameters you are talking about are dependencies on other classes. The real problem is that your factory has too many dependencies – not that its constructor takes too many arguments.

    Instead you need to look at design. Why does the factory have so many dependencies? Is it possible to reduce that number somehow? Maybe the objects that the factory creates are themselves too complex?

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

Sidebar

Related Questions

I have a factory class that populates objects with data. I want to implementing
I have a factory that returns an interface FormatService : public class FormatServiceFactory {
Problem I currently have a factory that depends on a few parameters to properly
Currently I have Windsor controller factory that is working well. However, I am changing
I have the following code for factory design pattern implementation. class Pen{ public: virtual
I have a factory that builds the objects with longest lifetime in my application.
I have a abstract base class that I have many inherited classes coming off
I am currently trying to create a generic instance factory for which takes an
The below code is a factory class that is delivers objects of type IGraph
I am trying to make a factory that will have the type passed in,

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.