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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T07:59:59+00:00 2026-05-26T07:59:59+00:00

I wanted to know if this was good practice or not, I am not

  • 0

I wanted to know if this was good practice or not, I am not really sure if this class should be static class or not?

   public class SettingsHelper
{
    public static readonly string MinVal= "MinVal";
    public static readonly string MinPartners = "MinPartners";

    public static IDictionary<string, string> GetSettings(string jsonsettings)
    {
        var settings = JsonConvert.DeserializeObject<Dictionary<string, string>>(jsonsettings);
        return settings;
    }


    public string SettingsToJson(IDictionary<string, string> settings)
    {
        var jsonsettings = JsonConvert.SerializeObject(settings);
        return jsonsettings;
    }


    public static decimal GetMinPartners(string jsonsettings)
    {
        var settings = GetSettings(jsonsettings);

        string partners;
        settings.TryGetValue(MinPartners, out partners);

        return decimal.Parse(partners);
    }

    public static int GetMinValue(string jsonsettings)
    {
        var settings = GetSettings(jsonsettings);

        string pival;
        settings.TryGetValue(MinVal, out pival);

        return int.Parse(pival);
    }

}

I want to include methods such as, update partners, add partners etc…

  • 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-26T07:59:59+00:00Added an answer on May 26, 2026 at 7:59 am

    I assume that with ‘static class’ you mean a class with only static methods.

    There are very few good reasons for static methods. Maybe if you need to implement a real Singleton (something that will try to kill you if it exists twice). But this doesn’t seem to be the case here.

    There are some acceptable reasons for static methods like

    • there is no state
    • alternative implementations really don’t make much sense

    These might apply in your case. => so the design might be ok.

    Probably a proper class (or possibly a class per method) might be even better.

    Clients of your methods/classes would get an instance in the constructor, possibly with a default constructor which creates the normal instances.

    Here is what you would gain:

    • When testing clients you can easily provide canned answers with mocks, you don’t need to use valid json strings. In case of clients that don’t create these Strings themselves this prevents tons of failures unrelated to the actual class under test when the structure of your json string changes.

    • When some day some of this information comes from xml, a database or divination, especially when this distinction is made by client and not be type of information, it will be easy to switch.

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

Sidebar

Related Questions

I wanted to know if this was thread safe/ good practice. My IOC is
I just wanted to know if I can point to class using this implementation:
Just wanted to know if it was a good JavaScript practice. Let's say I
I'm very new to facebook and wanted to know if this is even possible
I've seen this is various codebases, and wanted to know if this generally frowned
I know this is somewhat of a server question, but I wanted to ask
I wanted to know how PHP would execute this. Order of operations addslashes(strip_tags($record['value'])); Is
I get this warning in my error logs and wanted to know how to
This is something that's I've wanted to know recently, mostly out of curiousity. I'm
I wanted to know how to use threads in Cocoa. I'm new to this

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.