• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
MVC - Controller Questions

#1
[eluser]jleequeen[/eluser]
Is there really any benefit to having non related functions in the same controller? I ask this because I'm trying to understand why it's a good thing to have a controller with 10 functions in it that don't necessarily have anything to do with either other. To me a controller just shouldn't contain anything more than it needs for that request. Let me give an example.

A user controller has:

user/login
user/logout
user/profile
user/save
user/delete
etc...

Now to me, it seems like you wouldn't want login code in the same file that shows a user profile. I realize you could have a auth controller that handles login/logout, but my point is, some people do just this because they design based on "objects" You could just as easily have a blog controller but have 20 different methods in that controller that does many different things. It just seems that on each request, you should have mostly code specific for that request, not a lot of other functionality stuck into the controller that does other things, but that code has to get loaded on every request. Just seems a little too much overhead to me.

I realize in the MVC way of doing things, it's easy to design starting with objects and those become your controllers. But designing this way to me seems to put too much overhead in a single controller. In the old page based approach I would have a login page which would be specific for the login request. No other "extra" code stuck in there.

Is designing controllers based upon objects just done mainly to "group" seemingly like actions together, even if they don't need to be used on each request? Seems a little inefficient to me. Also, what happens (if you design user interface first which is what I normally do) things don't fit nicely into the "objects make your controller" approach.

It seems like I should be using the page based approach design principles I've always used to develop the views (interface first) and then use a controller per page (view) approach that accomplishes my efficient code per request.

Does this make sense or am I missing the boat entirely and should adopt the stuff 30 methods in a controller even if they aren't needed on each request mentality?


Messages In This Thread
MVC - Controller Questions - by El Forum - 09-27-2008, 08:40 PM
MVC - Controller Questions - by El Forum - 09-27-2008, 09:11 PM
MVC - Controller Questions - by El Forum - 09-27-2008, 11:59 PM
MVC - Controller Questions - by El Forum - 10-03-2008, 04:22 PM
MVC - Controller Questions - by El Forum - 10-03-2008, 04:44 PM
MVC - Controller Questions - by El Forum - 10-04-2008, 01:47 PM
MVC - Controller Questions - by El Forum - 10-04-2008, 04:22 PM

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.