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

10分で振り返るソフトウェアアーキテクチャの歴史2017

 10分で振り返るソフトウェアアーキテクチャの歴史2017

CAMPFIRE iOS #1 - connpass
https://yj-meetup.connpass.com/event/51735/

での発表資料です。

(2017/3/23追記):
各所からいただいたフィードバックに基づき、不正確な記述を修正しました。(Nyohoさん、あんざいゆきさん、かとじゅんさん、ありがとうございます)
また、参考リンク集を追加しました。

## 参考リンク

■ MVC Pattern
http://heim.ifi.uio.no/~trygver/2003/javazone-jaoo/MVC_pattern.pdf
■ Understanding JavaServer Pages Model 2 architecture | JavaWorld
http://www.javaworld.com/article/2076557/java-web-development/understanding-javaserver-pages-model-2-architecture.html
■ The DCI Architecture: A New Vision of Object-Oriented Programming
http://www.artima.com/articles/dci_vision.html
■ PHP Mentors -> Beyond MVC
http://phpmentors.jp/post/69076928673/beyond-mvc
■ Model-View-Controller
https://developer.apple.com/library/content/documentation/General/Conceptual/DevPedia-CocoaCore/MVC.html
■ Martin Fowler: eaaDev
https://martinfowler.com/eaaDev/
■ GUI Architectures
https://www.martinfowler.com/eaaDev/uiArchs.html#Model-view-presentermvp
■ THE MODEL-VIEW-VIEWMODEL (MVVM) DESIGN PATTERN FOR WPF
https://msdn.microsoft.com/ja-jp/magazine/dd419663.aspx
■ Flux | Application Architecture for Building User Interfaces
http://facebook.github.io/flux/docs/in-depth-overview.html#structure-and-data-flow
■ Alistair.Cockburn.us | Hexagonal architecture
http://alistair.cockburn.us/Hexagonal+architecture
■ The Onion Architecture : part 1 : Jeffrey Palermo (.com)
http://jeffreypalermo.com/blog/the-onion-architecture-part-1/
■ The Clean Architecture | 8th Light
https://8thlight.com/blog/uncle-bob/2012/08/13/the-clean-architecture.html
■ Onion Architecture と Clean Architecture - 騒音のない世界 BLOG
http://noiselessworld.hatenablog.jp/entry/2016/12/31/231632
■ Introduction to VIPER - Mutual Mobile Engineering Blog
http://web.archive.org/web/20160111142228/http://mutualmobile.github.io/blog/2013/12/04/viper-introduction
■ MVVM-C In Practice // Speaker Deck
https://speakerdeck.com/macdevnet/mvvm-c-in-practice
■ Minimum Viable Architecture -- Good Enough is Good Enough in a Startup
https://www.slideshare.net/RandyShoup/minimum-viable-architecture-good-enough-is-good-enough-in-a-startup

704056da9a4c4e075ad14479beaebab7?s=128

takasek

March 16, 2017
Tweet

Transcript

  1. 10෼ͰৼΓฦΔ ιϑτ΢ΣΞΞʔΩςΫ νϟ ͷྺ࢙2017 by takasek 2017/3/16 CAMPFIRE iOS #1

    1
  2. ͸͡Ίʹ ʢ2017/3/23 Ճචʣ ͜Ε͸ɺiOSΤϯδχΞ͕Α͘৮ΕΔɺओʹ GUIΞϓϦͷΞʔΩςΫνϟΛओ؟ʹஔ͍ͨ ൃදͰ͢ɻ 2

  3. MVC, MVP, MVVM, Layered Architecture, Clean Architecture, VIPER, Flux, Redux,

    DDD, MVA, …????? 3
  4. !" 4

  5. ·ͣɺ֓೦ͷ੔ཧ ! GUI Architectures ɹ … MVC, MVP, MVVM, etc

    • ViewͱModel(=ϏδωεϩδοΫ)ͷ෼཭ • ର৅: αϒγεςϜ • ModelΑΓԞଆ͸஌ΒΜ ! System Architectures ɹ … Layered Architecture, ɹɹ Clean Architecture, ɹɹ VIPER, etc • ର৅: γεςϜશମ 5
  6. GUI Architectures 6

  7. GUI Architectures ᶃ MVC Model-View- Controller (1979-) ΈΜͳ஌ͬͯΔ͚ͲɺΈΜͳޡղͯ͠Δɻ 7

  8. MVC: Model-View- Controller(1979-) Smalltalk։ൃऀͷͻͱΓ Reenskaug͕ߟҊ C: Ϣʔβʔૢ࡞Λड͚ M: σʔλΛมߋ V:

    MͷมߋΛobserve 8
  9. MVC: Model-View- Controller(1979-) ΁ʔʂ M→V͸ observerύλʔϯ ʢ1ݸͷMͷมߋΛ ɹnݸͷVʹ఻͑ΔͨΊʣ …ͩͬͨΜͩͶʁ 9

  10. "MVC͸ਓؒͱͦͷϝϯλϧϞσϧʹؔ͢Δ ΋ͷͰ͋ΓɺΦϒβʔόύλʔϯʹؔ͢Δ΋ ͷͰ͸ͳ͍ɻ" -- The DCI Architecture (Reenskaug and O.

    Coplien, 2009, ࿨ஐӈܡ(༁)) 10
  11. MVC͕ຊ౰ʹ΍Γ͔ͨͬͨ͜ͱ "ΑΓਂ͍ࢹ఺͔ΒݟΕ͹ɺ͜ͷϑϨʔϜϫʔΫ͸ ϢʔβΠϯλϥΫγϣϯ͔Β৘ใͷද৅Λ෼཭͢Δ ͨΊʹଘࡏ͍ͯ͠Δɻ" "Ϟσϧ-Ϗϡʔ-ίϯτϩʔϥ-ϢʔβΛཁ໿͢Ε ͹ɺίϯϐϡʔλͱਓؒͷΠϯλϥΫγϣϯʹ͓͚ Δࢥߟʢ"thinking"ʣͷ෦෼Λࢧ͑Δʹ͸༏Ε͍ͯ Δͷͩɻ" - The

    DCI Architecture (Reenskaug and O. Coplien, 2009, ࿨ஐӈܡ(༁)) 11
  12. MVCʹ଍Γͳ͔ͬͨ͜ͱ "ΦϒδΣΫτࢦ޲ʹ΄ͱΜͲͳ͘ɺMVCʹ͓͍ ͯ͸શ͘ଘࡏ͠ͳ͍͜ͱ͕͋ΔɻͦΕ͸ߦಈΛ ίʔυͰͱΒ͑Δ͜ͱ͕Ͱ͖ΔΑ͏։ൃऀΛॿ͚ Δͱ͍͏͜ͱͩɻΤϯυϢʔβͷ;Δ·্͍ͷཁ ݅ʹ͍ͭͯ࿦ཧతʹߟ͑Δ৔ॴΛɺ։ൃऀ͸࣋ͬ ͍ͯͳ͍ͷͰ͋Δɻ" - The DCI

    Architecture (Reenskaug and O. Coplien, 2009, ࿨ஐӈܡ(༁)) 12
  13. ͪͳΈʹਐԽܗMVCͬΆ͍΋ͷͱͯ͠… DCI(Data-Context-Interaction) Architecture(2009-) • ίϯςΩετ • ϩʔϧ ʹΑΔ;Δ·͍ͷදݱ ͖ͬ͞ͷ࿦จதͰɺReenskaugത͕࢜ޠͬͯͨΜ ͚ͩͲɺলུɻ

    13
  14. ΋͏ͻͱͭ༨ஊͰɺ MVC Model2(1999-) MVCΛJSP(JavaServer Pages)ʹద༻ͨ͠΋ͷ1 Model2Ͱ͸Observerύλʔ ϯ͸࢖ΘΕͳ͍ 1 Understanding JavaServer

    Pages Model 2 architecture | JavaWorld http://www.javaworld.com/article/2076557/ java-web-development/understanding- javaserver-pages-model-2-architecture.html 14
  15. GUI Architectures ᶄ MVP Model-View- Presenter (1990-) ;Δ·͍ͷஔ͖৔Λ୳ͯ͠… 15

  16. MVP(Supervising Controller)(1990-) 16

  17. MVP(Supervising Controller)(1990-) IBMͱAppleڞಉ։ൃͷOS Taligent Ͱ࢖ΘΕͨ ౰ॳͷߏ଄͸ ਓྨʹ͸ෳࡶ͗ͨ͢ͷͰɺ ੔ཧ͞Ε͍ͯͬͨ ! 17

  18. MVP(Supervising Controller) ͷ໰୊఺ ViewͱModel͕ observerύλʔϯͰ ઀ଓ͞Ε͓ͯΓɺ • VɾM͕࠶ར༻ͮ͠Β͍ • ςετ͕ॻ͖ͮΒ͍

    18
  19. MVP (Passive Views) (2006-) MVP(Supervising Controller)ʹର͠ MVP(Passive Views)ͱݺ͹ΕΔ Humble(ݠڏͳ) Dialog

    Box ͱ΋͍͏ ݱ୅ʹೃછΈͷ͋Δ MVPͰ͢Ͷʂ 19
  20. ͱ͜ΖͰɺ MVP(Supervising Controller) ͷ໰୊఺ • VɾM͕࠶ར༻ͮ͠Β͍ • ςετ͕ॻ͖ͮΒ͍ ! V͕MΛobserve…ͬͯ

    Ͳ͔ͬͰฉ͍ͨΑ͏ͳ… 20
  21. ͦ͏Ͱ͢ʂ ࿩͸લޙ͢Δ͚Ͳ ෳ߹ύλʔϯͱͯ͠ͷ MVCʢCocoaʣ ैདྷͷMVCʹ΋ಉ͡໰୊͕͋ͬͨ ͳͷͰɺApple(ḪΕ͹NeXT)͸ ʮվྑܕͷෳ߹ύλʔϯMVCʯ ! Λਪ঑͍ͯ͠Δ •

    V͕MΛobserve͢ΔͷͰ͸ͳ͘ɺ ɹ C͕Mediatorʹ • VɾMΛ׬શʹ෼཭͠ɺ࠶ར༻ੑup https://developer.apple.com/jp/ documentation/CocoaEncyclopedia.pdf 21
  22. ͪͳΈʹMVPͱMVCͷҧ͍ • MVC͸ • ControllerͰinputΛड͚Δ • ViewͱController͸ϦονͳUIͰ͸݁߹͠΍͘͢ɺ Controller͕ViewͷϥΠϑαΠΫϧʹґଘ͢Δ • MVP͸

    • ViewͰinputΛड͚Δ ※Controller͸Viewͱ෼཭ࠔ೉ͳͷͰಉҰࢹ͢Δ • ViewͱPresenter͸෼཭͞Ε͓ͯΓɺ PresenterͷΈͰͷ୯ମςετ΋Մೳ 22
  23. GUI Architectures ᶅ MVVM Model-View- ViewModel (2009-) Windows Presentation Foundationͷ

    σʔλόΠϯσΟϯάػߏΛ׆༻ͯ͠Έͨ 23
  24. MVVM Model-View-ViewModel (2009-) Microsoftൃ঵ WPF(Windows Presentation Foundation) ʢݴޠ࢓༷ϨϕϧͰσʔλόΠϯσΟϯάՄʣ Λલఏͱͨ͠ΞʔΩςΫνϟ 24

  25. GUI Architectures ᶆ Flux (2014-) Facebookͷߟ͑ͨ࠷ڧͷσʔλϑϩʔϞσϧ 25

  26. Flux(2014-) Facebook੡ͷ σʔλϑϩʔϞσϧ Facebook ʮMVC͕ෳࡶʹͳΔݪҼ͸ ɹ૒ํ޲ͷσʔλϑϩʔʯ Flux͸ ୯ํ޲σʔλϑϩʔΛ୲อ 26

  27. GUI Architecturesʹ͍ͭͯ͸ ͱΓ͋͑ͣ͜͜·Ͱ 27

  28. ͓͞Β͍ ! GUI Architectures ɹ … MVC, MVP, MVVM, etc

    • ViewͱModel(=ϏδωεϩδοΫ)ͷ෼཭ • ର৅: αϒγεςϜ • ModelΑΓԞଆ͸஌ΒΜ ! System Architectures ɹ … Layered Architecture, ɹɹ Clean Architecture, ɹɹ VIPER, etc • ର৅: γεςϜશମ ͱ͍͏͜ͱͰޙ൒ઓ… 28
  29. System Architectures 29

  30. System Architectures ᶃ Layered Architecture 30

  31. Layered Architecture • ֤ϨΠϠ͸ࣗ෼ΑΓԼҐ૚ʹґଘ͢Δ • ্Ґ૚ʹରͯ͠͸ૄ݁߹ʹ ૚ͷ۠෼ʹ͸όϦΤʔγϣϯ͋Γ Eric EvansʮDomain Driven

    DesignʯͰ͸ • UI૚ • Application૚ • Domain૚ • Infrastructure૚ ͱ͍͏۠෼͕঺հ͞Ε͍ͯΔ 31
  32. ิ଍: DDD(Domain Driven Design)ͱ Layered Architectureʹ͍ͭ ͯ EvansͷDDDຊͰ͸Layered ArchitectureΛى఺ʹ࿩ΛਐΊ͍ͯ Δ͕ɺDDDͦͷ΋ͷ͸ΞʔΩςΫ

    νϟύλʔϯͰ͸ͳ͍ DDD͸ɺApplication૚ / Infrastructure૚ ͔ΒDomain૚ʹ ͋Δ΂͖ϩδοΫΛ෼཭͠ɺۀ຿஌ࣝ ΍ίϛϡχέʔγϣϯ΋ؚΊ࣮૷ͱҰ க͍ͤͯ͜͞͏ͱ͍͏ϞσϦϯάख๏ ※౰ॳʮDDD͸Layered Architecture͕લఏʯͱॻ͍͓ͯΓ ·͕ͨ͠ɺޠฐͷ͋ΔදݱͰͨ͠ɻ ! 32
  33. System Architectures ᶄ Hexagonal Architecture (2002?-) ʮ࿡֯ܗͷൿີ͸Ͷ̇ …ผʹ਺ࣈʹҙຯ͸ͳ͍ʯ 33

  34. Hexagonal Architecture(2002?-) গͳ͘ͱ΋2002೥Ҏલʹ͸ଘࡏ ಈػ Layered Architectureͷ໰୊఺: • UIͷࣗಈςετͮ͠Β͍ • DB΋Կނ͔ςετͮ͠Β͍

    ղܾࡦ ΞϓϦͱͷ઀߹෦Λϙʔτͱݺͼɺ దٓɺςετ༻ͷΞμϓλΛ ෇͚ସ͑ΒΕΔ࡞Γʹ͢Δ 34
  35. Hexagonal Architecture(2002?-) Ұ࣍ݩͷ૚ͷΞφϩδʔ͔Β ཭ΕΔͨΊɺ ࿡֯ܗͰදݱͯ͠Έ·ͨ͠ 35

  36. System Architectures ᶅ Onion Architecture (2008-) ʮٯʹߟ͑ΔΜͩɻ(૚Λ)্͛ͪΌͬͯ΋͍͍͞ ͱߟ͑ΔΜͩʯ 36

  37. Onion Architecture(2008-) Clear MeasureࣾͷCEO Jeffrey Palermo͕ ϒϩάʹవΊͨ ᐌ͘ ʮLayered Architecture͸

    ɹ্૚ ➡ Infra૚ ɹ…ͬͯґଘ͕͋Δ͚Ͳ ɹ໼ҹͷํ޲ɺٯ͡Όͳ͍ʁ 37
  38. Onion Architecture(2008-) Jeffʮ͜͏͡Όͳ͍ʁʯ 38

  39. Onion Architecture(2008-) • Infra૚͸UI૚ͱಉ͡ ʮ֎ଆʯѻ͍ • ґଘํ޲͸಺޲͖ • ಺ˠ֎΁ͷΞΫηε͸ɺ ґଘੑٯసͷ๏ଇ(DIP)Λ

    ࢖͏ •಺: ΠϯλϑΣʔεఆٛ •֎: ۩৅Λ࣮૷ 39
  40. System Architectures ᶆ Clean Architecture (2012-) ʮ͜Ε·ͰͷΞʔΩςΫνϟΛవΊͨΑɻͶɺ؆୯Ͱ͠ΐʁʯ 40

  41. Clean Architecture (2012-) ΞδϟΠϧքͷڊਓ Robert C. Martin (Bob͓͡͞Μ)ʹΑΔఏҊ • Hexagonal

    Architecture • Onion Architecture • DCI ౳ʑΛɺͻͱͭͷ֓೦ʹ౷߹ 41
  42. System Architectures ᶇ VIPER (2013-) Mutual Mobileͷߟ͑ͨ࠷ڧͷiOS൛Clean Architecture 42

  43. VIPER (2013-) Mutual Mobile͕ࣾiOSͷͨΊʹߟҊɻ (۩ମతͳObj-C/Swiftͷίʔυꑤ΀΄ͽ ʮΞʔΩςΫνϟʯͱ͍͏ΑΓʮઃܭʯʁ) • View • Interactor

    • Presenter • Entity • Routing (Wireframe) ͷ಄จࣈΛऔ͍ͬͯΔɻ ը໘ભҠͷ੹຿Λ ViewController͔Β෼཭Ͱ͖Δͷ͕ಛ௃ɻ 43
  44. ͍ͭͰʹ MVVM-C (2016-) Model-View-ViewModel ʹՃ͑ͯɺը໘ભҠ (Coordinators)Λ ෼཭͢Δઃܭ΋ ఏҊ͞ΕͯΔ ! ͜ͷਤ

    " ɺBusiness Logic͕ VMʹ͋Δͷ͕ؾʹͳΔ͚Ͳ… 44
  45. System Architectures ᶈ Minimum Viable Architecutre (2014-) ٕज़બఆʹޙչ͕ͳ͍ͷ͸ɺଟ෼ΦʔόʔΤϯδχΞϦϯάͷূڌ 45

  46. Minimum Viable Architecutre(2014-) eBay, GoogleΛܦͨ ελʔτΞοϓͷCTO Randy ShoupʹΑΔϓϨθϯ ࣄۀͷ੒௕ϑΣʔζʹԠͨ͡ ࠷௿ݶΞʔΩςΫνϟͰॆ෼

    ΠςϨʔςΟϒʹ ϘτϧωοΫΛݟ͚ͭͯ ௚͍͚ͯ͠͹͍͍ ͱ͍͏… ΞʔΩςΫνϟͱ͍͏͔… ϝλΞʔΩςΫνϟ…ʁ 46
  47. "If you don’t end up regretting your early technology decisions,

    you probably over engineered. Rearchitecting is a sign of success; if you never need to, either you overbuilt or nobody cares." -- Randy Shoup 47
  48. System Architecturesᶈ ❓❔❓ (2017-) ཧ૝ͱݱ࣮ͷؒͰɺ࣍͸ҰମͲΜͳΞʔΩςΫνϟ͕…ʁ 48