for
-nihal111
Nihal Singh
Understanding the spec and being able to picture the flow of the feature is crucial for efficient implementation.
Have a design/flow-diagram to work with.
Make a rough one by hand if you don't get one from the designer. It helps.
Once the first two steps are done, it's time to create a Contract for the ViewProxy, Presenter and Model layers.
This does not have to be final. It just serves as a great starting point and allows you to get some clarity.
Make an architectural design doc, using the template.
The doc should essentially contain the following-
Once you've signed the Contract,
it's time to commit.
Keep writing tests as you go, or at least keep thinking about how you'll write them. This should keep the code testable.
Activity
Keep the activities lean
Delegate lifecycle events to the Presenter
To call super methods in the Activity, use a custom interface, that gets called by the presenter
Presenter
It's a good idea to have the Presenter extend from the LifecycleAwarePresenter (com.kouzoh.mercari.common.presenter)
The lifecycle (FragmentActivity.getLifecycle()) can be passed to the Presenter during construction
This allows for clearing the disposables at the right lifecycle events.
ViewProxy
The ViewProxy should be initialized inside the Activity and passed on to the presenter during it's construction.
The ViewProxy can take in the activity as parameter during construction. This allows for obtaining the context and finding views by ID.
Template Create and Edit Screen
TemplateCreateEditActivity
Create Screen
Edit Screen
When?
onCreate
How?
Activity
Presenter
ViewProxy
Activity delegates onCreate to Presenter
Presenter calls view to update UI, based on intent received
Depends on?
intent.getStringExtra(S.MODE)
When?
onCreate
How?
Activity
Presenter
ViewProxy
Activity delegates onCreate to Presenter
Presenter defines the onClickListener and passes it to the ViewProxy
Depends on?
intent.getStringExtra(S.MODE)