Should all the fields in a GlobalSettings modelling class be static ( C# centric )?

The idea is that the ApplicationSettings class will get some default values from a configuration / resource file and later on some but not all from those settings will be applied to UserSettings

-------------Problems Reply------------

You should have only instance fields in such a class, and make the whole class a Singleton if needed (although be careful not to expose it globally - singletons are evil).

Static fields cannot be serialized (which is important for a settings class). Second thing, by having instance fields, you can easily pass different instances of settings to different parts of your app. And the important point is to pass the settings to the rest of the application, not to make them globally visible so that every object can access them.

Category:c# Views:0 Time:2009-06-23

Related post

Copyright (C), All Rights Reserved.

processed in 0.139 (s). 11 q(s)