The Model-View-Controller Architecture
The MVC pattern splits an application into three layers: the model, the view, and the controller. Each of these layers has a very specific job that it is responsible for and—most important—is not concerned with how the other layers do their jobs.
The Model
The model represents core business logic and data. Models encapsulate the properties and behavior of a domain entity and expose properties that describe the entity. For example, the Auction class represents the concept of an “auction” in the application and may expose properties such as Title and Current Bid, as well as exposing behavior in the form of methods such as Bid().
The View
The view is responsible for transforming a model or models into a visual representation. In web applications, this most often means generating HTML to be rendered in the user’s browser, although views can manifest in many forms. For instance, the same model might be visualized in HTML, PDF, XML, or perhaps even in a spreadsheet. Following separation of concerns, views should concentrate only on displaying data and should not contain any business logic themselves—the business logic stays in the model, which should provide the view with everything it needs.
The Controller
The controller, as the name implies, controls the application logic and acts as the coordinator between the view and the model. Controllers receive input from users via the view, then work with the model to perform specific actions, passing the results back to the view.