S
Simon Harvey
Hi everyone,
I have a class that I want to use to store application state information. I
was thinking that I would probably want to make all the information static
in that class because the application should only have one copy of
application information.
First Question:
Is this the right sort of scenario to use a static class? Or should I make
an object and use a Singleton pattern? Would there be an advantage to that?
My second question is how to initialise this static state class.
Normally I would just use the new operator and call the objects contructor,
passing in any appropriate data. However, given that I'm not instantiating
an object, I can't do that.
So I'm not sure how to initialise the class. The actual class is called
StateManager. What I need to be able to do is something like:
StateManager.static_constructor(state_data);
I'm not sure how to achieve that effect though.
Thanks everyone
Take care
Simon
I have a class that I want to use to store application state information. I
was thinking that I would probably want to make all the information static
in that class because the application should only have one copy of
application information.
First Question:
Is this the right sort of scenario to use a static class? Or should I make
an object and use a Singleton pattern? Would there be an advantage to that?
My second question is how to initialise this static state class.
Normally I would just use the new operator and call the objects contructor,
passing in any appropriate data. However, given that I'm not instantiating
an object, I can't do that.
So I'm not sure how to initialise the class. The actual class is called
StateManager. What I need to be able to do is something like:
StateManager.static_constructor(state_data);
I'm not sure how to achieve that effect though.
Thanks everyone
Take care
Simon