Mvp, Mvc, Mvvm

·

2 min read

When thinking about different frameworks, it's all about the data layer and how it comes to the UI

  • How we turn the model into something or drive something
  • Flow of data
  • Who is "the boss", ie. who is really driving the show?
    • In MVP: presenter is the boss and tells the view what do, given a particular state. Typically you can re-use a presenter across multiple views.
    • MVC: controller is the boss and tells the view what to do (show this, enable that), and is tightly coupled to the view. Typically you have one controller to one view.
    • MVVM: view is the boss and asks the view model to give it stuff

MVC

  • The view is the nib. Or, if you are creating the view programmatically, then it is the file that creates the view.
  • The controller does not need to be the view controller. However because in iOS, there is a concept of "view controller", often when developers use MVC, they make the "view controller" the controller.
  • The cont

  • MVVM:

    • Provides abstraction between layers
    • more testaiblity

MVP

  • Presenter drives everything
    • Gets the data
    • Gives it to the view
  • Presenter is the one to tell the view:
    • Dispaly this
    • Do this with the view

MVVM

  • VM knows how to convert te data into a VM
  • VIew is running the show
    • View asks the VM for everything
    • View displays it

It’s about who is running the show

  • MVP - presenter
  • MVVM - view controller

MVC

  • Controller vs presenter
  • In iOS - doesn’t need to be tied to view controller
  • Controller
    • Show this,
    • Do this
    • Turn off that
    • Understands te view
    • More tied to a view, can’t switch it out
  • Presenter
    • Initialise with a state
    • COuld change out different views with the same presenter
    • e.g. has defined interactions such as navigate back, \

High level animation, games, etc.

  • don’t want to wait for the abstraction and flow. Beacuse it may take more time
  • But with CPUs being so powerful now, it’s pretty theoretical
  • So probably meh, same same