Reputation: 1093
So its a fairly noobish question. Im still coding a web spider and have lots of questions but the first one I want to ask is how do you decided whether a method should belong to a controller or a model.
I don't want to bring my application into this as there are many specific "does this code belong in controller or model" questions whereas I'm hoping this question will just serve as a general guideline.
Upvotes: 0
Views: 150
Reputation: 35298
I've worked in many environments, in many languages, ranging from entirely procedural, to object-oriented but not MVC, to MVC with fat controllers and MVC with skinny controllers. I can only speak of my own opinions, but these are things I've learned over the years and opinions I've gained through experience and having to deal with the maintenance consequences of some of the early code I wrote (we all have a past!).
I also know that many people will disagree with what I write here, as that is the nature of how we work ;)
I'm drifting off-topic here, but in short, most of your logic should probably finish up in your models. Your models, well, model your application in terms of data and how that data changes. It's therefore natural that this is where a lot of logic is placed. Your controllers only serve to transport information between the models and your end user (which just so happens, to be via the view).
Quite a long-winded way to say "I agree with John", eh? ;)
Upvotes: 2
Reputation: 37507
I always go with Skinny Controller, Fat Models as far as I can - so the answer to your question is usually the model.
Upvotes: 5