Introducing 

Prezi AI.

Your new presentation assistant.

Refine, enhance, and tailor your content, source relevant images, and edit visuals quicker than ever before.

Loading…
Transcript
  • Model View Controller
  • Separate Model, View, Controller
  • More popular by the minute
  • Variations
  • Fetch data from model
  • Go to other view
  • Go to other controller
  • Update data in model
  • Close view
  • Close application
  • Fetch data from other model
  • Show X if Y
  • Show subview
  • difficult to write
  • difficult to check
  • difficult to maintain
  • time & memory consuming
  • MVC is sloppy
  • Isn't enough
  • Can mean anything
  • Views and Models are often tightly coupled
  • Cannot easily see dependencies
  • Views are coupled to Views.
  • Must test Views
  • Integration Tests

Dependency Hell!

Testability

Explicit Flow of Control

Type Safety

Low Coupling

  • Being able to replace models, views and controls...
  • ...without having to test each combination of model, view and controller again.
  • FSM give explicit flow of control.
  • View-interfaces ensure transitions, giving type safety.
  • Humble object helps with testability.
  • Monads give type safety to context.
  • DI decrease coupling.
  • Presenter decrease coupling.
  • States help codify synthesis requirements

...as does transitions.

  • M/V can be reused by different FSMs.
  • Easy to inject different set of views.
  • Not a lib or tool - an architecture.
  • Customize as needed.

State First Architecture

MVC Recap.

MVC View

Testability

  • Able to test each model, view or control separately
  • Need to control side effects.

Spaghetti

Low Coupling

We need

  • See how views are connected.
  • Share information about the flow for outsiders.
  • Reuse controlflow.

Explicit Flow of Control

2

O(n )

  • Being able to guarantee the absence of some bugs.
  • Not having to wade through 1000 LOC in order to find interesting events &c.

Type Safety

Clues to a solution

  • Low Coupling, Testability > Presenter First
  • Controlflow > Finite State Machine
  • Low Coupling, Testability > Dependency Injection
  • Type Safety, Controlflow > Monads

Presenter First

  • View-Presenter
  • Humble Object
  • Presenter knows about IModel and IView
  • IModel knows nothing about IView or Presenter
  • IView knows nothing about IModel or Presenter
  • MVP-triads
  • Inject M and V into P

Finite State Machine

  • Controls the transitions that exist between different states.
  • Easy to find the transitions.
  • Should control side effects.

Dependency Injection

  • Inject M/V runtime using e.g. Abstract Factory Pattern.
  • Makes sure M/V doesn't know about each others concrete implementations.
  • Can change entire group of M/V easily.
  • AFP makes sure needed implementations are provided.
  • Avoid global state.

Monads

  • Models as monads.
  • Computational context.
  • Only one model per view.
  • Transitions as monad transformations.
  • Bind between monads.
  • States can demand certain monads.
  • Helps with ensuring a known good context.

Proposition

Conclusion

  • A FSM handle the connections.
  • Each state in the FSM is a MV-pair.
  • Each transition is an event, binding the states models.
  • FSM creates M/V using an Abstract Factory exposing M/V-interfaces.
  • Each state can have explicit demands on incoming states.

Questions?

Learn more about creating dynamic, engaging presentations with Prezi