views:

94

answers:

2

I have a dialog box with two disctinct parts. Each part uses a model view design.
But when a model is updated, the second one has to be updated too. I’m wondering if it exists any best pratice or design pattern for communicating (update notification) between two models.
That's not realy possible to have two views and only one model.

Thanks for your time

+1  A: 

You could use the Mediator design pattern.

Mark Seemann
A: 

A common solution is to have the second model listen to the first model and update itself when the first model fires a change event.

If each model can cause an update of the other, the same pattern will work, but you need to put something in place to prevent circular updates -- e.g. a valueIsAdjusting flag that's set by the event-firing method and checked by the event-listening method.

David Moles