[Bluej-discuss] style question: best way to handle global data
Chuck Iverson
iversonc at pacbell.net
Thu Dec 6 23:26:08 GMT 2007
How about putting your constant config data in an interface and
implementing it where you need it?
On Dec 6, 2007, at 12:51 PM, Aryeh M. Friedman wrote:
> 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
>
> _______________________________________________
> mailing list bluej-discuss at bluej.org
> To unsubscribe or change your preferences, go to
> http://lists.bluej.org/mailman/listinfo/bluej-discuss
More information about the bluej-discuss
mailing list