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

ゼロイチフェーズからのCleanArchitecture/ios_ca

dotrikun
January 21, 2020

 ゼロイチフェーズからのCleanArchitecture/ios_ca

dotrikun

January 21, 2020
Tweet

More Decks by dotrikun

Other Decks in Programming

Transcript

  1. Copyright (C) 2018 DeNA Co.,Ltd. All Rights Reserved. Copyright (C)

    2020 DeNA Co.,Ltd. All Rights Reserved. θϩΠνϑΣʔζ͔Βͷ Clean Architecture iOS Clean Architecture ษڧձ January 21, 2020 Hiroshi Shikata Healthcare
 DeNA Co., Ltd. 1
  2. Copyright (C) 2020 DeNA Co.,Ltd. All Rights Reserved. ࣗݾ঺հ ▪

    ࢛ํɹ༟ ▪ 2018೥6݄ Sansan → DeNA ▪ DeNAͷϔϧεέΞࣄۀ෦Ͱ৽نαʔϏε։ൃΛ୲౰ ▪ DeNAʹೖࣾͯ͠1೥൒Ͱ15kg૫ͤ·ͨ͠ ▪ ৄ͘͠͸ DeNA TechCon 2020 Ͱ࿩͠·͢ ▪ 2020/03/04 Wed. @ ौ୩ώΧϦΤ 2
  3. Copyright (C) 2020 DeNA Co.,Ltd. All Rights Reserved. ϔϧεέΞͷ৽نαʔϏε։ൃ ▪

    1೥൒ͰϔϧεέΞؔ࿈ΞϓϦ3ຊΛ৽ن։ൃ ▪ ͍ͣΕ΋ඇClean Architecture ▪ ͏ͪҰຊ͸͓ଂೖΓ ▪ ݱࡏ͸4ຊ໨ͷΞϓϦΛ։ൃத ▪ Clean ArchitectureΛ࠾༻ 4
  4. Copyright (C) 2020 DeNA Co.,Ltd. All Rights Reserved. ϓϩδΣΫτ ▪

    ։ൃظؒ ▪ 2ʙ10ϲ݄ ▪ ։ൃظؒʹ͸༨༟͕͋Δ͕ɺ࣮ࡍʹ࡞ͬͯΈͯݫͦ͠͏ͳΒଧͪ੾Δ͜ͱ΋ ▪ ςετظؒͳͲ͸ผϓϩδΣΫτͷ։ൃ΋ฒ૸ ▪ ։ൃମ੍ ▪ ΞϓϦ1໊ɺόοΫΤϯυ2໊ ▪ ਓͷग़ೖΓ ▪ ͨ·ʹԉ܉͕ૹΒΕͯ͘ΔʢϨϕϧײ·ͪ·ͪʣ 5
  5. Copyright (C) 2020 DeNA Co.,Ltd. All Rights Reserved. App ϓϩδΣΫτߏ੒

    7 Classes/ UI/ViewControllers/ Embedded Framework Entity/ AccessToken.swift UseCase/ InterfaceAdapter/ Framework_Driver/ DataStore/ WebClient/ AppDelegate.swift DomainLayerDependency.swift AppRoot/ Login/ AppRootViewController.swift UI/Components/ UI/Protocols/ LoginViewController.swift LoginViewModel.swift LoginViewRouter.swift AccessToken.swift AuthUseCase.swift AuthGateWay.swift KeychainDataStore.swift AuthWebAPI.swift
  6. Copyright (C) 2020 DeNA Co.,Ltd. All Rights Reserved. App ϓϩδΣΫτߏ੒

    8 Classes/ UI/ViewControllers/ Embedded Framework Entity/ AccessToken.swift UseCase/ InterfaceAdapter/ Framework_Driver/ DataStore/ WebClient/ AppDelegate.swift LayerDependency.swift AppRoot/ Login/ AppRootViewController.swift UI/Components/ UI/Protocols/ LoginViewController.swift LoginViewModel.swift LoginViewRouter.swift AccessToken.swift AuthUseCase.swift AuthGateWay.swift KeychainDataStore.swift AuthWebAPI.swift ϓϨθϯςʔγϣϯ υϝΠϯ
  7. Copyright (C) 2020 DeNA Co.,Ltd. All Rights Reserved. App ϓϩδΣΫτߏ੒

    9 Classes/ UI/ViewControllers/ AppDelegate.swift DomainLayerDependency.swift AppRoot/ Login/ AppRootViewController.swift UI/Components/ UI/Protocols/ LoginViewController.swift LoginViewModel.swift LoginViewRouter.swift UseCaseͷΠϯελϯεΛอ࣋͢Δ Singleton
  8. Copyright (C) 2020 DeNA Co.,Ltd. All Rights Reserved. App ϓϩδΣΫτߏ੒

    10 Classes/ UI/ViewControllers/ AppDelegate.swift DomainLayerDependency.swift AppRoot/ Login/ AppRootViewController.swift UI/Components/ UI/Protocols/ LoginViewController.swift LoginViewModel.swift LoginViewRouter.swift • UIWindowͷrootViewController • εϓϥογϡ/΢ΥʔΫεϧʔͳͲφϏήʔ γϣϯͷى఺ΛchildViewControllerͱͯ͠อ࣋ &੾Γସ͑
  9. Copyright (C) 2020 DeNA Co.,Ltd. All Rights Reserved. App ϓϩδΣΫτߏ੒

    11 Classes/ UI/ViewControllers/ AppDelegate.swift DomainLayerDependency.swift AppRoot/ Login/ AppRootViewController.swift UI/Components/ UI/Protocols/ LoginViewController.swift LoginViewModel.swift LoginViewRouter.swift
  10. Copyright (C) 2020 DeNA Co.,Ltd. All Rights Reserved. TransitionProtocol 13

    ը໘ભҠ͕ൃੜ͢Δ਌ViewControllerʹ࣋ͨͤΔΠϯλʔϑΣʔε ʢProgressΛ͜͜ʹ࣋ͨͤΔ͔͸͔ͳΓ໎ͬͨʣ
  11. Copyright (C) 2020 DeNA Co.,Ltd. All Rights Reserved. App ϓϩδΣΫτߏ੒

    14 Classes/ UI/ViewControllers/ AppDelegate.swift DomainLayerDependency.swift AppRoot/ Login/ AppRootViewController.swift UI/Components/ UI/Protocols/ LoginViewController.swift LoginViewModel.swift LoginViewRouter.swift • ViewController͔ΒUseCaseͷΠϯελϯεΛड ͚औΔ • υϝΠϯϩδοΫͱͷ઀఺
  12. Copyright (C) 2020 DeNA Co.,Ltd. All Rights Reserved. ϓϩδΣΫτߏ੒ 15

    Embedded Framework Entity/ AccessToken.swift UseCase/ InterfaceAdapter/ Framework_Driver/ DataStore/ WebClient/ AccessToken.swift AuthUseCase.swift AuthGateWay.swift KeychainDataStore.swift AuthWebAPI.swift • ϓϨθϯςʔγϣϯͱͷ઀఺
  13. Copyright (C) 2020 DeNA Co.,Ltd. All Rights Reserved. ϓϩδΣΫτߏ੒ 16

    Embedded Framework Entity/ AccessToken.swift UseCase/ InterfaceAdapter/ Framework_Driver/ DataStore/ WebClient/ AccessToken.swift AuthUseCase.swift AuthGateWay.swift KeychainDataStore.swift AuthWebAPI.swift • UseCase͔Βެ։͞Εͨprotocolͷ࣮૷ • ௨৴ͱσʔλͷ֨ೲΛ࣮ࡍʹߦ͏
  14. Copyright (C) 2020 DeNA Co.,Ltd. All Rights Reserved. ϓϩδΣΫτߏ੒ 17

    Embedded Framework Entity/ AccessToken.swift UseCase/ InterfaceAdapter/ Framework_Driver/ DataStore/ WebClient/ AccessToken.swift AuthUseCase.swift AuthGateWay.swift KeychainDataStore.swift AuthWebAPI.swift • GateWay͔Βެ։͞Εͨprotocolͷ࣮૷ • σʔλͷऔಘ΍֨ೲͷΈΛߦ͏
  15. Copyright (C) 2020 DeNA Co.,Ltd. All Rights Reserved. 18 Clean

    Architecture & Embedded Framework Λ࢖͏ϝϦοτ
  16. Copyright (C) 2020 DeNA Co.,Ltd. All Rights Reserved. ։ൃࢹ఺ͰͷϝϦοτ ▪

    ૄ݁߹ ▪ Ͳ͜ʹͳʹ͕࣮૷͞Ε͍ͯΔ͔͕ࣗ໌ʹͳΔ ▪ DIͰϩδοΫͷࠩ͠ସ͕͑༰қʹͳΔ ▪ ϓϩτλΠϐϯά΍ಈ࡞֬ೝͷදࣔσʔλग़͠෼͚ ▪ ϝϯόʔͷೖΕସΘΓ ▪ ϝϯόʔͷεΩϧϨϕϧʹ߹Θ࣮ͤͯ૷ΛϨΠϠʔ୯ҐͰ෼୲Ͱ͖Δ ▪ iOSʹशख़͍ͯ͠ͳͯ͘΋UI͚ͩɺϏδωεϩδοΫ͚ͩ੾Γग़ͤΔ ▪ iOSʹशख़͍ͯ͠Δਓ͸ΩϟονΞοϓָ͕ʹͳΔ 20
  17. Copyright (C) 2020 DeNA Co.,Ltd. All Rights Reserved. ϔϧεέΞϓϩμΫτࢹ఺ͰͷϝϦοτ 22

    APP Show App Watch Extension ΍ Widget΁ͷରԠָ͕ʹͳΔ Embedded Framework ✘ ✔
  18. Copyright (C) 2020 DeNA Co.,Ltd. All Rights Reserved. ࣄۀࢹ఺ͰͷϝϦοτ ݈߁ߦಈ

    × ސ٬૚Ͱෳ਺ͷαʔϏεΛ࡞͍ͬͯΔ 24 า͘ ݮྔ ېԎ B2B2C αʔϏεA αʔϏεB αʔϏεC B2C αʔϏεD αʔϏεE ? B2C (ΞϥΠΞϯε) αʔϏεF ? ?
  19. Copyright (C) 2020 DeNA Co.,Ltd. All Rights Reserved. ࣄۀࢹ఺ͰͷϝϦοτ ݈߁ߦಈ

    × ސ٬૚Ͱෳ਺ͷαʔϏεΛ࡞͍ͬͯΔ 25 UI͸ҟͳΔ͕݈߁ߦಈ͝ͱͷϏδωεϩδοΫ͸ࣅ͍ͯΔ า͘ ݮྔ ېԎ B2B2C αʔϏεA αʔϏεB αʔϏεC B2C αʔϏεD αʔϏεE ? B2C (ΞϥΠΞϯε) αʔϏεF ? ? →υϝΠϯϩδοΫΛ੾Γग़͓ͯ͘͜͠ͱͰผϓϩμΫτͰ࠶ར༻Ͱ͖Δ
  20. Copyright (C) 2020 DeNA Co.,Ltd. All Rights Reserved. Embedded Framework

    ͸Ͳ͏෼͚Δʁ 27 Embedded Framework Entity/ UseCase/ InterfaceAdapter/ Framework_Driver/ Embedded Framework (InterfaceAdapter) Embedded Framework (Entity) Embedded Framework (UseCase) Embedded Framework (Framework_Driver) VS
  21. Copyright (C) 2020 DeNA Co.,Ltd. All Rights Reserved. ͳͥ Embedded

    Framework ͕Ұ͚ͭͩͳͷ͔ ▪ νʔϜʹXcodeϓϩδΣΫτઃఆͷख࿅͕͍ͳ͍ͱ٧ΉϦεΫ ▪ XcodeͷTargetઃఆ ▪ ϥΠϒϥϦ௥Ճ ▪ ґଘؔ܎ ▪ Entity <-UseCase <- InterfaceAdapter <- Framework/Driver ▪ ͋ͱ͔Β෼ׂͰ͖ͳ͘͸ͳ͍ 28
  22. Copyright (C) 2020 DeNA Co.,Ltd. All Rights Reserved. ʰٕज़త౤ࢿʱͱͯ͠Ϧλʔϯ͕ݟࠐΊΔͳΒ͋ΓͰ͸ ▪

    ϔϧεέΞͷ৔߹͸Ϧλʔϯ͕ݟࠐΊͦ͏ˍֶशίετΛڐ༰Ͱ͖ͦ͏ͳͷͰಋ ೖͨ͠ ▪ ελʔτΞοϓ΍ϕϯνϟʔͳͲখن໛or୹ظϓϩδΣΫτͩͱݫͦ͠͏ ▪ ࣄۀ/ϓϩμΫτ/։ൃͷࢹ఺ͰϦιʔεΛ౤ࢿ͢΂͖͔ͷ൑அΛ 31