Fenix Voltres
Fenix Voltres

Reputation: 3448

Managing many windows in GUI architecture

I've got a question about an architecture af a complex GUI app.

I'm creating such app and have many, many windows which often interacts with each other, and I'm facing problem of having all needed references to other windows within them. What is the best approach to manage those windows?

First think I came up with was to create global singleton sharing all windows references (and encapsulate them in getters/setters) and each windows would have only reference to that, let's say 'window manager' - but generally I don't like that type of programming (I'm anti-global :P), I consider it's bad and unsafe.

Are there any paradigms/design patterns am I missing?

Appreciate any useful tips,

Maciek

Upvotes: 0

Views: 179

Answers (2)

Bryan Oakley
Bryan Oakley

Reputation: 386210

You need an application wide "controller". Think of it like a central DNS. It doesn't have to be a special "global singleton". Your application will already have one of those (the root object of your app). Just have it manage a list of windows.

Upvotes: 0

Martin
Martin

Reputation: 40365

Sounds complicated.

If you need to communicate between windows then I would suggest using events.

Form 1 raises an event and form 2 responds to it. Pass the needed details in the event args.

That stops any need to have references to each form in other forms.

Upvotes: 0

Related Questions