T
titan.nyquist
I need to initialize data to be stored in a static class (for all my
code to see), but I'm lost on how to do so.
If I use the class constructor, what if it fails? I am reading it
information from files that (could potentially) not exist. If it
throws an exception, it could be thrown wherever the first access to
the class is, which is undetermined. This seems like a bad idea.
Furthurmore, the data initialization code should be run at the
beginning of the program, to ensure if anything fails, it fails right
away.
How else could I do it? Any ideas?
I could create a method that the static class (the one that holds the
data) that I call when *I* choose to call it, right away at the
beginning of the program. That method could set a "dataInitialized"
boolean to be true, which ever access to the data could check (via
properties).
What do you think?
Titan
code to see), but I'm lost on how to do so.
If I use the class constructor, what if it fails? I am reading it
information from files that (could potentially) not exist. If it
throws an exception, it could be thrown wherever the first access to
the class is, which is undetermined. This seems like a bad idea.
Furthurmore, the data initialization code should be run at the
beginning of the program, to ensure if anything fails, it fails right
away.
How else could I do it? Any ideas?
I could create a method that the static class (the one that holds the
data) that I call when *I* choose to call it, right away at the
beginning of the program. That method could set a "dataInitialized"
boolean to be true, which ever access to the data could check (via
properties).
What do you think?
Titan