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

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

878cf5e0f8e3284f06c8968e961cecd4?s=47 dotrikun
January 21, 2020

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

878cf5e0f8e3284f06c8968e961cecd4?s=128

dotrikun

January 21, 2020
Tweet

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. 3 ৽نαʔϏε։ൃͷ࿩

  4. Copyright (C) 2020 DeNA Co.,Ltd. All Rights Reserved. ϔϧεέΞͷ৽نαʔϏε։ൃ ▪

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

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

  7. 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
  8. 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 ϓϨθϯςʔγϣϯ υϝΠϯ
  9. 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
  10. 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ͱͯ͠อ࣋ &੾Γସ͑
  11. 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
  12. Copyright (C) 2020 DeNA Co.,Ltd. All Rights Reserved. Router 12

    ը໘͔Βൃੜ͢Δը໘ભҠΛఆٛ
  13. Copyright (C) 2020 DeNA Co.,Ltd. All Rights Reserved. TransitionProtocol 13

    ը໘ભҠ͕ൃੜ͢Δ਌ViewControllerʹ࣋ͨͤΔΠϯλʔϑΣʔε ʢProgressΛ͜͜ʹ࣋ͨͤΔ͔͸͔ͳΓ໎ͬͨʣ
  14. 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ͷΠϯελϯεΛड ͚औΔ • υϝΠϯϩδοΫͱͷ઀఺
  15. 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 • ϓϨθϯςʔγϣϯͱͷ઀఺
  16. 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ͷ࣮૷ • ௨৴ͱσʔλͷ֨ೲΛ࣮ࡍʹߦ͏
  17. 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ͷ࣮૷ • σʔλͷऔಘ΍֨ೲͷΈΛߦ͏
  18. Copyright (C) 2020 DeNA Co.,Ltd. All Rights Reserved. 18 Clean

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

  20. Copyright (C) 2020 DeNA Co.,Ltd. All Rights Reserved. ։ൃࢹ఺ͰͷϝϦοτ ▪

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

  22. Copyright (C) 2020 DeNA Co.,Ltd. All Rights Reserved. ϔϧεέΞϓϩμΫτࢹ఺ͰͷϝϦοτ 22

    APP Show App Watch Extension ΍ Widget΁ͷରԠָ͕ʹͳΔ Embedded Framework ✘ ✔
  23. Copyright (C) 2020 DeNA Co.,Ltd. All Rights Reserved. 23 ࣄۀࢹ఺

  24. Copyright (C) 2020 DeNA Co.,Ltd. All Rights Reserved. ࣄۀࢹ఺ͰͷϝϦοτ ݈߁ߦಈ

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

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

    Framework ͷ෼ׂʹ͍ͭͯ
  27. 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
  28. Copyright (C) 2020 DeNA Co.,Ltd. All Rights Reserved. ͳͥ Embedded

    Framework ͕Ұ͚ͭͩͳͷ͔ ▪ νʔϜʹXcodeϓϩδΣΫτઃఆͷख࿅͕͍ͳ͍ͱ٧ΉϦεΫ ▪ XcodeͷTargetઃఆ ▪ ϥΠϒϥϦ௥Ճ ▪ ґଘؔ܎ ▪ Entity <-UseCase <- InterfaceAdapter <- Framework/Driver ▪ ͋ͱ͔Β෼ׂͰ͖ͳ͘͸ͳ͍ 28
  29. Copyright (C) 2020 DeNA Co.,Ltd. All Rights Reserved. 29 ·ͱΊ

  30. Copyright (C) 2020 DeNA Co.,Ltd. All Rights Reserved. 30 θϩΠνϑΣʔζ͔ΒClean

    ArchitectureΛಋೖ͢Δ
  31. Copyright (C) 2020 DeNA Co.,Ltd. All Rights Reserved. ʰٕज़త౤ࢿʱͱͯ͠Ϧλʔϯ͕ݟࠐΊΔͳΒ͋ΓͰ͸ ▪

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