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

"ビュー"を考えるためのADRパターン @ laravel.osaka #10

Df4978f14401325586e9e286b140ac4c?s=47 n1215
April 26, 2017

"ビュー"を考えるためのADRパターン @ laravel.osaka #10

2017.04.26 laravel.osaka#10のLTで使用したスライドです
ADR with Laravel サンプルコード
https://github.com/n1215/lara-adr

Df4978f14401325586e9e286b140ac4c?s=128

n1215

April 26, 2017
Tweet

Transcript

  1. “Ϗϡʔ”Λߟ͑ΔͨΊͷADRύλʔϯ for laraval.osaka #10 2017/04/26 גࣜձࣾNextat தᒇ ݈ೋ

  2. What is ADR ? • Action-Domain-Responder • “MVC Refinement” by

    Paul M. Jones
  3. MVCͱ ADR ͷରԠ • Model ͱ Domain • Controller ͱ

    Action • View ͱ Responder
  4. ModelͱDomain • ΄΅ಉ͡ • फڭ࿦૪ʹͳΔͷͰࠓճ͸ύε

  5. Controller ͱ Action • 1ΞΫγϣϯ1Ϋϥεਪ঑ • ΞΫγϣϯʹର͢Δԣஅॲཧɾ߹੒ॲཧ ͷ΍Γ΍͢͞ • ਆControllerΫϥεͷ஀ੜΛ્ࢭ

  6. View ͱ Responder • ຊ೔ͷ͓୊ • “Ϗϡʔ”ͱ͸ʁʁʁ

  7. LaravelΛར༻ͨ͠MVC ͷྫ

  8. "Ϗϡʔ" = ςϯϓϨʔτʁ • Blade

  9. JSONΛฦ͢৔߹͸ʁ • “Ϗϡʔ”͔ͩΒͱݴͬͯςϯϓϨʔτΛ ࢖͏ͱ͸ݶΒͳ͍

  10. Presentation Domain Separation ͷݪଇ • MVC͕ຊ౰ʹ࣮ݱ͔ͨͬͨ͠ίτ • υϝΠϯ૚͸ϓϨθϯςʔγϣϯ૚ʹൺ ΂Δͱ࢖͍ճ͠΍͘͢มߋ͞Εʹ͍͘ •

    ૄ݁߹ʹ͓ͯ͘͠ͱ޾ͤʹͳΕΔ
  11. Ϗϡʔͷ໾ׂ • υϝΠϯʢϞσϧʣ૚ͷॲཧ݁ՌΛϢʔ βʔʹͲ͏ݟͤΔ͔ΛܾΊΔϩδοΫ • ΫϥΠΞϯτ͕ҧ͑͹Ͳ͏ݟͤΔ΂͖͔ ΋มΘΔ • ϒϥ΢βɺίϚϯυϥΠϯ

  12. WebΞϓϦέʔγϣϯͷ”Ϗϡʔ” ϢʔβʔϞσϧ $user ͳͲυϝΠϯͷग़ྗ ɹ↓ɹม׵ HTTPϨεϙϯε - HTML - JSON

    etc.
  13. HTTPϨεϙϯε Blade ςϯϓϨʔτ →ϨεϙϯεϘσΟͷΈ • εςʔλείʔυ • HTTPϨεϙϯεϔομ ΋"Ϗϡʔ"͕ѻ͏΂͖ର৅ͷҰ෦

  14. None
  15. Laravel (>= 5.3) / Lumen Ͱͷྫ

  16. Responder

  17. ϨεϙϯεΛHTMLʹมߋ͍ͨ͠ • ResponderΛೖΕସ͑Δ • Domain͸࢖͍·ΘͤΔ

  18. ·ͱΊ • ADR͸MVC͕ຊ౰ʹ΍Γ͔ͨͬͨίτ • WebΞϓϦʹͱͬͯͷ"Ϗϡʔ"͸HTTPϨ εϙϯεΛੜ੒͢Δॲཧͷ͜ͱ • ςϯϓϨʔτ͚͕ͩ”Ϗϡʔ"Ͱ͸ͳ͍

  19. ࢀߟ - pmjones/adr https://github.com/pmjones/adr - Radar.Project https://github.com/radarphp/Radar.Project - Presentation Domain

    Separation https://martinfowler.com/bliki/PresentationDomainSeparation.html - Single Action Controllers https://laravel.com/docs/5.4/controllers#single-action-controllers - Lumen/Laravel Action-Domain-Responder(ADR)Ξϓϩʔν http://qiita.com/ytake/items/db8cb64493f08f5b9706