Design Pattern

Model View Controller (MVC)

Damn, I learned about this when first learning about programming in Swift. Reintroduced in CS247.

MVC: Model-View-Controller.

  • Model: Handles logic + data
  • View: Handles program output / display
  • Controller: Handles input, facilitates control flow between classes

Model: May have multiple views, or just one - different types of views: text, graphical view, etc.

  • Model doesn’t need to know anything about the state / implementation of the views
  • Sometimes we structure interactions between Model and View as an Observer Pattern

Controller: mediates control flow.

  • May encapsulate things like turn-taking or some portion of the game rules.
  • Some of this logic may go in the model instead: judgement call
  • May communicate with user for input (sometimes done by the View)


MVC is the standard design pattern for GUIs.