Re: Model-View-Presenter (MVP) question
- From: AndyW <foo_@xxxxxxxxxxxxxxxx>
- Date: Sat, 26 Nov 2005 14:34:55 +1200
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.
.
- References:
- Model-View-Presenter (MVP) question
- From: kaspar . thommen
- Re: Model-View-Presenter (MVP) question
- From: AndyW
- Re: Model-View-Presenter (MVP) question
- From: Kaspar
- Model-View-Presenter (MVP) question
- Prev by Date: Re: Decouple SQL queries from class in OOP design
- Next by Date: Re: Decouple SQL queries from class in OOP design
- Previous by thread: Re: Model-View-Presenter (MVP) question
- Next by thread: Re: Model-View-Presenter (MVP) question
- Index(es):
Relevant Pages
|