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

MVVM+RAC+TDD

DAloG
April 04, 2015

 MVVM+RAC+TDD

How to. For those who can.

DAloG

April 04, 2015
Tweet

More Decks by DAloG

Other Decks in Programming

Transcript

  1. HOW TO: MVVM + RAC + TDD Note: All info

    is subject to change. April 2015 1
  2. MVVM (RICH VIEW) UIViewController UIKit Network Data storage Business logic

    Custom interface System Interaction @interface MyView: UIView id<MyViewModel> 7
  3. MVVM (RICH VIEW) UIViewController UIKit Network Data storage Business logic

    Custom interface System Interaction @interface MyView: UIView id<MyViewModel> 8
  4. MVVM (RICH VIEW) + RAC UIViewController UIKit Network Data storage

    Business logic Custom interface System Interaction @interface MyView: UIView id<MyViewModel> 9
  5. MVVM (RICH VIEW) + RAC UIViewController UIKit Network Data storage

    Business logic Custom interface System Interaction @interface MyView: UIView id<MyViewModel> 10
  6. HOW TO ACHIEVE? Destination owns a Source. Destination calls a

    Source. Destination look at Source state. Destination is derived from Source. 16
  7. DECOMPOSITION IS A KEY View decomposed to UIViews, UIViewControllers, DataSources,

    Delegates, Managers, Storyboards… View Model decomposed to View Models. Model decomposed to Core, Services, Facades. 21
  8. CODE / LAYER DISTRIBUTION 0 25 50 75 100 Content

    feed Content editor Offline content Offline with sync View ViewModel Model 22
  9. VIEW LAYER Storyboard backed, XIB backed, code - no matter.

    Layout. Localization. Render efficiency. 23
  10. VIEW LAYER CONNECTIONS View View Model Data display View View

    Model Alternate layout View View Model Tab like interface View View Model View Model 24
  11. TDD IN VIEW: CELL TAP Setup expectation for correct call

    Verify call correctness Fire expectation Is Equal to string wrapper 34
  12. TDD IN VIEW: CELL TAP Send event to cell Push

    segue require NavCon Wait for UIKit internals Send event Verify 36
  13. TDD IN VIEW: P.S KIF for interacting. We need to

    wait. Sometimes. Test Behavior not code. 37
  14. VIEW MODEL TESTING TDD As simple as possible. Model state

    changes — ViewModel state changes ViewModel receive call — Model receive call Can hold more than one model. 40
  15. CORE Fail = Crash Minimum frameworks. (Core Data instances may

    be exceptions) Do not owns a facades. Owns services. Data consistence. 44
  16. APPLE PUSH OPTIONS SOURCE: DESTINATION: set @property Setter Call method

    Method Source is depend on Destination. Abstract layer depend on Concrete 51
  17. APPLE PULL OPTIONS SOURCE: DESTINATION: KVO KVO - observe… NSNotification

    @selector() String based typing. Runtime error detection. Threads and ownership 53
  18. RAC USING: NO LOGIC INSIDE Do not mix with UIKit

    Do not mix with Networking Do not mix with Layout Do not mix with CoreData Do not mix with Threading 58