lundi 16 mai 2016

MVC pattern best way to connect View to multiple Controllers?

I'm recently doing a purchase order program using the MVC pattern in C# (not ASP.NET web app, just a desktop program). Now the problem is that in the UI there are lots of buttons that will link to another section, let's say from the order page I can click and go to the inventory page. Each section of course have their own set of MVC.

How can I connect the button to other controller while maintaining abstraction? That is each view does not have to understand how the other controller works, or what parameters it requires to work.

There are a couple of design possibilities that comes to mind but I have no idea which one is better / simpler:

  • The dirty way: just put the references to all the required controllers in one view, but this way reduce abstraction.

  • Shared view space: each button is a different view that has their own controller, but then I need to have view manager of some sort.

  • Routing: pretty much like ASP. NET RedirectToAction, make a custom router that use common type (like string) to determine which controller and which action to perform

  • Custom button for each action: for each controller and each action I make a button class just for it. Then I need a way for the view to supply the required parameters to each button.

Any suggestion on what should I do?

Aucun commentaire:

Enregistrer un commentaire