One ViewController Design
MVC, Model-View-Controller
decouple Model and View
may cause Massive-View-Controller
MVVM, Model-View-ViewModel
- VIewModel is the display data, that can be directly showed in view
- ViewModel - Model may need cast, bi-direction
MVP, Model-View-Prenster
MVCS, Model-View-Controller-Store(Services)
- (Store) Services - networking, data parser, DB, cache, components, tools class
VIPER, View-Interactor-Prenster-Entity-Router(Wireframe)
Router(Wireframe) - keep the VIPER structure existed,
Interactor - data fetching
Presenter - business logic
View/ViewController - weak referenced by Router(Wireframe), every time we re-use, we re-instantiate
Model Design
indicate model detail
ViewModel Design
indicate ViewModel detail
Data flow
For example, we show the tableView cell, how to?
Protocol, delegation
- use Delegation, decouple components, provide standard interface
- use Protocol, replace inheritance
- use Delegation, provide module API