-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?

Community
  • 1
  • 1
Jonny Piazzi
  • 3,684
  • 4
  • 34
  • 81
  • 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](http://stackoverflow.com/questions/18538428/loading-a-json-file-into-c-sharp-program). – LAT Jun 23 '16 at 04: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 – Alex W Jun 23 '16 at 04:45

2 Answers2

-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. :)

Asad Ali
  • 361
  • 1
  • 15
-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.

Jeff Siver
  • 7,434
  • 30
  • 32