On 8/2/2006 2:39 PM, Kevin Windham wrote:
I have some code that reads and writes my preferences to an XML file. The writing code is pretty straight forward. It just travels down the chain of classes that make up the data model for my prefs and asks each class instance to add it's properties to the xml document.
That seems sensible enough.
The reading code however is somewhat inelegant it seems. I am using an XMLReader to parse the prefs file and it gives events for the xml entities as it reads them in. So in order to let each class instance handle it's own stuff, I have the XMLReader instance pass those events to methods in the various prefs classes that mirror the event in the XMLReader. Then each pref class has to determine if the current xml entity belongs to it, or to a class it contains.
[snip rest] I see two potential problems here. 1. I can't be sure without seeing the code, but it sounds like your consumer classes have some knowledge of the fact that the prefs are stored in an XML file (e.g. because they use XMLReader events). This isn't good. Ideally, you should be able to switch among XML, binary, Ini, Win32 registry and Unix config storage mechanisms without having to change anything except your prefs class. 2. You're pushing the values to your consumer classes rather than allowing them to pull from the prefs class. The latter is generally simpler to implement and maintain (though there are instances where this isn't true). To accomplish this in the current context, you might need to have your prefs class parse the entire file and then store the contents for later querying by your consumer classes. -- Charles Calvert Celtic Wolf, Inc. (703) 580-0210 [EMAIL PROTECTED] http://www.celticwolf.com/ _______________________________________________ Unsubscribe or switch delivery mode: <http://www.realsoftware.com/support/listmanager/> Search the archives of this list here: <http://support.realsoftware.com/listarchives/lists.html>
