-2

I have a component that have some default values. These values are used when some classes are instantiated, so the properties will be, by start, filled with the default value.

If you will ask why i'm doing these is because, these values, will be the same in the entire application. So there is no need to always repeat the same value, every time an instance is created.

So I'm thinking in 3 ways this can be done:

  • 1st like a custom .config class as in this topic.
  • 2nd using .config appSettings by adding add tags.
  • 3rd using some static or singleton class that have the properties of each value.

My question is, how these strategies is the best or there is other that i miss?

2
  • You could also use a .json file to store the default values. The syntax is flexible and I personally prefer it over XML. You can find more info here. Commented Jun 23, 2016 at 4:30
  • 1
    Who's going around downvoting all the answers, they answer the question asked it may not be what you wanted but the question was pretty broad Commented Jun 23, 2016 at 4:45

2 Answers 2

-1

Well! I would suggest you go with 2nd option.

using .config appSettings by adding add tags.

The reason is .config will also be included in client version. So what if you want to change or modify some of the values in the near/far future? Would you change them in code and rebuild all the application?

I think modifying the values in .config in deployed version will be more easy and will save your time. Trust me! when you have to re-build entire application just for a minor modification it is an overhead. :)

Hope that helps. :)

Sign up to request clarification or add additional context in comments.

Comments

-1

Honestly, I think any of your choices is fine. My recommendation is to pick whichever approach feels like the best and go with it. With solid practices, refactoring to a different pattern later should be straightforward. Plus, by starting, you will quickly learn a lot more about the problem domain allowing you to make a much better (and easier) decision.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.