Configuration File and Design

J

Jason Cavett

I am somewhat stumped on how to implement a component into my
application. Basically, I already have a ConfigurationFile object
that I read in from a file when my application starts and write out to
when my application closes. I can also update that ConfigurationFile
object from an options dialog.

The issue I'm having is that I'm not sure (from a design perspective)
the best way to update the various components that are affected when
the ConfigurationFile changes. I have three problems/questions:

1. I want the system to be updated (relatively) immediately after the
changes are applied.
2. I considered using the Observable pattern to do this, but it seems
rather clunky because there are quite a few components in the system
that would need to observe the ConfigurationFile. I'm not even sure I
like the ConfigurationFile being an Observable object in the first
place. Do you think this is a good idea?
3. Would it be beneficial to make the ConfigurationFile a Singleton in
this sort of situation?

This is the first time I've ever run across "global options" like
this, so I hope my questions make sense.


Thanks
 
E

Ed Kirwan

Jason said:
I am somewhat stumped on how to implement a component into my
application. Basically, I already have a ConfigurationFile object
that I read in from a file when my application starts and write out to
when my application closes. I can also update that ConfigurationFile
object from an options dialog.

The issue I'm having is that I'm not sure (from a design perspective)
the best way to update the various components that are affected when
the ConfigurationFile changes. I have three problems/questions:

1. I want the system to be updated (relatively) immediately after the
changes are applied.
2. I considered using the Observable pattern to do this, but it seems
rather clunky because there are quite a few components in the system
that would need to observe the ConfigurationFile. I'm not even sure I
like the ConfigurationFile being an Observable object in the first
place. Do you think this is a good idea?
3. Would it be beneficial to make the ConfigurationFile a Singleton in
this sort of situation?

This is the first time I've ever run across "global options" like
this, so I hope my questions make sense.


Thanks

FWIW, I tend to use the, "Global options," you mention and have each
behaviour read these options without caching, so that the behaviour will
change once the option values change.

For example, see:
http://www.edmundkirwan.com/servlet/fractal/cs1/frac-cs110.html

Of course, if changing an option could affect that way something static
has already been done (e.g., changing an option could change the
background photo in an app, and that background is only drawn when the
app starts) then I'd have thought the observer pattern would be the way
to go.

..ed
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,521
Members
44,995
Latest member
PinupduzSap

Latest Threads

Top