Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm working in a REST JavaScript client, and I'm trying to follow the MVC pattern, but a very basic question came to my mind: who should make the http request and load the data into the model?

My intuition tells me that the controller should do it, but in lots of examples (the ember.js documentation, by example) it's done by the model, with a find() method. But other frameworks, like Django, do it in the controller.

What do you think it's the better way to do this?

share|improve this question
up vote 2 down vote accepted

A model shouldn't have to worry or even know about persistence. So a model loading itself is out for me.

In MVC: the controller should be the one in control of having the model loaded. Whether it does it itself, or delegates that to a store or repository or whatever other data-persistence service name you can think of is immaterial.

share|improve this answer

Both can work. I prefer neither. The model loading could be done by some repository or 'store' service.

ExtJs uses Stores which have the knowledge about obtaining model data, provide client side caching etc. I appreciate this design, good separation of concerns.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.