What is a good method for loosely coupled communication between controllers in MVC / MVP?
For example, in a quote, the user must create and add a new contact or add an existing one.
They decided to create a new contact. Upon completion, the contact is added to the quote, and the user interface returns the user to this quote. If they click on cancel, they return to the quote.
I want to reuse the contact elsewhere, so it should not know anything about Quote. For example, if I create a contact from the contact list, he should return there when done.
Here are some options that I thought of:
ContactsController calls ApplicationController.getNextStep (this), and ApplicationController points to the next step on behalf of ContactController
The ContactsController raises an "actioncomplete" event or the like, and the ApplicationController listens for this event and raises the right next step.
QuoteController goes into "baton" to ContactController with the next step, which calls ContactController
The ContactsController raises an "actioncomplete" event or the like, and the QuotesController listens for this event and raises the right next step.
Do you have any experience with this? Other ideas? What will cause the least amount of headaches in a large application?
Thank!
source
share