471,337 Members | 879 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,337 software developers and data experts.

Class/Object basics..

I'd like to have an XML document that my app reads and writes to on a
regular basis. It will read the XML document on opening, write to it when
closing, and while running, it will do updates and add and delete nodes.

So...

I think I should create a 'Settings' class, with methods for reading,
writing, getting a value.. etc..

So, my question is: Where would I declare the object. Or should I say,
create it, so that I have access to it from anywhere in my main class? So
that at any point, I can say:

SettingsObject.Flush(); // Update the settings file with the latest changes
SettingsObject.ShutDown() // Do all the end-of-running things, and close the
XML file.
Jan 8 '06 #1
1 936
I would make it a Singleton. Look up the Singleton design pattern. Jon
Skeet has a page on this:

http://www.yoda.arachsys.com/csharp/singleton.html

Your "Settings" class could use composition: it could contain an XML
document as a private field, and then provide a "nice" interface to the
rest of the application that talks to the app in higher-level terms (so
that the app doesn't have to know that the settings are stored in XML,
and you could change the representation / location of the settings
later).

Jan 9 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Greg Phillips | last post: by
42 posts views Thread by Dan | last post: by
1 post views Thread by Matthias Kaeppler | last post: by
5 posts views Thread by Simon Harris | last post: by
4 posts views Thread by Brian | last post: by
7 posts views Thread by S. Lorétan | last post: by
9 posts views Thread by DBC User | last post: by
8 posts views Thread by oh.i.love.spam | last post: by
3 posts views Thread by Peskov Dmitry | last post: by
reply views Thread by rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.