Re: Where to instantiate manager class in GUI?



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


.



Relevant Pages

  • Re: It it possible to redirect events?
    ... the Manager, and the Manager has many 'Items'. ... I'm going to assume that what you want is an event in the Manager class ... for clients of the Manager class (specifically, ... 4.Client should respond to ItHappened events. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: It it possible to redirect events?
    ... the Manager, and the Manager has many 'Items'. ... For one, the code you posted wouldn't compile (the Manager class constructor needs a "()" after the name of the constructor), and even if it did, it wouldn't do anything because the instance of Item isn't initialized, nor is it referenced anywhere other than in a local variable. ... But assuming you really want to get rid of the forwarding, you could implement your event explicitly in the Manager class, subscribing to the underlying Item event. ... Note that this actually changes the reference relationships between your instances. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: How to do unit test on an atom unit which tied with a large unit?
    ... a "manager test stub" and fake the functionality in the test for ... Create a fake ... manager class to work with and control the actual atom class that you ... Since you aren't testing the manager class itself, ...
    (borland.public.delphi.non-technical)
  • Re: no indexof-function for collection object available.
    ... What I ended up doing is writing 2 classes. ... One was a manager class ... that handled all the add/edit/delete/sort routines and implemented ... object to my manager class I was able to use InnerList.Items.IndexOf ...
    (microsoft.public.dotnet.languages.vb)
  • Re: How do I approach this?
    ... Without reading back these threads, let me clarify a couple of ... comment' that it could really do to be something like an sql database. ... point my manager asked me to liaise with the IT development manager, ... This week I demo'd the app. ...
    (microsoft.public.vstudio.development)