Skip to content

ethyreal/PlanningPoker

Repository files navigation

PlanningPoker

Simple example of an MVVM+C implementation.

Project Goals

  1. Create a non trivial app using MVC as given by apple. Build up "massive view controllers" or at least tightly coupled. They should have the following inside each UIViewController:
    • Model/Business
    • Navigation/Routing
    • Networking
  2. Refactor logic item by time towards a goal of MVVM+C. Each iteration should have:
  3. Polish well factored POC into a fully functioning MVP of Planning Poker
  4. Explore evolving this architecture towards a declarative and reactive paradigm using Combine and SwiftUI
  5. Make the case for MVVM as a prefered transitional design pattern that is useful for a UIKit world and later for a SwiftUI world

What is MVVM?

The Model-View-ViewModel (MVVM) pattern helps to cleanly separate the business and presentation logic of an application from its user interface (UI)

Why?

Strengths of using this pattern primarily are:

  • Separation of concerns
  • Easy to reason about
  • Testability

How is this done in UIKit?

  • Model: Struct/Class
  • View: UIView(Controller)
  • ViewModel: Class

But really it should be written:

Model <-> ViewModel <-> View

The Model and View never actually talk to each other.

We can use a State type to represent a view's ... well state. This creates a unidirectional data flow for UI updates:

Model -> ViewModel -> State -> View.

There is also a parallel flow that handles updates or actions from the user in the view:

View -> ViewModel -> Service -> Model

An illustration of these data flows:

MVVM+C

About

Simple example of an MVVM+C implementation

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages