Communication between controllers in MVC / MVP

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!

+5
source share
3 answers

I think I will answer my question. Hope I get this sweet, sweet generosity.

. , , , , . , , .

. ( , ). ( , ). .

:

  • , , . - , .

  • , , , . , , , .

  • , facebook, , , . facebook .

  • , , , , , .

. , , . , .

, . , .

, . , , - .

+1

, Quote Contacts, Contact. , , , . , n- .

+1

, , , , .

, Func < > , . : , , . , , ; , all .

When your dealer has completed its task, it just opens your portfolio (Func <>) and comes to your desk in the office , to see if anyone object To-Do in his office drawer posted.

Jon Skeet (also on StackOverflow) has an excellent resource here: http://csharpindepth.com/articles/chapter5/closures.aspx

+1
source

All Articles