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

OK、理想のアーキテクチャは分かった。で、どこから手をつけんの?

704056da9a4c4e075ad14479beaebab7?s=47 takasek
January 24, 2017

 OK、理想のアーキテクチャは分かった。で、どこから手をつけんの?

答え.
framework化によるPresentation Domain Separation。

iOS Creators' Meetup vol.3 - connpass
https://oi-study.connpass.com/event/48050/
での発表資料です。

---

# 参考リンク

Speeding up Xcode Builds – Zalando Tech Blog
https://tech.zalando.com/blog/speeding-up-xcode-builds/

iOS 9でアップデート後にアプリが起動できなくなる問題の原因と解決方法 - inFablic
http://in.fablic.co.jp/entry/2016/06/09/150000

iOS Clean Architecture - 騒音のない世界 BLOG
http://noiselessworld.hatenablog.jp/entry/ios-clean-architecture

ヘキサゴナルアーキテクチャ(Hexagonal architecture翻訳)
http://blog.tai2.net/hexagonal_architexture.html

プレゼンテーションとドメインの分離
http://bliki-ja.github.io/PresentationDomainSeparation/

704056da9a4c4e075ad14479beaebab7?s=128

takasek

January 24, 2017
Tweet

Transcript

  1. OKɺཧ૝ͷΞʔΩςΫνϟ ͸෼͔ͬͨɻͰɺͲ͔͜Β खΛ͚ͭΜͷʁ by takasek 2017/1/24 iOS Creators' Meetup vol.3

    1
  2. 2

  3. 3

  4. FiNCΞϓϦɺࠓ݄ΑΓট଴੍Ͱ ެ։த 4

  5. !ଟػೳ! 5

  6. 4 େྔͷϑΝΠϧͰϏϧυ͕ॏ͍ 4 ઃܭ͕ෳࡶ 4 ࢓༷มߋ࣌ͷӨڹ΋େ͖͍ ͱ͍͏Θ͚ͰνʔϜҰؙͱͳͬͯɺ ΞʔΩςΫνϟʹ͍ͭͯࢼߦࡨޡ͍ͯ͠ΔࡢࠓͰ ͢ 6

  7. ࠷ۙͷiOSք۾ ΞʔΩςΫνϟ͕࿩୊Ͱ͢ ΫϦʔϯΞʔΩςΫνϟͱ͔ 7

  8. ͳΔ΄Ͳ ϨΠϠʔΛ෼ׂͯ͠ ந৅ʹґଘͯ͠ ςετͷ༰қੑΛߴΊͯ ;Μ;Μ 8

  9. ࣍ͷϓϩδΣΫτͰ͸ ద༻ͯ͠ΈΑ͏͔ͳ͊ 9

  10. …ɻ 10

  11. !ࠓ։ൃͯ͠ΔΞϓϦͷɺ ͜ͷFat ViewControllerΛ Ͳ͏͢Ε͹͍͍Μͩʁ …ͱ͓ࢥ͍ͷوํ΁ɻ 11

  12. OKɺཧ૝ͷΞʔΩςΫνϟ ͸෼͔ͬͨɻͰɺͲ͔͜Β खΛ͚ͭΜͷʁ by takasek 2017/1/24 iOS Creators' Meetup vol.3

    12
  13. 13

  14. 14

  15. iOS Clean Architecture - ૽Իͷͳ͍ੈք BLOG http://noiselessworld.hatenablog.jp/entry/ios- clean-architecture 15

  16. ୯ํ޲ґଘΛ ແཧͳ͘ڧ੍ͤͭͭ͞ ࠓͷΞϓϦͷઃܭΛ վળ͢ΔͨΊʹ 16

  17. ֤૚ͷ frameworkԽ! 17

  18. frameworkͷ੾Γ෼͚ 4 ԣ࣠ʢػೳʣ 4 ϥΠϒϥϦͷframework͸͜ΕͰ͢ΑͶ 4 ΞϓϦ಺ͷػೳͰɺଞͱಠཱੑͷߴ͍ίϯϙʔωϯ τ͸࠷ॳ͔Βԣ࣠ͰframeworkԽ͠ͱ͘ͷ΋͋Γ 4 ॎ࣠ʢΞʔΩςΫνϟͷϨΠϠʔʣ

    4 ࠓճ࿩͢΋ͷ 4 ୯ํ޲ґଘ 18
  19. framework׆༻ͷϝϦοτ 4 ΞΫηείϯτϩʔϧΛ׆༻ 4 ࠷খݶͷΠϯλϑΣʔε͚͕ͩݟ͑ͯ҆શˍ ೴ʹ༏͍͠ 4 ґଘ͢ΔՕॴʹ͸ඞͣimport͕ඞཁ 4 Ϗϧυલʹґଘؔ܎

    4 ૬ޓґଘͰ͖ͳ͍࡞ΓΛڧ੍Ͱ͖Δ 4 Ϗϧυ࣌ؒ΋ݮΔ 19
  20. Speeding up Xcode Builds – Zalando Tech Blog https://tech.zalando.com/blog/speeding-up-xcode-builds/ Ϗϧυ͸ର৅ʹରͯ͠O(n^2)ͷॲཧͬΆ͍

    ͭ·ΓϑΝΠϧͷ൒෼ΛผϑϨʔϜϫʔΫʹҠͤ͹ɺϏϧυ࣌ؒ͸1/4ʹʂ 20
  21. !ʮframeworkΛ ෼͚͗͢Δͱ໰୊͋Δ ͬͯฉ͍ͨΑ͏ͳʯ 21

  22. framework͕ଟ͍ͱىಈ࣌ʹམͪ Δ໰୊ iOS 9ͰΞοϓσʔτޙʹΞϓϦ͕ىಈͰ͖ͳ͘ͳΔ໰ ୊ͷݪҼͱղܾํ๏ - inFablic http://in.fablic.co.jp/entry/2016/06/09/150000 4 iOS9.3.2Ͱमਖ਼ࡁ

    4 Ϣʔβʔͷ࢖༻୺຤ͷOSόʔδϣϯͱ૬ஊʁ 4 Ͱ΋ංେԽͨ͠ΞϓϦΛ਺ݸͷframeworkʹ෼཭͢ Δ͘Β͍ͳΒɺผʹଛ͸ͳ͍Μ͡Όͳ͍ʁ 22
  23. framework ෼ׂͷखॱ 23

  24. framework ෼ׂͷखॱ …Λ࿩͢લʹ 24

  25. ϔΩαΰφϧ ΞʔΩςΫνϟ ͷ࿩ 25

  26. !ʢ·ͨ৽͍͠ ΞʔΩςΫνϟͷ໊લ ग़͖ͯͨʣ 26

  27. ා͕Βͳ͍͍ͯ͘Α! 27

  28. ϔΩαΰφϧΞʔΩςΫνϟͱ͸1 1 ϔΩαΰφϧΞʔΩςΫνϟ(Hexagonal architecture຋༁) http://blog.tai2.net/hexagonal_architexture.html 28

  29. 4 ΫϦʔϯΞʔΩςΫνϟͷΠϯεύΠΞݩͷͻͱͭ 4 ؙ͕࿡֯ܗʹͳͬͯΔ͚ͩʢͳ͓6ͱ͍͏਺ࣈʹҙຯ͸ͳ͍ʣ 4 ֤ลΛʮϙʔτʯͱ͍͏ 4 ʮϙʔτʯʹʮΞμϓλʯΛࠩ͠ସ͑Δ 4 ʮ಺ଆ΁ͷґଘʯͱ͍͏ίϯηϓτ͸ಉ͡

    29
  30. ϔΩαΰφϧΞʔΩςΫνϟ͸ɺ Applicationͷ֎͕ϙʔτͰ۠੾ΒΕͯΔ 30

  31. Fat ViewControllerͬͯͷ͸ͭ·Γ 31

  32. ΰʔϧ: ֤ϙʔτͷframeworkԽ 32

  33. ·ͣҰา໨͸ɺ͜͏ 33

  34. Presentation Domain Separation 34

  35. Presentation Domain Separation(PDS) Presentation૚ʹؔ৺͕͋Δͷ͸ Presentation૚͚ͩ ͦΕҎ֎ΛɺڊେͳDomain Modelͱͯ͠ frameworkʹ੾Γग़͢ 35

  36. PDSͰ͖ͨΒɺ 36

  37. PDSͰ͖ͨΒɺଞͷϙʔτ΋… 37

  38. …෼ׂͯ͠ɺ׬੒ʂ 38

  39. ͬ͘͟Γ෼͚ͨ Model.frameworkͷத͸ ಉ͡खॱͰɺ͞Βʹ༰қʹ ࡉ෼ԽͰ͖Δ͸ͣ 39

  40. PDSͷࡉ͔͍खॱ 4 ຤୺(EntityͬΆ͍΋ͷ)͔ΒঃʑʹखΛ͚ͭɺ͡Θ͡Θ ͱModel.frameworkͷྖ౔Λ޿͍͛ͯ͘ 4 ࠷௿ݶͷpublic/openΞΫηείϯτϩʔϧ͚ͩ֎ʹެ։ 4 ࠷ॳ͔Βࡉ͔͘෼͚͗͢ͳ͍ 4 EntityͱUseCaseͱ͔ɺσʔλΞΫηε૚ͱ͔ɺࡉ͔

    ͍͜ͱ͸ߟ͑ͳ͍ 4 !ͨͩɺ໌Β͔ʹDomainʹґଘ͠ͳ͍Utilityతͳ΋ ͷ͸ɺผframeworkͰ͍͍ͷͰ͸ 40
  41. frameworkʹҠ͠ऴΘͬͨΒ 4 ෆཁʹͳͬͨpublicΞΫηείϯτϩʔϧΛక Ί෇͚Δ 4 ফͯ͠ϏϧυΤϥʔʹͳΔ͔Ͳ͏͔Ͱ൑அ Ͱ͖ΔͷͰࢥߟఀࢭ͠ͳ͕Β࡞ۀͰ͖Δ 41

  42. ى͖͕ͪͳ໰୊ᶃ !ʮॲཧ͕ࠞ͟Γ߹ͬͯͯCore ͔ΒframeworkʹҠͤͳ ͍…ʯ 4 = ີ݁߹ 4 ઃܭ͕Α͘ͳ͍ͱؾ෇͚ͨʂ 4

    ܕΛ෼ׂ͠ɺదٓ੾Γ෼͚Δ 4 ӨڹεέονΛඳ͘ ʢʮϨΨγʔίʔυվળ ΨΠυʯP194ʣ 42
  43. ى͖͕ͪͳ໰୊ᶄ Domain Modelͷ෼ׂΑΓલʹ ϙʔτͷ෼ׂʹखΛ͚ͭͯ͠· ͏ͱةͳ͍ ґଘํ޲: 4 ΞϓϦຊମ ! ϙʔτ

    4 ϙʔτ !❌ ΞϓϦຊମ ϙʔτ͕ɺ·ͩDomain Model ͷframeworkʹҠߦͰ͖͍ͯ ͳ͍ίʔυʹґଘͯ͠͠·ͬͨ ৔߹ɺಈ͚ͳ͘ͳΔ 43
  44. ͦΜͳ͔Μ͡Ͱ frameworkΛ׆༻ͯ͠ɺϞδϡʔϧԽ͞Εͨઃ ܭΛखʹೖΕ·͠ΐ͏ ! 44

  45. ࢀߟϦϯΫ Speeding up Xcode Builds – Zalando Tech Blog https://tech.zalando.com/blog/speeding-up-xcode-builds/

    iOS 9ͰΞοϓσʔτޙʹΞϓϦ͕ىಈͰ͖ͳ͘ͳΔ໰୊ͷݪҼͱղܾํ๏ - inFablic http://in.fablic.co.jp/entry/2016/06/09/150000 iOS Clean Architecture - ૽Իͷͳ͍ੈք BLOG http://noiselessworld.hatenablog.jp/entry/ios-clean-architecture ϔΩαΰφϧΞʔΩςΫνϟ(Hexagonal architecture຋༁) http://blog.tai2.net/hexagonal_architexture.html 45