-
Notifications
You must be signed in to change notification settings - Fork 0
Contract
Jack Malpo edited this page Jan 30, 2017
·
6 revisions
#Contract
Every subcomponent contains a Contract interface that binds the different elements together through expectations. The Contract contains different sub-interfaces that pertain to the different core Sliver pieces, eg. View, Presenter, Interactor, Router. The purpose of this interface is to ensure that nothing is coupled with anything else, so that a View should not have to know about the exact Presenter implementation to which it plans to interact with, and so on. Thus, every element holds a reference to an interface of the Contract instead of the actual implementation. This also allows for generification of the elements and methods, and easier testing through dependency injection.
A skeleton Contract looks like this:
//Contract.class is the base Contract for all Sliver subcomponents
interface SkeletonContract extends Contract {
interface View extends Contract.View {
//View methods
//eg. void displayNumber(NumberViewModel number);
}
//Presenters need to hold a reference to a generic View, so these need to be typed
interface Presenter extends Contract.Presenter<View> {
//Presenter methods
}
interface Interactor extends Contract.Interactor {
//Interactor methods
}
interface Router {
//Router methods
}
}