Server-side HTML rendering:
- Fastest browser rendering
- Page caching is possible as a quick-and-dirty performance boost
- For "standard" apps, many UI features are pre-built
- Sometimes considered more stable because components are usually subject to compile-time validation
- Leans on backend expertise
- Sometimes faster to develop*
*When UI requirements fit the framework well.
Client-side HTML rendering:
- Lower bandwidth usage
- Slower initial page render. May not even be noticeable in modern desktop browsers. If you need to support IE6-7, or many mobile browsers (mobile webkit is not bad) you may encounter bottlenecks.
- Building API-first means the client can just as easily be an proprietary app, thin client, another web service, etc.
- Leans on JS expertise
- Sometimes faster to develop**
**When the UI is largely custom, with more interesting interactions. Also, I find coding in the browser with interpreted code noticeably speedier than waiting for compiles and server restarts.
You might also consider a hybrid model with a light backend implementation using a front-end/back-end templating system like mustache.
The user interacts with the View, but the View must communicate the actions to the Controller. The Controller may update the Model, but it isn't required with every/any change.
The description I am providing is based on my personal experience with the .NET implementation of MVC. Your implementation can be different.
The Controller is where actions are processed, basically a business layer. A simple controller will do nothing more than get the data from the Model to feed to the View. A complicated Controller will perform all sorts of actions, up to security management, authentication, authorization, registration, and possibly many other things.
The View should only be responsible for displaying the information in a fashion that the user can understand. There can be some cross over here with both the Controller and the Model as things like Single Page Applications (SPAs) will have data validation feedback for the user. Any other cross overs are heavily frowned upon.
The Model deals with data. This includes validation of data (where applicable). Data storage and retrieval is also handled in this layer.
UPDATE
There seems to be some confusion surrounding who does what when. I included two different overviews of the MVC architectures because they are similar, but not the same. There is room for either interpretation. Possibly, many more. The descriptions above are my interpretation of MVC from multiple sources, including my own experience building applications using this methodology. Hopefully, this update will help to clear up some of this confusion.
MVC is an attempt to build a Separation of Concerns design pattern for software development. It has primarily been implemented in web based applications (to my knowledge).
The View handles all of the user interaction. If your user clicks on a button, the View determines if the click is a user interface interaction or something that is beyond its concern (a Controller interaction). If the button does something like copy values from one field to another, your implementation will determine if that is a View concern or a Controller concern. You will most likely only have this blurring of concerns when dealing with a Single Page Application (SPA).
The Controller is where your actions are processed. The View has communicated the user decided to change values for some fields. The Controller may perform validation on that data or it may be handled by the Model. Again this is implementation dependent. If the Controller has security features, it may determine that the user doesn't have sufficient privileges to perform the action. It would reject the changes and update the View accordingly. The Controller also determines what data to retrieve from the Model, how to package it, and update the View with that data.
The Model determines how and where to store data. It may also perform validation of that data before storing it (it should do this because people will bypass the View on occasion).
Wikipedia has an article on MVC.
- A model notifies its associated view/views and controllers when there has been a change in its state. This notification allows views to update their presentation, and the controllers to change the available set of commands. In some cases an MVC implementation might instead be "passive," so that other components must poll the model for updates rather than being notified.
- A view is told by the controller all the information it needs for generating an output representation to the user. It can also provide generic mechanisms to inform the controller of user input.
- A controller can send commands to the model to update the model's state (e.g., editing a document). It can also send commands to its associated view to change the view's presentation of the model (e.g., by scrolling through a document).
From Microsoft's Overview of MVC.
Models. Model objects are the parts of the application that implement the logic for the application's data domain. Often, model objects retrieve and store model state in a database. For example, a Product object might retrieve information from a database, operate on it, and then write updated information back to a Products table in a SQL Server database.
In small applications, the model is often a conceptual separation instead of a physical one. For example, if the application only reads a dataset and sends it to the view, the application does not have a physical model layer and associated classes. In that case, the dataset takes on the role of a model object.
Views. Views are the components that display the application's user interface (UI). Typically, this UI is created from the model data. An example would be an edit view of a Products table that displays text boxes, drop-down lists, and check boxes based on the current state of a Product object.
Controllers. Controllers are the components that handle user interaction, work with the model, and ultimately select a view to render that displays UI. In an MVC application, the view only displays information; the controller handles and responds to user input and interaction. For example, the controller handles query-string values, and passes these values to the model, which in turn might use these values to query the database.
Best Answer
First I think is best talk about what is MVC Architecture and then go further into the way you are currently programming.
The MVC Architecture is way to organize the workflow inside a sotfware sistem, think about it as a layered way to implement system behaviour. This layers are:
Model: Represents your Data Model, its the system core where all information related to it should be localized. So for example: if you are going to desing a Game you'll need Players, Rules, Obstacles, and some logic related to the interactions of this elements such as : Players should be able to sort Obstacles when some set of Rules apply.
The Model is the first think you should think off because its going to be the center of your applications.
Controller: This is where the magic happens and where the Layered Architecture meets the Object Oriented Paradigm it was intended to use. Here is where you implement how does the system reacts when some application user request something about the app vai the user interface.
View: This is the Start and End Point of User interactions. Here is where you define how users interact with the application. Nowadays is quite common users try to access, for example, web applications from different kinds of media such as: Mobile Phones, Tables, Pcs, Laptops, etc.
Generally each techonologie needs a diferent language to create the view, so imagine that your Data Model and the way that model interacts and how you render that interactions is all hardcoded, there is absolutely no way to reuse your code in a way that is not CopyPaste. The result is code that smells and lots of time wasted adapting the HOLE sysmte.
The virtude of having the View in a separated layer, allow us to work independently from the Model we are currently working on. We only need to know how we should render the list of objects the controller is sendng us. How did he generated it is completly trivial
So , finally we got an independet Model that could be adapted as we see fit according to our current needs (today i need to handle a Monouser Game with no rules, tomorrow i whan to play with friends and now its Multiuser, and so on) that not depends on how are we going to render it to the user. Then, a Controller that captures users request that came from a view , process Model Objects, and then gives the information back to the View to render it.
Back to the first question you asked: Like you can see (i hope) MVC is a WAY to do things and not a TECHNOLOGIE to create software. You could use your java Servlets, and implement a MVC Achitecture under it.
Here is a Q&A example site using a MVC Architecture to clarify a little![enter image description here](https://i.stack.imgur.com/quF8E.jpg)