realbasic-nug
[Top] [All Lists]

Re: How to handle prefs with OO

To: REALbasic NUG <realbasic-nug at lists dot realsoftware dot com>
Subject: Re: How to handle prefs with OO
From: Thomas Reed <tareedlists at mac dot com>
Date: Thu, 31 Mar 2005 07:20:50 -0500
Delivered-to: realbasic-nug at lists dot realsoftware dot com
References: <30245 dot 1112266813 at www35 dot gmx dot net>
On Mar 31, 2005, at 6:00 AM, Beatrix Willius wrote:

How can I implement this better:

I'm partial to Apple's solution to this problem in the Core Foundation on Mac OS X. Basically, the OS will take care of preferences for you, and your application simply requests a preference associated with a particular key (ie, there's a dictionary involved under the surface). You don't even have to worry about reading and writing the file -- the OS does that for you, and there's a synchronize routine you call when you've made changes and want them written to disk. For Mac OS X, you can access the Core Foundation preferences via my Core Foundation wrapper classes (see the URL in my sig).

If you're doing cross-platform work, though, you can mimic this behavior with a class that reads from a file into a dictionary pretty easily. Somebody (Kevin Ballard, maybe?) has a class for turning XML into a dictionary and vice versa, though I forget what it's called and have never used it.

Beyond that, I wouldn't get complicated with it. You mentioned factories and whatnot -- too messy. Not needed. Remember, whatever is accessing a particular preference should know what to do with it better than your abstracted preferences class!

-Thomas

Personal web page: <http://homepage.mac.com/thomasareed/> My shareware: <http://www.bitjuggler.com/> Free REALbasic code: <http://www.bitjuggler.com/extra/>

There are 10 kinds of people in the world -- those who understand binary
numbers and those who don't.

_______________________________________________
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>

<Prev in Thread] Current Thread [Next in Thread>