Sgt. Conker We are "absolutely fine"

3Dec/104

Articles: MVC in games

by Roy Triesscheijn

MVC Primer

MVC stands for "Model View Controller" and has been an architectural pattern in software engineering for quite some time now. MVC allows decoupling between what 'the program is supposed to do' and how this is made visible and controlled.

In MVC the three main responsibilities of the application are handled by three separate parts:

  • The model houses the actual business logic. The model is totally decoupled from the controller and view.
  • The view observes the information from the model, and if needed request an update of the information. Data from the model is lightly massaged, formatted and then presented.
  • The controller controls the application by mapping different kinds of input to public methods available on the model. The model itself always has the final responsibility of doing something with the request made by the controller. In many form-based applications the view and controller are hard to distinguish from each other.

Using MVC will allow you to reuse your complex model in different scenarios. Want to prepare your program for a different kind of input? Just write a new controller. Want to visualize your data in another way, just write a new viewer. In a good application controllers and viewers can even be changed while the application is running.