Re: Model-View-Presenter (MVP) question



On 25 Nov 2005 01:01:58 -0800, "Kaspar" <kaspar.thommen@xxxxxxxxx>
wrote:

>AndyW,
>
>Thanks for your response. However, I still have the problem of handling
>"special" events inside the model. What if an Exception is thrown
>somewhere in my model, catched, and a Yes-No-Cancel dialog must be
>shown to the user before continuing? How can I do that without making
>the Model know about a Presenter/Controller/View?
>
>Kaspar

The key is in the controller.

There are two parts to it. The first part is taking input (kbd/mouse
etc) and tranlating into business events, which are pushed to the
model. The second part is in translating the responses back to the
view.

Think of the controller as being the glue between the two. But its
dumb in that it only knows how to do mechanical tasks.such as read
keyboard/display views and validate controls (basic validation)

(litle trick. There are only really half a dozen basic controls in a
GUI, the rest are composite, so you really only need to probably
write a dozen validators to ensure correct input (more complex
validation is done in the model). Reuse is king.

One way I have found to validate screen input is to use the momento
pattern (I will also refer to them as Mixins). Its basically a data
structure that you put an objects (screens) attributes in. You can
attach a validation event handler to it as a local method. This can
be done as RTTI as well if you want to make it generic.

A yes/no/cancel dialog is a view, it will have a controller (although
a very simple one - because there is simply one business event - the
choice to be made).

Likely that you will use this all over the place - it wont be just
tied to a single screen. So, your model will generate a 'choice'
business event, the controller should pick it up and display the
screen, then return the result to the model. (think as business
events as being patterns as well, it helps abstract them).

Dont relate the yes/no dialog to the parent screen from a human logic
point of view. Its only relationship is in the business process being
performed by the model.

Those other links posted in the other post are good reads. Its
important to look at as many different mvc models as possible - then
perhaps build a composite version for your own purpose.

.



Relevant Pages

  • Re: OOP - a question about database access
    ... >> using a tool that generates it and hand coding little or no SQL? ... > between objects and the controller, plus the mapping files, plus the HQL ... imagine I have a number of screens that display customer name ... I select a customer to edit and change the name. ...
    (comp.object)
  • Re: responsiblity about MVC
    ... if it was directly generated off of the data structure you were updating. ... You could make it the responsibility of the Controller to do validation. ...
    (comp.object)
  • Re: MVC - The right way
    ... follow the controller definition given here pretty well. ... > You have a very large application, with 100's of screens, and many ... Eg, a particular customer ... that could instantiate the customer report class. ...
    (comp.object)
  • Re: Please recommend an app/equipment
    ... We would like to be able to talk with each other through our Macs while also being able to draw on each others screens. ... You also have the option of giving both the controller and the "controlee" access to the mouse and keyboard at the same time or, alternatively, locking out the "controlee's" keyboard and mouse when the computer is being controlled. ... The former option permits an interactive session between users. ...
    (comp.sys.mac.apps)
  • Re: aspbeans
    ... populate, save, navigate through the columns by hand, and do all of ... it reduces ties between the controller and the ... i'm planning on putting in validation, ... the separate layers and everything else. ...
    (microsoft.public.dotnet.framework.aspnet)