Global object problem
From: *** (droida38_at_yahoo.com)
Date: 11/16/04
- Next message: Maximiliano Neustadt: "GUI+Business logic, which glue that sticks them together?"
- Previous message: Stede Troisi: "Re: agile/xp question (formal analysis)"
- Next in thread: H. S. Lahman: "Re: Global object problem"
- Reply: H. S. Lahman: "Re: Global object problem"
- Reply: Kurt: "Re: Global object problem"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 16 Nov 2004 04:49:59 -0800
I have inherited this system that started out as a prototype and ended
up beeing a running system :-/
It has some design flaws that I'd like to refactor the best way,
that's why I need you help.
The program is a GUI client running on the PC. It can open several
connections to a server and thus has several windows (one for each
session).
When a new window is created an object (CenterData) containing a
Hashtable is also created. This object is then passed all over the
system, giving access to central services and variables.
CentalData contains keys (services), values (serviceproviders).
i.e. Hashtable.put("colorTable", new ColorTable()) gives access to the
current colortable (The colorTable can be different for each window).
The CentalData object is accessed from all over the program, both when
setting values and reading them. This is real handy as most classes
receives a CentalData in their constructor and thereby can use the
central functions (ex. tooltipManager, selectionManager, fontManager,
commandHandler, configurator, logManager) and even install new
services. It is also possible to install a listener so that an object
will be notified when a certain service changes ex. the Window is
notified when the colorTable is replaced.
Unnecessary to mention this makes it quite difficult to know which
objects are using which services when. But what would be a good way to
fix this?
Obviously I could identify which classes uses which services, and only
deliver references to these in their constructor. But many of the
objects that uses the CentralData object actually use quite a few
services, so I expect some quite large constructor parameter methods
:-/
I would be tempting to use Singletons as they could be accessed from
all over, but I don't think that would add more clearness, as well as
the fact that the individual windows should receive different objects.
- Next message: Maximiliano Neustadt: "GUI+Business logic, which glue that sticks them together?"
- Previous message: Stede Troisi: "Re: agile/xp question (formal analysis)"
- Next in thread: H. S. Lahman: "Re: Global object problem"
- Reply: H. S. Lahman: "Re: Global object problem"
- Reply: Kurt: "Re: Global object problem"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]