473,386 Members | 1,738 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 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 971
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Greg Phillips | last post by:
Hello everyone, I have read the section on templates in The C++ Programming Language 3rd edition 3 times over the last 4 days. Still I am stumped. I'll explain a bit about what I am doing...
42
by: Dan | last post by:
Hello, I have trouble with class calling. I am calling getvolume() with succes in the function CreateCircle but it do not want to call it in ShowCircle() function. I am staying in the same...
1
by: Matthias Kaeppler | last post by:
Sorry if this has been discussed before (I'm almost certain it has), but I didn't know what to google for. My problem is, I have a class, a gtkmm widget, and I want it to serve as a base class...
5
by: Simon Harris | last post by:
Hi All, Being a classic ASP programmer, I'm trying to get to grips with OOP, specifically using classes. I have setup my class with various properties, so far so good. What I dont quite get...
10
by: Chet Cromer | last post by:
I am creating a set of base classes and sub classes to use throughout a program I'm developing. The base class represents a generic "lookup table" from my database that contains lists of things...
4
by: Brian | last post by:
Hello.. After many books and self study, I think I am finally starting to grasp the basics of classes. However, I can't quite grasp how to use them after I design them. For example, I want to...
7
by: S. Lorétan | last post by:
Hi guys, Sorry for this stupid question, but I don't know why it isn't working. Here is my (example) code: namespace Test { class A { public string Label1; }
9
by: DBC User | last post by:
I am trying to find the difference between set and class. Could some one help me? I can understand that a class is like a set. Each subset could be a inherited class and members are instances. What...
8
by: oh.i.love.spam | last post by:
I've been a procedural PHPer for a while now and I don't know why it has taken me so long to start the jump from procedural to OOP. I have a function that I would use for doing length...
3
by: Peskov Dmitry | last post by:
Hi, What is the memory layout of an object, and the derived object. For example : class A { private: int prv_data; protected: int pro_data;
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

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.