What is Model View Controller (MVC)?
In a typical application you will find these three fundamental parts: • Data (Model) • An interface to view and modify the data (View) • Operations that can be performed on the data (Controller) The MVC pattern, in a nutshell, is this: • The model represents the data, and does nothing else. The model does NOT depend on the controller or the view. • The view displays the model data, and sends user actions (e.g. button clicks) to the controller. The view can: • be independent of both the model and the controller; or • actually be the controller, and therefor depend on the model. • The controller provides model data to the view, and interprets user actions such as button clicks. The controller depends on the view and the model. In some cases, the controller and the view are the same object. Rule 1 is the golden rule of MVC so I’ll repeat it: The model represents the data, and does nothing else. The model does NOT depend on the controller or the view. Let’s take an address book application