OK to keep it really simple im is the best method for the choice of DB operators in a method: singletons, Registry patterns, static config class, or config files.
Ive been reading about this and it seems that many contradictory ideas are this.
I understand that no one can fit all the solutions, but generally what is the best practice for this type of problem. Do not use singleton, it is not a huge huge global variable, whose preliminary process is your process.
not manages this resource.
What you want is an object that depends on the injection in every radius, in other words the pattern you are looking for is dependency injection.
For the simplest app, simply use the command line parameter and a config object.
For a slightly more complex application, allow a config-file to be the default config object, and then modify it with the command-line parameter.
Minor more complex apps, integrated with your platform / language / original registry feature to provide default.
For production applications, use the IoC-DI container and config / db / your application is currently injected into classes and runtime.
There is a key to avoiding being a process-stationary config object, because it will interfere with testing, soft-restart, and difficult to migrate more flexible configuration methods.
Comments
Post a Comment