tags:

views:

89

answers:

4

When using the MVC pattern, should I implement a seperate controller for each view?

A: 

I believe there is no 'the' MVC pattern. There are almost as many MVC patterns as there are users of a MVC architecture. That being said, in my opinion, the answer to your question is 'no'.

koen
A: 

I use to implement a controller for each module of my application, not for each view. A controller can call methods of other controller. I'm not sure if this is the better way to do it, but I think It's working well for me.

Jonathan
A: 

the idea is to separate/decoupling M, V and C, its not a problem if you want a single controller control multiple view, as long as the view and controller is decoupled

uray
+1  A: 

Create a new one if you need to. Don't if you don't.

Patterns are not about data structures, they're about organizational patterns among communicating components. If the same controller is appropriate for more than one view, great - especially if you can use it without modification.

If you have to change it, then you have a case for two separate controllers. If there is shared code between them, then consider moving it to another class - either a base class or (my personal preference) shared via aggregation.

The easiest way to think about MVC is a command-line program. The program is the Model. The Controller is STDIN. The View is STDOUT.

kyoryu