Implementing new feature in existing screen

3be52a14c8c58209263d7f83204b8dc7?s=47 Rui Kowase
August 28, 2018

Implementing new feature in existing screen

2018/08/23 Android Lunch & Learn

3be52a14c8c58209263d7f83204b8dc7?s=128

Rui Kowase

August 28, 2018
Tweet

Transcript

  1. Implementing New Feature in Existing Screen Rui Kowase @rkowase 2018/08/23

    Android Lunch & Learn
  2. Can you implement new feature in existing screen easily?

  3. Agenda • The New Architecture • Architecture of SafeTrade feature

    • Q&A
  4. Profile • Name: Rui Kowase / 小和瀬 塁 • Account:

    @rkowase Skill: Flutter, Android, etc...
  5. The New Architecture

  6. Benefits of The New Architecture “This architecture will help you

    to make your code less buggy and easier to modify. Having a consistent architecture will make your work and life easier.”
  7. Goal of The New Architecture • Shared Knowledge • Improves

    testability • Reusability
  8. Overview of The New Architecture

  9. Example of The New Architecture in Exhibit Screen

  10. Testing

  11. Architecture of SafeTrade

  12. Overview of SafeTrade Feature ItemDetail Screen Exhibit Screen

  13. Architecture of SafeTrade Feature Exhibit ViewProxy Exhibit Presenter Existing Feature

    Exhibit Repository SafeTradeExhibit Presenter SafeTradeExhibit Repository SafeTradeExhibit ViewProxy SafeTrade FeatureBuilder Exhibit Activity New Feature Feature toggle SafeTrade ViewFactory Inject Inject
  14. Architecture of SafeTrade Feature Exhibit ViewProxy Exhibit Presenter Existing Feature

    Exhibit Repository SafeTradeExhibit Presenter SafeTradeExhibit Repository SafeTradeExhibit ViewProxy SafeTrade FeatureBuilder Exhibit Activity New Feature Feature toggle SafeTrade ViewFactory Inject Inject
  15. ExhibitModule @Module class ExhibitModule( // ... @Provides @ActivityScope fun provideSafeTradePresenter():

    SafeTradeContract.ExhibitPresenter { val builder = SafeTradeFeatureBuilder(...) return builder.buildExhibitPresenter(...) } }
  16. ExhibitPresenter class ExhibitPresenter @Inject constructor( // ... private val safeTradeExhibitPresenter:

    SafeTradeContract.ExhibitPresenter, ) : ExhibitContract.Presenter {
  17. Architecture of SafeTrade Feature Exhibit ViewProxy Exhibit Presenter Existing Feature

    Exhibit Repository SafeTradeExhibit Presenter SafeTradeExhibit Repository SafeTradeExhibit ViewProxy SafeTrade FeatureBuilder Exhibit Activity New Feature Feature toggle SafeTrade ViewFactory Inject Inject
  18. SafeTrade Contract interface SafeTradeContract { interface Presenter { // .....

    } interface ExhibitPresenter : Presenter { // ..... companion object { val EMPTY = object : ExhibitPresenter {} } } interface ExhibitView : ViewProxy<ExhibitPresenter> { // ..... } // ..... } The interface of SafeTrade’s ViewProxy and Presenter
  19. SafeTrade FeatureBuilder class SafeTradeFeatureBuilder @Inject constructor( private val activity: Activity,

    private val provider: SafeTradeViewFactory ) { @VisibleForTesting var isDebug: Boolean = BuildConfig.DEBUG fun buildExhibitPresenter(repository: SafeTradeRepository, helper: StringFormatHelper, state: ListingUiState ): SafeTradeContract.ExhibitPresenter { if (!isDebug) { return SafeTradeContract.ExhibitPresenter.EMPTY } // ….. return presenter } } The builder for Presenter
  20. Architecture of SafeTrade Feature Exhibit ViewProxy Exhibit Presenter Existing Feature

    Exhibit Repository SafeTradeExhibit Presenter SafeTradeExhibit Repository SafeTradeExhibit ViewProxy SafeTrade FeatureBuilder Exhibit Activity New Feature Feature toggle SafeTrade ViewFactory Inject Inject
  21. SafeTrade ViewFactory interface SafeTradeViewFactory { interface Exhibit : SafeTradeViewFactory {

    fun getEnableRoot(): View fun getEnableCheckbox(): CheckBox fun getEnableCheckboxContainer(): View fun getEnableSafeTradeFeeValue(): TextView fun getEnableTitle(): TextView fun getEnableSubTitle(): TextView fun getEnableHelpIcon(): ImageView fun getAdditionalFeeRoot(): View fun getAdditionalFeeLabel(): TextView fun getAdditionalFeeValue(): TextView fun getAgreementRoot(): View fun getAgreementCheckbox(): CheckBox } } View inflater
  22. Architecture of SafeTrade Feature Exhibit ViewProxy Exhibit Presenter Existing Feature

    Exhibit Repository SafeTradeExhibit Presenter SafeTradeExhibit Repository SafeTradeExhibit ViewProxy SafeTrade FeatureBuilder Exhibit Activity New Feature Feature toggle SafeTrade ViewFactory Inject Inject
  23. ExhibitActivity private void setUpDi() { // ... SafeTradeExhibitViewFactoryProvider provider =

    new SafeTradeExhibitViewFactoryProvider( findViewById(R.id.safe_trade_frame_enable), // ... ); ThisApplication.get(this) .component() .newStatefulExhibitSubComponent( new ExhibitModule( // ... exhibitViewProxy, // … ), new ImageModule(this)) .inject(this); }
  24. The flow of SafeTrade

  25. Architecture of SafeTrade Feature Exhibit ViewProxy Exhibit Presenter Existing Feature

    Exhibit Repository SafeTradeExhibit Presenter SafeTradeExhibit Repository SafeTradeExhibit ViewProxy SafeTrade FeatureBuilder Exhibit Activity New Feature Feature toggle SafeTrade ViewFactory Inject Inject Tap SafeTrade’s View
  26. Architecture of SafeTrade Feature Exhibit ViewProxy Exhibit Presenter Existing Feature

    Exhibit Repository SafeTradeExhibit Presenter SafeTradeExhibit Repository SafeTradeExhibit ViewProxy SafeTrade FeatureBuilder Exhibit Activity New Feature Feature toggle SafeTrade ViewFactory Inject Inject Call SafeTradeExhibit Presenter
  27. Architecture of SafeTrade Feature Exhibit ViewProxy Exhibit Presenter Existing Feature

    Exhibit Repository SafeTradeExhibit Presenter SafeTradeExhibit Repository SafeTradeExhibit ViewProxy SafeTrade FeatureBuilder Exhibit Activity New Feature Feature toggle SafeTrade ViewFactory Inject Inject Do nothing if it is disabled
  28. Architecture of SafeTrade Feature Exhibit ViewProxy Exhibit Presenter Existing Feature

    Exhibit Repository SafeTradeExhibit Presenter SafeTradeExhibit Repository SafeTradeExhibit ViewProxy SafeTrade FeatureBuilder Exhibit Activity New Feature Feature toggle SafeTrade ViewFactory Inject Inject Call SafeTradeExhibit ViewProxy
  29. Architecture of SafeTrade Feature Exhibit ViewProxy Exhibit Presenter Existing Feature

    Exhibit Repository SafeTradeExhibit Presenter SafeTradeExhibit Repository SafeTradeExhibit ViewProxy SafeTrade FeatureBuilder Exhibit Activity New Feature Feature toggle SafeTrade ViewFactory Inject Inject Update views
  30. Summary • Toggle Feature in Builder class • SRP (Single

    Responsibility Principle) • Divide classes by interface and inject
  31. Thank you!