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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T03:35:01+00:00 2026-06-13T03:35:01+00:00

I currently have a class named ConfigProfile factory and it contains methods for say

  • 0

I currently have a class named ConfigProfile factory and it contains methods for say a default profile, current settings, ect. This class gets used internally by my Profile service. I was thinking that it would be better to simply make this a true factory and just create the appropriate Profile Service for each of the products we are configuring.

    public string GetDefaultProfile(string product)
    {
        if (string.IsNullOrEmpty(product))
        {
            throw new ArgumentNullException("product");
        }

        string profile = null;

        if (product.Contains("Product 1", StringComparison.CurrentCultureIgnoreCase) ||
            product.Contains("product1", StringComparison.CurrentCultureIgnoreCase))
        {
            profile = Resources.product1DefaultProfile;
        }

        return profile;
    }

that is only one product there, but we have several more which means I will have to add more if statements for each one. The profile service already has an interface and is what gets used for most of my program. Also there are several methods that use this same way of doing things. So would a factory that returns the appropriate profile service based on product name be a better solution or is there something else I could do?

Edit: This is one of the simpler methods in this class. the more complex one is the one that retrieves the current system settings from the required places. Like all products have IIS settings, but some will have theme support while others will have database configuration to do.

  • 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-13T03:35:02+00:00Added an answer on June 13, 2026 at 3:35 am

    Factory is a very good solution. It allows you to hide the configuration complexity behind a simple interface.

    If you need to be able to configure it at run-time/start-up, combine with Strategy.

    Both solutions – static factory or Strategy – can be combined with Prototype. Prototype would be useful as an optimization, if you often use the same profile, and it’s read-only.

    EDIT: You are probably using Prototype already. Your sample code looks like you are copying/referencing a profile rather than building it as a complex product.

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

Sidebar

Related Questions

I have something like this currently: <div class = className style = position: absolute;
I currently have a class called clientActivity that contains a finger paintig activity that
Currently I have a class that looks like this: public class MyClass : IMyClass
Currently, I have a database access class named DB , which uses PDO .
I currently have a VB.NET class named Customers and it's been steadily growing in
I have a class named Page with a private property currently called _pageData which
I currently have a class file with the following enumeration: using System; namespace Helper
I currently have a class where I need accomplish the equivalent of the following
I am developing a web form using Visual Web Developer Currently I have class
Currently I have a class that is extending the ListActivity class. I need to

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.