I started coding a significantly sophisticated web application, and it got pretty messy. Therefore, I decided that I would try to organize it better. MVC seemed appropriate. I have never used MVC and studied it before. I am trying to consolidate a better perception of this (and my questions obviously reflect what I think I have learned so far). My questions are a bit JavaScript oriented:
Which object should execute AJAX requests? Controller or model? (seperation - should the Model just store / manipulate the data, should it not care / know where the data came from, or should it be selected?)
If the function of calling the model calls the functions that provide them with data as arguments, or should the request for the request (link) of the model in itself? (principles of separation in mind: "The view should not care / know where it gets the data from" - is that right?)
In general, should one “know” about the existence of the Model and vice versa? Is the only controller sticking them together or just the wrong one? (I really doubt the statement is generally true)
It is a good possibility that I want to transfer this to a desktop / mobile application, so I would like to separate the components in such a way that it would allow me to complete this task, replacing the current data source, HTTP requests, with access to the database and replacing the view.
Perhaps any approach I requested is still a "valid" MVC, and it is up to me. I understand that nothing has been done in stone, I'm just trying to have (better) a general idea in my head.
ah123 source share