Hi there, my first question here, so go easy if I've not got the subject/detail ratio quite right ;)
Ok.
So I'm using parsley 2 in flex because I'm very much liking it's messaging architecture for decoupling the view from the model and controller via it's messaging dispatcher and presentation models (read view mediator's).
what I'm wondering about and have been experimenting with is to dispatch messages from the controller that dispatch just enough information for the pm(mediator) to display the info in the view. All manipualtions of the information go back to the controller(via messages), which then dutifully updates the model.
Now, I'm not completely sold on it, as typically, I've seen lots of colleauges injecting the model into the mediator.. I can see pro's and cons,
the cons for me are mainly: view's can become coupled to the model, model can be manipulated without the controller's knowledge.
I guess this question could get very deep (we could start discussing how much logic a domain should have, who should update its' state etc), but I dont want to go down that.. just want to keep it simple.
So imagine this situation:
- Controller has a domain,
- Contorller accesses remote service, updates domain,
- Domain does some updates to its state and the controller then dispatches MVC messages to say that the domain is updated,
- The bootstrap initialization is now complete a View component is then added to the stage, and a mediator (pm) is now listenitng for mvc messages,
- View is manipulated in some way by the user, and this gesture will somehow change the domain (e.g. cicks 'update record' or similar),
- View dispatches mvc message to controller ('update record message'),
- Controller updates domain,
- Controller dispatches mvc message to say domain is changed in someway,
- Mediator gets message from controller and updates view.
I must say, I'm loving parsley's messaging and finding it a joy to work with on many levels,but what do you guys propose is a good way to resolve the race condition/time condition in step 3-5.
In these steps the first MVC message from the controller does not exist, and the view is created afterwards meaning that it does not get the initial state from the controller. Is there a way of getting/setting the initial state without getting too silly or without coupling the domain to the view?
The best I got so far is that views would get their state by getting the pm (mediator) to dispatch a message "giveMeState" which has a responder, and implement IResponder or somethign similar)..
Be very interested in your opinions..