Yes, you have to take care, for a very pragmatic reason!
The classes in which you want to use your settings should absolutely not depend on how these settings are saved.
Imagine that in the future you want to support multiple themes for your application. As a result, you will have not one, but many opportunities for the size of your panel, for example:
AppSettings.Views.ThemeA.Windows.Dashboard.Size; AppSettings.Views.ThemeB.Windows.Dashboard.Size;
Only one thing is still required in your user interface class, the value for its windowSize variable, it does not need to know which theme is currently being used.
It’s true, wherever you have the XML interface, you don’t want it to depend on the schema everywhere in your code, but only in one central place.
For example, you can put the settings in Map for internal use, for example:
public class SettingsReader { public static final String VIEW_WINDOW_DASHBOARD_SIZE = "Views.Windows.Dashboard.Size"; private Map settings = new Hashmap(); public SettingsReader(AppSettings appSettings) { settings.put(VIEW_WINDOW_DASHBOARD_SIZE, appSettings.Views.Windows.Dashboard.Size); } public String getSettingValue(String key) { return settings.get(key); } }
Then you have only one place to refactor to support the topic, for example:
public class SettingsReader { public static final String VIEW_WINDOW_DASHBOARD_SIZE = "Views.Windows.Dashboard.Size"; private Map settings = new Hashmap(); public SettingsReader(AppSettings appSettings, String theme) { settings.put(VIEW_WINDOW_DASHBOARD_SIZE, appSettings.Views + theme + Windows.Dashboard.Size); } public String getSettingValue(String key) { return settings.get(key); } }
The last note, simply because my combination of pseudo-codes and java code can be confusing for people, especially appSettings.Views + theme + Windows.Dashboard.Size : when working with the XML interface, xPath is usually very useful even when working with objects thanks to the good JXPath library (for java I do not know other languages).