[Bluej-discuss] style question: best way to handle global data
Aryeh M. Friedman
aryeh.friedman at gmail.com
Thu Dec 6 20:51:46 GMT 2007
Let's say I have a global piece of data (like system wide configs) and
need to make it aviable in a number of unpredictable situations (i.e.
the caller does not necessarly know that global data will be used)....
for example if I am writing a replacement for JUnit and have a setting
for say the type of test and an other for say the reporting format to
use for results... what is the best way to handle this... I can think
two solutions use a Singleton (i.e. a class that has a static instance
of itself and uses that static instance for all method calls) and the
other is to pass the global data as a param... the con of the 1st is it
violates the spirit of the no global data precept of OO and the draw
back of the second is the caller needs to be (unnecessarily) aware of
the fact that a called method will need global data.
--
Aryeh M. Friedman
FloSoft Systems
Developer, not business, friendly
http://www.flosoft-systems.com
More information about the bluej-discuss
mailing list