Upgrade to Pro — share decks privately, control downloads, hide ads and more …

ViewControllers: The Right Way

ViewControllers: The Right Way

Bottom-up approach to relieve ViewController's from some responsabilities.
The first part is about how we can define a component and then how these components interact between them.

Avatar for Francisco Depascuali

Francisco Depascuali

September 29, 2016

Other Decks in Programming

Transcript

  1. Content • State of the art • Problem • Solution

    • Demo • Components • Demo • Questions?
  2. VC Responsabilidades • Model - View binding • Handle user

    input Ideal World Real World • Model - View binding • Handle user input • Layout • Navigation flow • Data source • Persistance • Data fetching & transformation • Model mutation
  3. MVVM • ViewModel - View binding • Handle user input

    • Layout • Navigation flow View Controller View Model • Data source • Persistance (Services, Repositories) • Data fetching & transformation • Model mutation
  4. Problem • Layout is ViewController’s responsibility.
 • Can’t inject dependencies

    on ViewController’s init method: • Inconsistent state of ViewController at initialization. • User needs to call a function. • Mutability: Different semantic meaning.
  5. NibLoadable Represents a component that can be loaded from a

    nib. Default implementation for UIViews: Load a view by its name
  6. Reference • Simple made easy - Rich Hickey • WWDC

    session 229: Adv. iOS Application Architecture and Patterns - Andy Matuschak • Let’s Play: Refactor the Mega-Controller - Andy Matuschak • Repo: https://github.com/Wolox/wolmo-core- ios