-
Notifications
You must be signed in to change notification settings - Fork 0
Home
#Sliver: The New Refclient UI Architecture#
##Overview
Sliver is based off of a popular iOS architecture called VIPER, an acronym for "View Interactor Presenter Entity Router", which in turn was based off of the much more platform agnostic MVP architecture. While REFCLIENT doesn't need to address the same problems as iOS, the separation of responsibility that VIPER (Sliver) provides holds true regardless of platform.
With Sliver, we can migrate all of our business logic out of our views and unit test it as intended, instead of mixing together our instrumentation and unit tests trying to accommodate monstrous view classes. We can also delegate the acquisition of external dependencies, so that this does not pollute our newly isolated business logic. Finally, we can maintain a single source of truth from the data we acquire, such that our application never enters unpredictable, untestable states. There are 6 types of classes to help us achieve this, organized and grouped into their own subcomponents - one of each class in a subcomponent:
- View
- Presenter
- Interactor
- Router
- ViewModel
- Mapper
It looks like this (sans the Mapper and ViewModel, which are critical, but behave more like utilities):
##ViewModel A ViewModel is an immutable chunk of data that populates the View. It only contains the exact fields necessary to allow the View to be completed, therefore, a ViewModel is specific to the View around which it is designed. Its immutability is to prevent any discordance with the "single source of truth" that is the data source. This is critical in preventing unpredictable states in the application. To emphasize the importance of immutability, ViewModels in Sliver are AutoValue classes (more to come), which for all intents and purposes cannot be changed.
##Mapper Mappers are single responsibility units which convert a specific database model to a specific ViewModel. They are employed by the Presenter of the same Sliver Component. Mappers should be used in the Rx stream between a Presenter and an Interactor.
//todo
##The Role of Dagger //todo
##The Role of Rx //todo
##AutoValue //todo
##Testing //todo
##Package Structure //todo
##Various Musts //todo
##Notes //todo