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

The Archive Base Latest Questions

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

I have an idea that reading values from config files instead of using hard

  • 0

I have an idea that reading values from config files instead of using hard code values, but I’m not sure it is a good practice or not.

First I created a utility class:

public class ConfigValues
{ 
    public static int Read(string key, int defaultValue){....}
    public static string Read(string key, string defaultValue){....}
    public static bool Read(string key, bool defaultValue){....}
    ...
}

The Read function tries to read value for the given key. If the key doesnot exist or the value has bad format, it returns the default value. And I’m going to use this class like:

public class MyClass
{ 
    private int _age = ConfigValues.Read("Com.MyClass.Age", 0); 
    ...
}

So that, we can make almost all variables in the application customizable.
Will it be a good practice?
Please comment it for free.

  • 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-12T06:20:26+00:00Added an answer on May 12, 2026 at 6:20 am

    People who think you should make things configurable:

    • Some of the other answers
    • http://www.ebizq.net/blogs/decision_management/2007/04/dont_softcode_use_business_rul.php
    • Many good software development theories (I don’t have links handy).

    People who think differently:

    • http://ayende.com/Blog/archive/2008/08/21/Enabling-change-by-hard-coding-everything-the-smart-way.aspx (And the rest of his entries)
    • http://thedailywtf.com/Articles/Soft_Coding.aspx
    • http://benbro.com/blog/on-configuration/
    • http://jeffreypalermo.com/blog/hardcoding-considered-harmful-or-is-it/

    The answer comes down to your requirements: why are you setting this value here?

    • Is it something that different users will want set differently? => config file.
    • Is it just a default value to be changed later? => Hardcode it.
    • Is it something which affects operational use of the program (i.e. default homepage for browser)? => Config file.
    • Is it something which might have complex impacts on various parts of the program? … Answer depends on your userbase.

    Etc. It’s not a simple yes-it’s-good or no-it’s-bad answer.

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

Sidebar

Related Questions

I have a product idea that requires integration into the Microsoft Office suite. Are
Please forgive my long question. I have an idea for a design that I
Simple idea: I have two images that I want to merge, one is 500x500
I have an idea for how to solve this problem, but I wanted to
I have tried reading multiple tutorials, the PHP documentation and have no idea what
do you have idea, if there would be some nice way to browse/log JMS
I have this idea for a free backup application. The largest problem I need
I have an idea for a simple application which will monitor a group of
Anyone have any idea how to get the value of Language for Non-Unicode Programs
I have no idea. This causes seemingly random time-outs. These in turn break 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.