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

ZOZOが採用しているiOSのアーキテクチャについて/zozo-tech-meetup8-io...

M"e
November 22, 2018
2.5k

 ZOZOが採用しているiOSのアーキテクチャについて/zozo-tech-meetup8-ios-architecture

M"e

November 22, 2018
Tweet

Transcript

  1. Copyright © ZOZO Technologies, Inc. All Rights Reserved. ΞδΣϯμ ‣ݱࡏ࠾༻͍ͯ͠ΔJ04ͷΞʔΩςΫνϟ

    ‣࣍ʹ࠾༻͢ΔJ04ͷΞʔΩςΫνϟ ‣࠾༻ཧ༝ ‣ΞʔΩςΫνϟʹ͍ͭͯ ‣࣮૷ʹ͍ͭͯ ‣·ͱΊ
  2. Copyright © ZOZO Technologies, Inc. All Rights Reserved. ‣͑ΜͲ͏ ‣7"4*-:;0;0ςΫϊϩδʔζ

    ‣6*࣮૷͕޷͖ ‣5BC1BHF7JFX$POUSPMMFS ‣$PODFQU%FTJHO)PNF$POUSPM"QQ ‣(JU)VCIUUQTHJUIVCDPN&OEPV.BSJ ϓϩϑΟʔϧ
  3. Copyright © ZOZO Technologies, Inc. All Rights Reserved. .7$ ‣$PDPB͕.7$ʹج͍࣮ͮͯ૷͞Ε͍ͯΔ

    ‣7JFXͱ.PEFM͕෼཭͍ͯ͠ΔͷͰ࠶ར༻ੑ͕ߴ͍ ‣γϯϓϧʂ ‣ॲཧ͕ෳࡶʹͳΔͱ$POUSPMMFS͕ංେԽ View Model ViewController Update Action Update Notify Update ࢀߟ: https://developer.apple.com
  4. Copyright © ZOZO Technologies, Inc. All Rights Reserved. .77. $PPSEJOBUPST

    ‣.77. ‣7JFX$POUSPMMFSʹूத͢ΔϩδοΫΛ7JFX.PEFMʹ੾Γ෼͚Δ ‣7JFXͱ7JFX.PEFMؒͷ΍ΓऔΓ͸ΛσʔλόΠϯσΟϯάΛ࢖༻ ‣σʔλόΠϯσΟϯάʹ3YͳͲΛ࢖༻ ‣$PPSEJOBUPST ‣ը໘ભҠΛ୲౰ View Model ViewModel Coordinators ࢀߟ: https://speakerdeck.com/macdevnet/mvvm-c-in-practice
  5. Copyright © ZOZO Technologies, Inc. All Rights Reserved. ΞʔΩςΫνϟʹٻΊΔ͜ͱ ‣௕͘ӡ༻Ͱ͖Δ͜ͱΛ૝ఆͨ͠ΞʔΩςΫνϟ

    ‣࢓༷ͷมߋɺ6*ͷมߋΛ͠΍͍͢ ‣ϝϯόʔ͕૿͑ͨͱͯ͠΋࣮૷͠΍͍͢ ‣։ൃ૊৫͕ϚτϦοΫε ‣ΤϯδχΞͷྲྀಈੑ͕ߴ͍ ‣ϓϩδΣΫτʹॻ͔ؔΘΔΤϯδχΞ͕ଟ͍
  6. Copyright © ZOZO Technologies, Inc. All Rights Reserved. ࣍ʹ࠾༻͢ΔͳΒʁ ‣.7$

    ‣.77. ‣'MVY ‣$MFBO"SDIJUFDUVSF ‣7*1&3 ‣FUDʜ
  7. Copyright © ZOZO Technologies, Inc. All Rights Reserved. ΞʔΩςΫνϟͷ۠෼ ‣(6*ΞʔΩςΫνϟ

    ‣.7$ɺ.77.ɺ'MVY ‣7JFXͱ.PEFMΛ෼཭ ‣γεςϜΞʔΩςΫνϟ ‣$MFBO"SDIJUFDUVSFɺ7*1&3 ‣γεςϜશମͷߏ੒
  8. Copyright © ZOZO Technologies, Inc. All Rights Reserved. ΞʔΩςΫνϟͷ۠෼ Presentation

    Layer Model Layer Data Layer ‣(6*ΞʔΩςΫνϟ ‣.7$ɺ.77.ɺ'MVY ‣7JFXͱ.PEFMΛ෼཭ ‣γεςϜΞʔΩςΫνϟ ‣$MFBO"SDIJUFDUVSFɺ7*1&3 ‣γεςϜશମͷߏ੒
  9. Copyright © ZOZO Technologies, Inc. All Rights Reserved. ΞʔΩςΫνϟͷ۠෼ Presentation

    Layer Model Layer Data Layer ‣(6*ΞʔΩςΫνϟ ‣.7$ɺ.77.ɺ'MVY ‣7JFXͱ.PEFMΛ෼཭ ‣γεςϜΞʔΩςΫνϟ ‣$MFBO"SDIJUFDUVSFɺ7*1&3 ‣γεςϜશମͷߏ੒ ࢀߟ: https://speakerdeck.com/takasek/10fen-tezhen-rifan-rusohutoueaakitekutiyafalseli-shi-2017
  10. Copyright © ZOZO Technologies, Inc. All Rights Reserved. ࣍ʹ࠾༻͢ΔͳΒʁ ‣.7$

    ‣.77. ‣'MVY ‣$MFBO"SDIJUFDUVSF ‣7*1&3 ‣FUDʜ
  11. Copyright © ZOZO Technologies, Inc. All Rights Reserved. ࣍ʹ࠾༻͢ΔͳΒʁ ‣.7$

    ‣.77. ‣'MVY ‣$MFBO"SDIJUFDUVSF ‣7*1&3 ‣FUDʜ
  12. Copyright © ZOZO Technologies, Inc. All Rights Reserved. 7*1&3ͱ͸ ‣.VUVBM.PCJMFߟҊJ04൛$MFBO"SDIJUFDUVSF

    ‣γεςϜͷมԽ͕ଟ͍෦෼ͱͦ͏Ͱͳ͍෦෼Ͱ෼͔Ε͍ͯΔ ‣7JFXɺ*OUFSBDUPSɺ1SFTFOUFSɺ&OUJUZɺ3PVUJOH ‣֤ϨΠϠʔ1SPUPDPMʹͷΈґଘ ‣୯Ұ੹೚ͷݪଇΛ΋ͱʹ࡞ΒΕͨ ग़య: https://www.objc.io/issues/13-architecture/viper/
  13. Copyright © ZOZO Technologies, Inc. All Rights Reserved. ࠾༻ཧ༝ᶃ௕͘ӡ༻͢Δͷʹ߹͍ͬͯΔ ‣6*ɺ8FC"1*ΫϥΠΞϯτͳͲมԽ͕ଟ͍෦෼ͱมߋ͠ʹ͍͘෦෼͕෼͔

    Ε͍ͯΔ ‣ϑϨʔϜϫʔΫɺϥΠϒϥϦʔʹґଘ͠ͳ͍ ‣6*มߋΛ͠΍͍͢ ‣୯Ұ੹೚ͷݪଇ ‣ॲཧΛॻ͘৔ॴ͕໌֬ʹܾ·͍ͬͯΔ ‣Ұ෦ͷΫϥεʹॲཧ͕ूத͍͍͘͠
  14. Copyright © ZOZO Technologies, Inc. All Rights Reserved. ࠾༻ཧ༝ᶄϝϯόʔ͕૿͑ͯ΋ରԠ͠΍͍͢ ‣ࡉ෼Խ͞Ε͍ͯΔͷͰίϯϑϦΫτ͕গͳ͍

    ‣ॲཧΛॻ͘৔ॴ͕໌֬ʹܾ·͍ͬͯΔͷͰ໎Θͳ͍ ‣Ϋϥε͕ංେԽ͠ͳ͍ͷͰॲཧΛ௥͍΍͍͢
  15. Copyright © ZOZO Technologies, Inc. All Rights Reserved. $MFBO"SDIJUFDUVSFͱ͸ ‣&OUJUZ

    ‣σʔλߏ଄ɺϏδωεϩδοΫ ‣6TF$BTF ‣"QQMJDBUJPOݻ༗ͷϩδοΫ ‣*OUFSGBDF"EBQUFS ‣σʔλ΍ΠϕϯτΛม׵͢ΔϨΠϠʔ ‣'SBNFXPSLT%SJWFST ‣6*ɺσʔλϕʔεɺ8FC"1*ΫϥΠϯτ ग़య: http://blog.cleancoder.com/uncle-bob/2012/08/13/the-clean-architecture.html
  16. Copyright © ZOZO Technologies, Inc. All Rights Reserved. $MFBO"SDIJUFDUVSFͱ͸ ‣ґଘͷํ޲͕୯ํ޲

    ‣'SBNFXPSLˠ*OUFSGBDFˠ6TF$BTFˠ&OUJUZ ‣֎ଆ͔Β಺ଆ΁ͷࢀর ‣࢓༷มߋʹڧ͍ ‣6*ɾ04ɾ8FC"1*ΫϥΠΞϯτͳͲมߋ͕ଟ͍ͱ͜ΖΛ֎ʹ ‣มߋ͕গͳ͍&OUJUZΛத৺ͱ͍ͯ͠Δ
  17. Copyright © ZOZO Technologies, Inc. All Rights Reserved. 7*1&3ͷશମ૾ View

    Entity Presenter Routing Interactor User Action Asks for Update Notifies Updates Knows about ࢀߟ: https://cheesecakelabs.com/blog/ios-project-architecture-using-viper/
  18. Copyright © ZOZO Technologies, Inc. All Rights Reserved. 7*1&3ͷશମ૾ ࢀߟ:

    https://cheesecakelabs.com/blog/ios-project-architecture-using-viper/ View Entity Presenter Routing Interactor User Action Asks for Update Notifies Updates Knows about View
  19. Copyright © ZOZO Technologies, Inc. All Rights Reserved. 7JFX ‣ը໘දࣔ

    ‣7JFX7JFX$POUSPMMFS ‣λοϓͳͲͷ6*ΠϕϯτΛड͚औΔ ‣6*ΠϕϯτΛ1SFTFOUFSʹ௨஌͢Δ
  20. Copyright © ZOZO Technologies, Inc. All Rights Reserved. 7*1&3ͷશମ૾ View

    Entity Presenter Routing Interactor User Action Asks for Update Notifies Updates ࢀߟ: https://cheesecakelabs.com/blog/ios-project-architecture-using-viper/ Knows about Presenter
  21. Copyright © ZOZO Technologies, Inc. All Rights Reserved. 1SFTFOUFS ‣7JFX͔ΒͷΠϕϯτ΋ͱʹ*OUFSBDUPSʹσʔλΛཁٻ

    ‣*OUFSBDUPS͔Βड͚औͬͨσʔλΛ΋ͱʹදࣔ༻ίϯςϯπΛ४උ ‣ϏϡʔϩδοΫؚ͕·ΕΔ ‣݅਺͕݅ͩͬͨΒθϩϚονը໘ ‣ը໘ભҠͷ੹೚΋࣋ͭ
  22. Copyright © ZOZO Technologies, Inc. All Rights Reserved. 7*1&3ͷશମ૾ View

    Entity Presenter Routing Interactor User Action Asks for Update Notifies Updates ࢀߟ: https://cheesecakelabs.com/blog/ios-project-architecture-using-viper/ Knows about Interactor
  23. Copyright © ZOZO Technologies, Inc. All Rights Reserved. *OUFSBDUPS ‣6TF$BTF

    ‣ΞϓϦέʔγϣϯݻ༗ͷϩδοΫ ‣6*ʹؔ͢Δॲཧ͸ॻ͔ͳ͍
  24. Copyright © ZOZO Technologies, Inc. All Rights Reserved. 7*1&3ͷશମ૾ View

    Entity Presenter Routing Interactor User Action Asks for Update Notifies Updates Knows about ࢀߟ: https://cheesecakelabs.com/blog/ios-project-architecture-using-viper/ Entity
  25. Copyright © ZOZO Technologies, Inc. All Rights Reserved. 7*1&3ͷશମ૾ View

    Entity Presenter Routing Interactor User Action Asks for Update Notifies Updates ࢀߟ: https://cheesecakelabs.com/blog/ios-project-architecture-using-viper/ Knows about Routing
  26. Copyright © ZOZO Technologies, Inc. All Rights Reserved. 7*1&33PVUJOH ‣ը໘ભҠ

    ‣ը໘ͷηοτΞοϓ ‣ϧʔςΟϯάͷ੹೚͸1SFTFOUFSͱ3PVUJOHͰڞ༗͍ͯ͠Δ ‣1SFTFOUFS͸ભҠ͢Δը໘ͷೝࣝ ‣3PVUJOH͸Ͳ͏΍ͬͯը໘ભҠΛ͢Δ͔
  27. Copyright © ZOZO Technologies, Inc. All Rights Reserved. Ϧετը໘Λදࣔ ‣࢓༷

    ‣ΞΠςϜҰཡΛදࣔ͢Δ࣮૷ ‣"1*ϦΫΤετ͸WJFX%JE-PBEͷλΠϛϯά
  28. Copyright © ZOZO Technologies, Inc. All Rights Reserved. 7*1&3ʹ͸ΊΔ View

    Entity Presenter Routing Interactor σʔλऔಘͰ͖ͨΑ σʔλऔಘͰ͖͔ͨΒදࣔͯ͠ ஌͍ͬͯΔ viewDidload σʔλऔಘ ͓ئ͍ʂ ListViewController Item ϏϡʔϩδοΫ ΞϓϦέʔγϣϯ ϩδοΫ ը໘ભҠ อ༗ ࢀߟ: https://cheesecakelabs.com/blog/ios-project-architecture-using-viper/
  29. Copyright © ZOZO Technologies, Inc. All Rights Reserved. 7*1&3ʹ͸ΊΔ View

    Entity Presenter Routing Interactor σʔλऔಘͰ͖ͨΑ σʔλऔಘͰ͖͔ͨΒදࣔͯ͠ ஌͍ͬͯΔ viewDidload σʔλऔಘ ͓ئ͍ʂ ListViewController Item ϏϡʔϩδοΫ ΞϓϦέʔγϣϯ ϩδοΫ ը໘ભҠ DataStore σʔλऔಘ อ༗ σʔλऔಘͰ͖ͨΑ ࢀߟ: https://cheesecakelabs.com/blog/ios-project-architecture-using-viper/
  30. Copyright © ZOZO Technologies, Inc. All Rights Reserved. ࣮૷͢Δલʹɺͳͥ1SPUPDPMΛ࢖༻͢Δͷ͔ʁ ‣ॲཧΛந৅Խ

    ‣ॲཧʹґଘ͠ͳ͍ ‣ґଘؔ܎ٯసͷ๏ଇ ‣಺ଆ͕֎ଆΛݺͼग़͍ͨ͜͠ͱ͕͋Δ ‣*OUFSBDUPS͕σʔλΛऔಘͨ͜͠ͱΛ1SFTFOUFSʹ఻͍͑ͨ ‣௚઀ࢀর͢Δ͜ͱ͸ґଘؔ܎Λ่ͯ͠͠·͏ ‣಺ଆ͕એݴͨ͠1SPUPDPMΛ֎ଆ͕࣮૷͢Δ͜ͱͰղܾ ‣ؒ઀తʹࢀর͢Δ͜ͱ͕Մೳ
  31. Copyright © ZOZO Technologies, Inc. All Rights Reserved. &OUJUZͷ࣮૷ struct

    Item { let id: Int let name: String let imageURL: URL let price: Int let brandName: String }
  32. Copyright © ZOZO Technologies, Inc. All Rights Reserved. 7*1&3ʹ͸ΊΔ View

    Entity Presenter Routing Interactor σʔλऔಘͰ͖ͨΑ σʔλऔಘͰ͖͔ͨΒදࣔͯ͠ ஌͍ͬͯΔ viewDidload σʔλऔಘ ͓ئ͍ʂ ListViewController Item ϏϡʔϩδοΫ ΞϓϦέʔγϣϯ ϩδοΫ ը໘ભҠ DataStore σʔλऔಘ ࢀߟ: https://cheesecakelabs.com/blog/ios-project-architecture-using-viper/ อ༗ Presenter Interactor σʔλऔಘͰ͖ͨΑ σʔλऔಘ ͓ئ͍ʂ ϏϡʔϩδοΫ ΞϓϦέʔγϣϯ ϩδοΫ
  33. Copyright © ZOZO Technologies, Inc. All Rights Reserved. *OUFSBDUPSͷ࣮૷ protocol

    ItemsInteractorInput: class { func fetchItems() } protocol ItemsInteractorOutput: class { func itemsFetched(items: [Item]) }
  34. Copyright © ZOZO Technologies, Inc. All Rights Reserved. *OUFSBDUPSͷ࣮૷ class

    ItemsInteractor : ItemsInteractorInput { weak var output: ItemsInteractorOutput! func fetchItems() { // σʔλऔಘॲཧ self.output.itemsFetched(items: []) } }
  35. Copyright © ZOZO Technologies, Inc. All Rights Reserved. 7*1&3ʹ͸ΊΔ View

    Entity Presenter Routing Interactor σʔλऔಘͰ͖ͨΑ σʔλऔಘͰ͖͔ͨΒදࣔͯ͠ ஌͍ͬͯΔ viewDidload σʔλऔಘ ͓ئ͍ʂ ListViewController Item ϏϡʔϩδοΫ ΞϓϦέʔγϣϯ ϩδοΫ ը໘ભҠ DataStore σʔλऔಘ ࢀߟ: https://cheesecakelabs.com/blog/ios-project-architecture-using-viper/ อ༗ View Presenter σʔλऔಘͰ͖͔ͨΒදࣔͯ͠ viewDidload ListViewController ϏϡʔϩδοΫ
  36. Copyright © ZOZO Technologies, Inc. All Rights Reserved. 7JFXͷ࣮૷ protocol

    ItemListViewInterface: class { func showItems(items: [Item]) }
  37. Copyright © ZOZO Technologies, Inc. All Rights Reserved. 1SFTFOUFSͷ࣮૷ class

    ItemsPresenter : ItemsModuleInterface, ItemsInteractorOutput { weak var view: ItemsViewInterface! var interactor: ItemsInteractorInput! func updateView() { self.interactor.fetchItems() } func itemsFetched(items: [Item]) { self.view.showItems(items: items) } }
  38. Copyright © ZOZO Technologies, Inc. All Rights Reserved. 7JFXͷ࣮૷ class

    ItemListViewController : UIViewController, ItemsViewInterface { var presenter: ItemsModuleInterface! var list: [Item] = [] override func viewDidLoad() { super.viewDidLoad() self.presenter.updateView() } func showItems(items: [Item]) { self.list = items //ɹදࣔߋ৽ } }
  39. Copyright © ZOZO Technologies, Inc. All Rights Reserved. 7*1&3ʹ͸ΊΔ View

    Entity Presenter Routing Interactor σʔλऔಘͰ͖ͨΑ σʔλऔಘͰ͖͔ͨΒදࣔͯ͠ ஌͍ͬͯΔ viewDidload σʔλऔಘ ͓ئ͍ʂ ListViewController Item ϏϡʔϩδοΫ ΞϓϦέʔγϣϯ ϩδοΫ ը໘ભҠ DataStore σʔλऔಘ ࢀߟ: https://cheesecakelabs.com/blog/ios-project-architecture-using-viper/ อ༗ Routing ը໘ભҠ Presenter ϏϡʔϩδοΫ
  40. Copyright © ZOZO Technologies, Inc. All Rights Reserved. 3PVUFSͷ࣮૷ protocol

    ItemsRouterInput { func presentDetailsInterfaceForItem(id: Int) }
  41. Copyright © ZOZO Technologies, Inc. All Rights Reserved. 3PVUFSͷ࣮૷ class

    ItemsRouter : NSObject, ItemsRouterInput { static func assembleModule() -> UIViewController { let view = UIStoryboard(name: "ItemListViewController", bundle: nil).instantiateInitialViewController() as! ItemListViewController let presenter = ItemsPresenter() let interactor = ItemsInteractor() let router = ItemsRouter() view.presenter = presenter presenter.view = view presenter.interactor = interactor presenter.router = router interactor.output = presenter router.viewController = view return UINavigationController(rootViewController: view) } func presentDetailsInterfaceForItem(id: Int) { // ը໘ભҠॲཧ } }
  42. Copyright © ZOZO Technologies, Inc. All Rights Reserved. 1SFTFOUFSͷ࣮૷ protocol

    ItemsModuleInterface: class { func updateView() func showDetailsForItem(id: Int) }
  43. Copyright © ZOZO Technologies, Inc. All Rights Reserved. 1SFTFOUFSͷ࣮૷ class

    ItemsPresenter : ItemsModuleInterface, ItemsInteractorOutput { weak var view: ItemsViewInterface! var interactor: ItemsInteractorInput! var router: ItemsRouter! func updateView() { self.interactor.fetchItems() } func itemsFetched(items: [Item]) { self.view.showItems(items: items) } func showDetailsForItem(id: Int) { self.router.presentDetailsInterfaceForItem(id: id) } }
  44. Copyright © ZOZO Technologies, Inc. All Rights Reserved. ϝϦοτ ‣୯Ұ੹೚

    ‣ॲཧ͕໌֬ ‣࢓༷ͷมߋʹڧ͍ ‣ґଘ͕௿͍ ‣ϝϯόʔ͕૿͑ͨͱͯ͠΋࣮૷͠΍͍͢ ‣ίϯϑϦΫτ͕গͳ͍ ‣ςετ͕ॻ͖΍͍͢ ‣6*ͱϩδοΫ͕෼͔ΕΔ
  45. Copyright © ZOZO Technologies, Inc. All Rights Reserved. σϝϦοτ ‣ϑΝΠϧ਺͕ଟ͍

    ‣খ͍͞ϓϩδΣΫτʹ͸޲͔ͳ͍ ‣ΦʔόʔεϖοΫ ‣ෑډ͕ߴ͍
  46. Copyright © ZOZO Technologies, Inc. All Rights Reserved. ࢀߟهࣄ ‣"SDIJUFDUJOHJ04"QQTXJUI7*1&3

    ‣J041SPKFDU"SDIJUFDUVSF6TJOH7*1&3 ‣J04ΞϓϦઃܭύλʔϯೖ໳ ‣෼ͰৼΓฦΔιϑτ΢ΣΞΞʔΩςΫνϟͷྺ࢙