Style question
-
Before you get your flamethrowers out... this is a question about coding style and preference, not asking a coding question per se... While I do code, it is not as often as it used to be, and I have to rethink how some things are/should be done. In a .NET application, what process should be used to obtain a series of Setting values? A procedure? A function? Local variables? Global variables? Pass a structure? Just looking for advice... Tim
Just do what a tool such as Resharper or CodeRush suggests Then you can spend your time thinking about more important things
-
Before you get your flamethrowers out... this is a question about coding style and preference, not asking a coding question per se... While I do code, it is not as often as it used to be, and I have to rethink how some things are/should be done. In a .NET application, what process should be used to obtain a series of Setting values? A procedure? A function? Local variables? Global variables? Pass a structure? Just looking for advice... Tim
I manage my own settings (i.e. "config file") using environment variables to determine where to store them (e.g. "Program Data"; "User Data"; "Documents and Settings"; whatever ... depends on the OS). You can use the .NET "built-in" functions for managing "user.config", but .NET tends to create multiple folders, and copies of your config.file, when you start "versioning" your program (can get really confusing / messy ... IMO). As for "consumers" of your settings ... use "dependency injection". (In some cases, settings could be stored on a web server and accessed via a web service by the clients when you're dealing with an app that is "distributed"; e.g. kiosks). Since we're talking .NET ... manage you settings with a class; serialize and deserialize them using XML; and retrieve them initially at app start-up. (A "procedure" is just a "function" that "returns" void ... IMO).