Model-View-Controller

In modern web and mobile development there’s a concept of Model-View-Controller (MVC) which is simply a design pattern in which every instance belongs to one of three layers -> Model Layer, View Layer, or Controller Layer. ¬†Layer is just a fancy term for objects that fulfill a role.

  • Model Layer
    • holds data
    • has no info about User Interface (UI)
    • called things like you would call them IRL
      • For Crapper Keeper I had models for:
        • Users
        • Containers
        • Items
  • View Layer
    • UI primarily
      • things users can see
    • Things they can interact with go here
      • buttons, text fields, etc.
    • Sends message to controller
  • Controller Layer
    • Management for the app
      • configure the views that the users can see and when they can see it
      • the directions for how the app should work/flow
    • Takes data from model objects that its views want information on
    • Updates model objects
    • Updates view with changes in model objects

Models do not interact directly with views – the controller layer does all of the talking between these layers, receiving and dispatching requests.