Re: Where to instantiate manager class in GUI?
- From: "David White" <no@xxxxxxxxxxxxxx>
- Date: Thu, 13 Oct 2005 10:05:29 +1000
James wrote:
> I have a manager class which controls a couple of proxy classes and a
> few persistent data classes and I am trying to intergrate these
> classes into an MFC application using Visual C++.
>
> Which GUI class should I use to instantiate the manager class? In a
> main method in the application class? Or in the constructor of
> primary dialog box (it will always be controlled by action events
> from this dialog box)?
>
> Any advice appreciated (I'm an MFC beginner).
I'm sure you can make it work both ways, but which way is a "better" design
depends on many factors, including your subjective judgement as to what
makes a good design. If it makes sense for the manager object and proxies to
exist without the dialog box (i.e., if the dialog box exists to serve the
manager and not the other way around), then I would probably have the
manager in the app and pass it to the dialog box (so I wouldn't need a
method in the app either).
If you know of the document/view architecture in MFC, the document is
effectively the program's data and the views are how the user views and
interacts with the data. They are deliberately separate because there are
any number of ways the user might view and edit the same data. To me, if
I've understood correctly, your manager is your program's data and is the
core of the application, and the dialog is like a view on it, and only one
of many possible views on the same data (even if it's the only one you ever
use).
To summarize, putting the manager in the dialog box locks the manager and a
particular UI object together, but putting the manager in the app works just
as well but also gives the flexibility to use anything other than the dialog
box (including non-UI objects) to use the manager in future, should you wish
it.
DW
.
- References:
- Where to instantiate manager class in GUI?
- From: James
- Where to instantiate manager class in GUI?
- Prev by Date: Problem setting font for dialog caption
- Next by Date: Re: How to a new usb device drive letter as soon as it is inserted?
- Previous by thread: Where to instantiate manager class in GUI?
- Next by thread: Problem setting font for dialog caption
- Index(es):
Relevant Pages
|