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

なぜ誰もこう書いてくれない Dependency Injection

Koji Saiki
October 15, 2017

なぜ誰もこう書いてくれない Dependency Injection

Koji Saiki

October 15, 2017
Tweet

More Decks by Koji Saiki

Other Decks in Programming

Transcript

  1. ͳͥ୭΋͜͏ॻ͍ͯ͘Εͳ͍
    %FQFOEFODZ*OKFDUJPOೖ໳
    2017/10/5

    View full-size slide

  2. ࣗݾ঺հ
    ! ͓ͳ·͑ɿࠤഢߛೋʢ͍͖͜͞͏͡ʣ
    ! ͱ͜Ζɿ෱Ԭɾେࡕ
    ! ͭͿ΍͖ɿIUUQTUXJUUFSDPNTBJLPV
    ! ͸ͿɿIUUQTHJUIVCDPNLPKJTBJLJ
    ! ͿΖ͙ɿIUUQJSPOZIBUFOBCMPHDPN

    View full-size slide

  3. ɹ%FQFOEFODZ*OKFDUJPOɺґଘੑ஫ೖʜ
    ɹཧղ͍ͨ͠Ͱ͢ΑͶɻ

    View full-size slide

  4. ʮͦ͜͸4FSWJDF$MBTTͷ*OTUBODFΛ
    ɹ*OKFDU͢Ε͹ҰൃͰ͢Αɻʯ
    ɹͱ͔ݴ͍͍ͨͰ͢ΑͶɻ

    View full-size slide

  5. ɹ·ͣ͸͜ΕΛ಄ʹୟ͖ࠐΜͰ͍ͩ͘͞ɻ

    View full-size slide

  6. ʮ%FQFOEFODZ*OKFDUJPOʯͱ͍͏໊લ͔Β
    ɹػೳΛཧղ͢Δ͜ͱ͸Ͱ͖·ͤΜʂʂʂ

    View full-size slide

  7. z%*z͔Βਪଌ͢Δ͜ͱ͸lෆՄೳzͰ͢
    ! %FQFOEFODZ*OKFDUJPO
    ! ೔ຊޠʹ຋༁͢Δͱʮґଘੑ஫ೖʯ
    ! ͔͜͜ΒೖΔͱཧղͰ͖·ͤΜ

    View full-size slide

  8. ͜ΕΘ͔Γ·͔͢ʁ

    View full-size slide

  9. ͜ΕΘ͔Γ·͔͢ʁ
    ! 0CKFDU0SJFOUFE1SPHSBNNJOH

    View full-size slide

  10. ͜ΕΘ͔Γ·͔͢ʁ
    ! 0CKFDU0SJFOUFE1SPHSBNNJOH
    ! .JTTJPO$POUSPM

    View full-size slide

  11. ͜ΕΘ͔Γ·͔͢ʁ
    ! 0CKFDU0SJFOUFE1SPHSBNNJOH
    ! .JTTJPO$POUSPM
    ! ӡ໋ͱ͍͏໊ͷ31(
    ! Ӭԕͱឺͷ13(
    ! ܅ͱڹ͖͋͏31(

    View full-size slide

  12. ͜ΕΘ͔Γ·͔͢ʁ
    ! 0CKFDU0SJFOUFE1SPHSBNNJOH
    ! .JTTJPO$POUSPM
    ! ӡ໋ͱ͍͏໊ͷ31(
    ! Ӭԕͱឺͷ13(
    ! ܅ͱڹ͖͋͏31(
    ! %FQFOEFODZ*OKFDUJPOOFX

    View full-size slide

  13. ɹ͖͋ΒΊΑ͏

    View full-size slide

  14. Ұ୴ɺ໊લΛ๨Ε·͠ΐ͏
    ! ਖ਼໊ࣜশͱ͔೔ຊޠͱ͔๨Εͯɺʮ%*ʯ͸ԿΛ͢Δ΋ͷʁͱ͍͏ͱ͜Ζ͔Βೖ
    Δͷ͕l࣮֬z

    View full-size slide

  15. ͡Ό͋ʮ%*ʯ͸ԿΛ͢Δ΋ͷʁ
    ! ུশɾਖ਼໊ࣜশΛҙࣝͤͣɺ໨తɾୡ੒͍ͨ͜͠ͱΛཧղ͠·͠ΐ͏
    ! ڭՊॻɿʮ࡞ͬͯཧղ͢Δ%*ίϯςφʯ IUUQEIBUFOBOFKQOPXPLBZ


    ! ͖ͩ͠͞Μ͕͢͞Ͱ͢
    ! هࣄͷཁ໿ͳͲ͸͍ͯ͠·ͤΜɻ͔͋͠Βͣɻ

    View full-size slide

  16. ͍ͭ͜ʹͯ͠΄͍͜͠ͱ

    View full-size slide

  17. ͍ͭ͜ʹͯ͠΄͍͜͠ͱ
    ! ཉ͍͠ΦϒδΣΫτʢΠϯελϯεʣΛ༻ҙͯ͘͠ΕΔ

    View full-size slide

  18. ͍ͭ͜ʹͯ͠΄͍͜͠ͱ
    ! ཉ͍͠ΦϒδΣΫτʢΠϯελϯεʣΛ༻ҙͯ͘͠ΕΔ
    ! Ұ౓ੜ੒͞ΕͨΦϒδΣΫτΛอ؅͓͍ͯͯ͘͠ΕΔ

    View full-size slide

  19. ͍ͭ͜ʹͯ͠΄͍͜͠ͱ
    ! ཉ͍͠ΦϒδΣΫτʢΠϯελϯεʣΛ༻ҙͯ͘͠ΕΔ
    ! Ұ౓ੜ੒͞ΕͨΦϒδΣΫτΛอ؅͓͍ͯͯ͘͠ΕΔ
    ! γϯάϧτϯΠϯελϯε΋͘ΕΔ

    View full-size slide

  20. ͍ͭ͜ʹͯ͠΄͍͜͠ͱ
    ! ཉ͍͠ΦϒδΣΫτʢΠϯελϯεʣΛ༻ҙͯ͘͠ΕΔ
    ! Ұ౓ੜ੒͞ΕͨΦϒδΣΫτΛอ؅͓͍ͯͯ͘͠ΕΔ
    ! γϯάϧτϯΠϯελϯε΋͘ΕΔ
    ! ςετͷͱ͖ɺςετ༻ͷΦϒδΣΫτͱखܰʹ੾Γସ͑ͯ͘ΕΔ

    View full-size slide

  21. ɹͭ·Γɺ
    ʮ͍͍ײ͡ʹΦϒδΣΫτΛ͘ΕΔ΍ͭʯ
    ɹͰ͢ɻ

    View full-size slide

  22. ͡Ό͋ɺͦΖͦΖΠέͯΔ໊લ͚ͭΔ͔
    ! .BSUJOʮϓϩάϥϜ͸ΦϒδΣΫτΛ࢖ͬͯಈ࡞͍ͯ͠ΔɻͦΕΛద੾ʹࠩ͠
    ࠐΜͰ΄͍͠ɻʯ

    View full-size slide

  23. ͡Ό͋ɺͦΖͦΖΠέͯΔ໊લ͚ͭΔ͔
    ! .BSUJOʮϓϩάϥϜ͸ΦϒδΣΫτΛ࢖ͬͯಈ࡞͍ͯ͠ΔɻͦΕΛద੾ʹࠩ͠
    ࠐΜͰ΄͍͠ɻʯ
    ! .BSUJOʮͭ·Γzґଘੑzͷz஫ೖzͶɻʯ

    View full-size slide

  24. ͡Ό͋ɺͦΖͦΖΠέͯΔ໊લ͚ͭΔ͔
    ! .BSUJOʮϓϩάϥϜ͸ΦϒδΣΫτΛ࢖ͬͯಈ࡞͍ͯ͠ΔɻͦΕΛద੾ʹࠩ͠
    ࠐΜͰ΄͍͠ɻʯ
    ! .BSUJOʮͭ·Γzґଘੑzͷz஫ೖzͶɻʯ
    ! .BSUJOʮͰ͢Ͷɻʯ
    ! Զʮʁʁʁʯ
    ɹɹɹɹʊਓਓਓਓਓਓਓਓਓਓਓਓʊ
    ɹɹɹɹʼɹ%FQFOEFODZ*OKFDUJPOɹʻ
    ɹɹɹɹʉ:?:?:?:?:?:?:?:?:?:?:ʉ

    View full-size slide

  25. ͡Ό͋ɺͦΖͦΖΠέͯΔ໊લ͚ͭΔ͔
    ! .BSUJOʮ%*Λ΍ΒͤΔϓϩάϥϜʹ͸ͳΜ໊ͯલΛ͚ͭΑ͏ʁʯ

    View full-size slide

  26. ͡Ό͋ɺͦΖͦΖΠέͯΔ໊લ͚ͭΔ͔
    ! .BSUJOʮ%*Λ΍ΒͤΔϓϩάϥϜʹ͸ͳΜ໊ͯલΛ͚ͭΑ͏ʁʯ
    ! .BSUJOʮ๻ͷղऍͩͱ͜Ε͸zίϯςφzͳΜͩΑͶɻΦϒδΣΫτΛఏڙ͠ͳ
    ͕ΒɺϒϥοΫϘοΫεͰ΋ͪΌΜͱ࢓ࣄΛ͜ͳͯ͘͠ΕΔΞΫλʔɻʯ

    View full-size slide

  27. ͡Ό͋ɺͦΖͦΖΠέͯΔ໊લ͚ͭΔ͔
    ! .BSUJOʮ%*Λ΍ΒͤΔϓϩάϥϜʹ͸ͳΜ໊ͯલΛ͚ͭΑ͏ʁʯ
    ! .BSUJOʮ๻ͷղऍͩͱ͜Ε͸zίϯςφzͳΜͩΑͶɻΦϒδΣΫτΛఏڙ͠ͳ
    ͕ΒɺϒϥοΫϘοΫεͰ΋ͪΌΜͱ࢓ࣄΛ͜ͳͯ͘͠ΕΔΞΫλʔɻʯ
    ! .BSUJOʮz%*ͷ೚຿Λෛ͏ίϯςφzͶɻʯ
    ! Զʮʁʁʁʁʁʁʯ
    ɹɹɹɹɹʊਓਓਓਓਓਓਓʊ
    ɹɹɹɹɹʼɹ%*ίϯςφɹʻ
    ɹɹɹɹɹʉ:?:?:?:?:?:ʉ

    View full-size slide

  28. ɹ͖͋ΒΊΑ͏

    View full-size slide

  29. ɹͪΐͬͱ͕Μ͹ͬͯߟ͑Δͱɺ
    ɹ%*ίϯςφͷzίϯςφzͬͯɾɾɾ

    View full-size slide

  30. ͜͏͡Όͳͯ͘

    View full-size slide

  31. Ͱɺ͜͏ʁ
    ΦϒδΣΫτ
    Πϯελϯε԰
    γϯάϧτϯ
    औΓἧ͑ͯ·͢ʂ
    ΦʔμʔϝΠυ
    ঝΓ·͢ʂ

    View full-size slide

  32. ·ͱΊ
    ! z%FQFOEFODZ*OKFDUJPOzɺzґଘੑ஫ೖzͱ͍͏ݴ༿͸๨Εͯɺ໨తΛ஌Γ·͠
    ΐ͏ɻͦͯ͠࢖֮ͬͯ͑·͠ΐ͏ɻ
    ! z%*ίϯςφz͸ʮ%*ͷ໾ׂΛ୲͏ϓϩάϥϜʯఔ౓ʹΏΔ֮͑͘·͠ΐ͏ɻ
    ! ͖ͩ͠ͳ͓͖ɹ͞Μɺ͍Β͢ͱ΍ɹ͞Μɺແஅ࢖༻Ͱࣦྱ͠·͢N @@
    N

    View full-size slide

  33. ͓ΘΓ
    kojisaiki/saikou9901

    View full-size slide