Skip to content

Instantly share code, notes, and snippets.

@sushiljainam
Created October 10, 2016 16:05
Show Gist options
  • Save sushiljainam/7e9d75ffcb399b621aa0d3f571e0cfcc to your computer and use it in GitHub Desktop.
Save sushiljainam/7e9d75ffcb399b621aa0d3f571e0cfcc to your computer and use it in GitHub Desktop.
about MVC architecture
It's beautiful in its simplicity, as Terence Parr notes:
For the "MVC" of a web app, I make a direct analogy with the Smalltalk notion of MVC. The model is any of the logic or the database or any of the data itself. The view is simply how you lay the data out, how it is displayed. If you want a subset of some data, for example, my opinion is that is a responsibility of the model. The model knows how to make a subset. You should not be asking your graphics designer to filter a list according to age or some other criteria.
The controller in a web app is a bit more complicated, because it has two parts. The first part is the web server (such as a servlet container) that maps incoming HTTP URL requests to a particular handler for that request. The second part is those handlers themselves, which are in fact often called "controllers." So the C in a web app MVC includes both the web server "overlord" that routes requests to handlers and the logic of those handlers themselves, which pull the data from the database and push it into the template. This controller also receives HTTP POST requests and processes these, sometimes updating the database.
I look at a website as nothing but a graph with edges with POSTs and GETs that routes pages.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment