Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Navigationを見据えたリファクタリング -マルチモジュール化を添えて-

Navigationを見据えたリファクタリング -マルチモジュール化を添えて-

Bonfire Android #5
2019/8/19

Keisuke kiuchi

August 19, 2019
Tweet

More Decks by Keisuke kiuchi

Other Decks in Programming

Transcript

  1. ໦಺ܒี w ৬ۀɿ:ͷ"OESPJEΤϯδχΞ݉ҭࣇύύ w झຯͰ࡞ͬͨϞϊɿʮΒ͘ͰΜ "QQ ʯɺ
 ʮ$MFBO"SDIJUFDUVSF5FNQMBUF'PS,PUMJO 044 ʯ

    w ޷͖ͳΞʔΩςΫνϟɿ$MFBO"SDIJUFDVUF w 4/4
 5XJUUFS!GFJ@LPNF
 (JUIVC!LJVDIJLFJTVLF
 2JJUB!L@LFJTVLF
  2. 1SFTFOUFS "QQ ࣮૷ interface NaviInterface { fun getFragment2(): Fragment fun

    getFragment3(data: SomeData): Fragment } class RefactoredFragment { override fun onOptionsItemSelected(item: MenuItem): Boolean { when (item.itemId) { android.R.id.home -> changeFragment(naviInterface.getFragment2()) R.id.action_sub -> changeFragment(naviInterface.getFragment3(data)) } return super.onOptionsItemSelected(item) } } class NaviInterfaceImpl : NaviInterface { override fun getFragment2(): Fragment = Fragment2.newInstance() override fun getFragment3(data: SomeData): Fragment = Fragment3.newInstance(data.code, data.name) } OBWJHBUJPOΛ࢖͏ͱ͖͸͜ΕΒΛ ஔ͖׵͑Ε͹0, ͩͱࢥ͏ OBWJHBUJPOʹ͢Δ࣌͸
 ͜ΕΒΛஔ͖׵͑Ε͹0,
  3. ऄ଍ͦͷ̍ w ͜ͷख๏ͬͯଞͷϨΨγʔͳ"QJ΍6UJMݺͼग़͠ʹ΋࢖͑ΔΜ͡Όʁ
 ˠ:&4 1SFTFOUFS "QQ 3FGBDUPSFE
 'SBHNFOU -FHBDZ6UJM ɾ

    ɾ ɾ -FHBDZ"QJ -FHBDZ
 *OUFSGBDF -FHBDZ
 *OUFSGBDF
 *NQM -FHBDZ
 *OUFSGBDF -FHBDZ
 *OUFSGBDF -FHBDZ
 *OUFSGBDF
 *NQM -FHBDZ
 *OUFSGBDF
 *NQM