I am using predefined objects nested inside static class to store objects information at single place, and later i used them after some logic to populate normal objects with properties of predefined object.
What will you say that this approach is fine or I can achieve the same by some other efficient and better way?
//Example of storing predefined objects
public static class RegistrationGift
{
public class InvitedRegistrationGift
{
public const int Token = 5;
public const int Dollar = 0;
}
}
//how it will be used to populate credit entity (conversion)
Credit credit = new Credit();
credit.Token = RegistrationGift.InvitedRegistrationGift.Token;
// and so on
Using static classes will not bring major problems, however the singleton pattern may fits better in this case.
Consuming:
A variation of this is not to implement the singleton pattern, but keep the .Current accessor and define a public setter, so you can change the active config.
Then, on the app startup you set the config.
And consume:
The advantage is that you can create instances with predefined values to use, for example, in unit tests.