What's the best way to acess the model from the view in a MFC approach?

Discussion in 'Java' started by ***C.Steamer***, Oct 26, 2004.

  1. Say I got a class that extends JPanel and I want to update the model class
    from within the JPanel class, what is the best way to do that. I already
    implement an Observer pattern to update the GUI from the model but how do we
    go the other way. Basically I will be clicking on an area of the panel and
    based on which object I select I want to change something in the model
    class. Should I just pass in all the classes that the GUI will need? I don't
    like this method cuz then you have to have the classes already instantiated
    before you build the gui and it makes for intermixed code. Or should I make
    the model class into Singleton so I can statically access the class from
    anywhere? Thanks for your help?
    ***C.Steamer***, Oct 26, 2004
    #1
    1. Advertising

  2. "***C.Steamer***" <> wrote in message
    news:2fmfd.1648$VA5.852@clgrps13...
    > Say I got a class that extends JPanel and I want to update the model class
    > from within the JPanel class, what is the best way to do that. I already
    > implement an Observer pattern to update the GUI from the model but how do
    > we go the other way. Basically I will be clicking on an area of the panel
    > and based on which object I select I want to change something in the model
    > class. Should I just pass in all the classes that the GUI will need? I
    > don't like this method cuz then you have to have the classes already
    > instantiated before you build the gui and it makes for intermixed code. Or
    > should I make the model class into Singleton so I can statically access
    > the class from anywhere? Thanks for your help?
    >

    Ops, I mean the MVC approach not the MFC. Sorry
    ------Dacleaver------, Oct 26, 2004
    #2
    1. Advertising

  3. Re: What's the best way to acess the model from the view in a MFCapproach?

    ***C.Steamer*** wrote:
    > Say I got a class that extends JPanel and I want to update the model class
    > from within the JPanel class, what is the best way to do that.


    Do you really expect to get answers after

    Message-ID: <Cgzed.40930$z96.9460@clgrps12>

    ?

    Oh, and changing you name doesn't help. But when you do, consider
    removing the "I-am-cleaver". It also doesn't help to post to the wrong
    group (well after the above referenced post it also won't help you to
    post to the right one) and it doesn't help using slang like "cuz". Trust
    us, you don't look cool.

    /Thomas
    Thomas Weidenfeller, Oct 26, 2004
    #3
  4. ***C.Steamer***

    Jacob Guest

    Re: What's the best way to acess the model from the view in a MFCapproach?

    ***C.Steamer*** wrote:

    > Say I got a class that extends JPanel and I want to update the model class
    > from within the JPanel class, what is the best way to do that. I already
    > implement an Observer pattern to update the GUI from the model but how do we
    > go the other way.


    Basically you do by direct access. The GUI modules should
    have references to the model counterparts. Note also that
    any events that should be produced should be invoked from
    the GUI making the changes, and *not* from the model itself.

    > Should I just pass in all the classes that the GUI will need? I don't
    > like this method cuz then you have to have the classes already instantiated
    > before you build the gui and it makes for intermixed code.


    In principle the GUI should have references to the model
    classes, but if performance is at stake you should consider
    replacing the actual model objects with empty proxy objects.
    These will have a name, a location in the overall model
    hierarchy and an ability to *load* themselves (possibly
    through some accessor interface). From the user point of
    view it will appear as the real object. When the actual
    data is needed they are instantiated lazily.
    Jacob, Oct 26, 2004
    #4
  5. ***C.Steamer***

    Alex Hunsley Guest

    Re: What's the best way to acess the model from the view in a MFCapproach?

    ***C.Steamer*** wrote:
    > Say I got a class that extends JPanel and I want to update the model class
    > from within the JPanel class, what is the best way to do that. I already
    > implement an Observer pattern to update the GUI from the model but how do we
    > go the other way. Basically I will be clicking on an area of the panel and
    > based on which object I select I want to change something in the model
    > class. Should I just pass in all the classes that the GUI will need? I don't
    > like this method cuz then you have to have the classes already instantiated
    > before you build the gui and it makes for intermixed code. Or should I make
    > the model class into Singleton so I can statically access the class from
    > anywhere? Thanks for your help?


    What makes you think you're going to get any help here after this
    disgraceful performance? http://makeashorterlink.com/?J1B114F99

    (which was in response to helpful information from myself.)

    Now, go away.
    Alex Hunsley, Oct 26, 2004
    #5
  6. ***C.Steamer***

    Alex Hunsley Guest

    Re: What's the best way to acess the model from the view in a MFCapproach?

    Jacob wrote:
    > ***C.Steamer*** wrote:
    >
    >> Say I got a class that extends JPanel and I want to update the model
    >> class from within the JPanel class, what is the best way to do that.
    >> I already implement an Observer pattern to update the GUI from the
    >> model but how do we go the other way.

    >
    >
    > Basically you do by direct access. The GUI modules should
    > have references to the model counterparts. Note also that
    > any events that should be produced should be invoked from
    > the GUI making the changes, and *not* from the model itself.


    [snip]
    Jacob - I'd wouldn't answer this buffoon if I were you. He isn't very
    grateful for help: http://makeashorterlink.com/?J1B114F99
    Alex Hunsley, Oct 26, 2004
    #6
  7. ***C.Steamer***

    jacob Guest

    Re: What's the best way to acess the model from the view in a MFCapproach?

    Alex Hunsley wrote:

    > Jacob - I'd wouldn't answer this buffoon if I were you. He isn't very
    > grateful for help: http://makeashorterlink.com/?J1B114F99


    I judge the content only.

    The issue is an important one, and as this is a _forum_
    the reply is for everyone.
    jacob, Oct 28, 2004
    #7
  8. ***C.Steamer***

    Alex Hunsley Guest

    Re: What's the best way to acess the model from the view in a MFCapproach?

    jacob wrote:
    > Alex Hunsley wrote:
    >
    >> Jacob - I'd wouldn't answer this buffoon if I were you. He isn't very
    >> grateful for help: http://makeashorterlink.com/?J1B114F99

    >
    >
    > I judge the content only.


    How do you judge this content then:

    (OP wrote:)
    > Yeah thanks for nothing dude, If you don't have anything useful to add
    > don't say anything.


    Or do you think that because this comment doesn't involve java, it
    doesn't matter at all?


    > The issue is an important one, and as this is a _forum_
    > the reply is for everyone.


    Yes, and everyone in the "forum" suffers if you send the message that
    immature, anti-social and unreasonable behaviour is OK. If the original
    poster with the ID10T flag set sees that he can get treated with respect
    when he is not showing it for others, then he has no reason to change
    his ways, and we retain another deadweight.
    Alex Hunsley, Oct 28, 2004
    #8
  9. ***C.Steamer***

    jacob Guest

    Re: What's the best way to acess the model from the view in a MFCapproach?

    Alex Hunsley wrote:

    > How do you judge this content then:
    >
    > (OP wrote:)
    > > Yeah thanks for nothing dude, If you don't have anything useful to add
    > > don't say anything.

    >
    > Or do you think that because this comment doesn't involve java, it
    > doesn't matter at all?


    This was not from the post to which I was replying;
    not even from the same thread. I don't investigate
    the posting history to individuals before replying.
    And it wouldn't matter anyway.

    > If the original
    > poster with the ID10T flag set sees that he can get treated with respect
    > when he is not showing it for others, then he has no reason to change
    > his ways, and we retain another deadweight.


    I try to treat everyone with respect. If all did,
    the quality of the forum could be kept at level.
    jacob, Oct 28, 2004
    #9
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. S.M. Altaf [MVP]

    Re: best way to approach this problem

    S.M. Altaf [MVP], Nov 11, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    492
    Stimp
    Nov 11, 2005
  2. Scott McPhillips
    Replies:
    0
    Views:
    377
    Scott McPhillips
    Jul 5, 2003
  3. ringos75
    Replies:
    0
    Views:
    951
    ringos75
    Apr 14, 2005
  4. yopwojtek

    Derive from MFC DLL to MFC APP

    yopwojtek, Aug 6, 2005, in forum: C++
    Replies:
    1
    Views:
    386
    Alf P. Steinbach
    Aug 6, 2005
  5. Parthiv Joshi
    Replies:
    1
    Views:
    656
    Samuel L Matzen
    Jul 6, 2004
Loading...

Share This Page