realbasic-nug
[Top] [All Lists]

How to handle prefs with OO

To: realbasic-nug at lists dot realsoftware dot com
Subject: How to handle prefs with OO
From: "Beatrix Willius" <bwillius at gmx dot de>
Date: Thu, 31 Mar 2005 13:00:13 +0200 (MEST)
Delivered-to: realbasic-nug at lists dot realsoftware dot com
I am in the process of refactoring one of my projects. One central issue is
the handling of the preferences.

Current state:
- Preferences are loaded from xml into a number of global properties.
- Preferences window is opened and the state of objects is set according to
globals.
- In code I have lots of if statements for deciding, which path to follow.
- Sometimes the globals have to be changed outside the prefs window, for
instance when a file cannot be found anymore.
Benefits: Easy to implement.
Drawbacks: All code depends on the globals, new features have to be
introduced in multiple places.

How can I implement this better:

Idea 1: Load the prefs not into a large number of properties, but into a
dictionary.
Benefits: Only one object to carry around. No single properties to create.
Drawbacks: Code depends on dictionary instead of properties. Basic handling
of prefs stays the same.

Idea 2: Load the prefs into a dictionary. Make accessor methods for the
dictionary values. Use factories instead of if statements.
Benefits: No single properties to create. Safer access to dictionary. With
the factory the long methods are outsourced to multiple methods in a class.
Drawbacks: Code still directly coupled to dictionary.

Idea 3: Load the prefs into a dictionary. Use factories instead of if
statements. Let the factories be an observer to a class containing the
dictionary.
Benefits: No single properties to create. With the factory the long methods
are outsourced to multiple methods in a class. Dictionary and factories are
loosely coupled.
Drawbacks: Does this make sense? Is this feasible/implementable? 

Any ideas on this?

Regards

Trixi Willius

-- 
Sparen beginnt mit GMX DSL: http://www.gmx.net/de/go/dsl
_______________________________________________
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>