Pro Yearly is on sale from $80 to $50! »

Bloc PatternにおけるBloc分割の方針と実践例 / Division plan and practical example in bloc pattern

Bloc PatternにおけるBloc分割の方針と実践例 / Division plan and practical example in bloc pattern

Flutter Meetup Tokyo #12

8f35e0eca3fafcc994d26ad430628985?s=128

Kazuki YAMAGUCHI

November 07, 2019
Tweet

Transcript

  1. ,B[VLJ:BNBHVDIJZBNBSL[ 'MVUUFS.FFUVQ #MPD1BUUFSOʹ͓͚Δ#MPD෼ׂͷํ਑ͱ࣮ફྫ (MPCBM#MPD-PDBM#MPD$PNQPOFOU#MPD5FNQMBUF#MPD

  2. !ZBNBSL[,B[VLJ:BNBHVDIJ 4FSWFS.PCJMF"QQ&OHJOFFS!)PVTNBSU JOD

  3. ࿩͢͜ͱ ෼ 'MVUUFSͰ։ൃ͢Δʹ͋ͨͬͯར༻ͨ͠#MPD1BUUFSOʹ͓͚Δɺ ࣮૷ύλʔϯͷಛ௃ͱ෼ྨɺͦͯ͠#MPDͷ෼ׂͰܾΊͨํ਑Λ঺հ͠·͢

  4. ࿩ͷ୊ࡐΧ΢ϧ ɾ݄த०ʹ'MVUUFS੡ͷΞϓϦΛϦϦʔε ϦϓϨΠε  ɾ։ൃظؒ͸ि ɾ#MPD1BUUFSOͱ3Y%BSUΛ࠾༻ ɾ࡞ΒΕͨ#MPDͷ਺͸ݸ ɾϦϓϨΠεͷ࿩͸OPUFʹॻ͖·ͨ͠

  5. ɾ݄த०ʹ'MVUUFS੡ͷΞϓϦΛϦϦʔε ϦϓϨΠε  ɾ։ൃظؒ͸ि ɾ#MPD1BUUFSOͱ3Y%BSUΛ࠾༻ ɾ࡞ΒΕͨ#MPDͷ਺͸ݸ ɾϦϓϨΠεͷ࿩͸OPUFʹॻ͖·ͨ͠ ࿩ͷ୊ࡐΧ΢ϧ ɾ࡞ΒΕͨ#MPDͷ਺͸ݸ ଟ͍ʁগͳ͍

     ͜ͷݸͷ੗Έ෼͚ͱಛ௃͕ࠓճͷ࿩ͷओ୊Ͱ͢
  6. #MPD1BUUFSOΛద༻ͨ͜͠ͱͰݟ͑ͨͭͷ෼ׂํ਑

  7. ΞϓϦέʔγϣϯશମʹؔΘΔॲཧΛͭʹ·ͱΊΔ εΫϦʔϯ͚ͩͰར༻͢ΔॲཧΛͭʹ·ͱΊΔ ίϯϙʔωϯτͰར༻͢ΔॲཧΛͭʹ·ͱΊΔ ڞ௨Ͱར༻͢ΔॲཧΛͭʹ·ͱΊΔ #MPD1BUUFSOΛద༻ͨ͜͠ͱͰݟ͑ͨͭͷ෼ׂํ਑

  8. ΞϓϦέʔγϣϯશମʹؔΘΔॲཧΛͭʹ·ͱΊΔ εΫϦʔϯ͚ͩͰར༻͢ΔॲཧΛͭʹ·ͱΊΔ ίϯϙʔωϯτͰར༻͢ΔॲཧΛͭʹ·ͱΊΔ ڞ௨Ͱར༻͢ΔॲཧΛͭʹ·ͱΊΔ #MPD1BUUFSOΛద༻ͨ͜͠ͱͰݟ͑ͨͭͷ෼ׂํ਑ ΞϓϦέʔγϣϯશମʹ εΫϦʔϯ͚ͩͰ ίϯϙʔωϯτͰ ڞ௨Ͱ ํ਑ͷҧ͍͸είʔϓͷ޿͞

  9. ΞϓϦέʔγϣϯશମʹؔΘΔॲཧΛͭʹ·ͱΊΔ εΫϦʔϯ͚ͩͰར༻͢ΔॲཧΛͭʹ·ͱΊΔ ίϯϙʔωϯτͰར༻͢ΔॲཧΛͭʹ·ͱΊΔ ڞ௨Ͱར༻͢ΔॲཧΛͭʹ·ͱΊΔ #MPD1BUUFSOΛద༻ͨ͜͠ͱͰݟ͑ͨͭͷ෼ׂํ਑ ͳͥɺ͜ͷ੗Έ෼͚͕ྑ͍ͷ͔ʁ

  10. ͳͥɺ͜ͷ੗Έ෼͚͕ྑ͍ͷ͔ʁ ͭͷओͳཧ༝  ΞϓϦɺεΫϦʔϯɺίϯϙʔωϯτͱ͍͏6*ߏ଄Λ࣠ʹॲཧ͕·ͱ·ΔͨΊɺ ߏ଄͕୯७ͰΘ͔Γ΍͘͢ͳΔ ϑΝΠϧ਺͸૿͑΍͍͕͢ɺϑΝΠϧ͋ͨΓͷίʔυྔ͸ݮΔ  είʔϓͷൣғ͕໌֬ʹఆ·ͬͨ#MPDΛ࡞ΔͨΊɺ#MPDࣗମ͕ૄ݁߹ʹͳΔɻ ݁Ռͱͯ͠ɺอकੑ͕ߴ͘ͳΓɺಡΈ΍͍͢ɺཧղ͠΍͍͢ɺมߋ͠΍͍͢ͱ͍ͬ ͨঢ়گʹͳΔ

    #MPDͷ࣮૷ࣗମ͕ߏ଄Խ͞ΕΔ͜ͱʹΑΓɺอकੑ্͕͕Δ
  11. (MPCBM#MPD-PDBM#MPD$PNQPOFOU#MPD5FNQMBUF#MPD ෼ׂํ਑ͷఆٛʹΑͬͯੜ·Εͨɺ#MPDͷ෼ྨ

  12. (MPCBM#MPD ɾΞϓϦ୯ҐͰɺ޿͍ൣғʹؔΘΔॲཧΛ·ͱΊΔ FYೝূॲཧ ΠϕϯτετϦʔϜΛଞ#MPDʹ఻೻͢Δॲཧ  -PDBM#MPD ɾεΫϦʔϯ୯ҐͰɺݶΒΕͨڱ͍ൣғʹؔΘΔॲཧΛ·ͱΊΔ FYඳը͢Δσʔλͷऔಘॲཧ ϦϩʔυͳͲͷը໘୯ҐͰߦΘΕΔॲཧ $PNQPOFOU#MPD

    ɾίϯϙʔωϯτ୯ҐͰɺݶΒΕͨ෦෼ʹؔΘΔॲཧΛ·ͱΊΔ FYϢʔβʔΞΫγϣϯ͕ൃੜ͢Δॲཧ ͓ؾʹೖΓ ࡟আ  5FNQMBUF#MPD ɾڞ௨ͷॲཧ୯ҐͰɺݶΒΕͨڱ͍ൣғʹؔΘΔॲཧΛ·ͱΊΔ FYೝূॲཧ ྨࣅը໘ͷྨࣅॲཧ ෼ׂํ਑ͷఆٛʹΑͬͯੜ·Εͨɺ#MPDͷ෼ྨ
  13. (MPCBM#MPD ɾΞϓϦ୯ҐͰɺ޿͍ൣғʹؔΘΔॲཧΛ·ͱΊΔ FYೝূॲཧ ΠϕϯτετϦʔϜΛଞ#MPDʹ఻೻͢Δॲཧ  -PDBM#MPD ɾεΫϦʔϯ୯ҐͰɺݶΒΕͨڱ͍ൣғʹؔΘΔॲཧΛ·ͱΊΔ FYඳը͢Δσʔλͷऔಘॲཧ ϦϩʔυͳͲͷը໘୯ҐͰߦΘΕΔॲཧ $PNQPOFOU#MPD

    ɾίϯϙʔωϯτ୯ҐͰɺݶΒΕͨ෦෼ʹؔΘΔॲཧΛ·ͱΊΔ FYϢʔβʔΞΫγϣϯ͕ൃੜ͢Δॲཧ ͓ؾʹೖΓ ࡟আ  5FNQMBUF#MPD ɾڞ௨ͷॲཧ୯ҐͰɺݶΒΕͨڱ͍ൣғʹؔΘΔॲཧΛ·ͱΊΔ FYೝূॲཧ ྨࣅը໘ͷྨࣅॲཧ ෼ׂํ਑ͷఆٛʹΑͬͯੜ·Εͨɺ#MPDͷ෼ྨ Χ΢ϧΞϓϦͰͷ#MPDΛ෼ྨ͝ͱʹৼΓ෼͚Δͱ    
  14. (MPCBM#MPD ΞϓϦ୯ҐͰ޿͍ൣғʹؔΘΔॲཧΛ·ͱΊΔ "QQ 4DSFFO 4DSFFO 4DSFFO 4DSFFO #MPD

  15. ͓ؾʹೖΓը໘ ҟͳΔը໘ͷڞ௨ͷॲཧ πʔϧνοϓ Λɺ ಉҰͷ(MPCBM#MPDΛࢀর੍ͯ͠ޚ͍ͯ͠Δ (MPCBM#MPD ϗʔϜը໘ πʔϧνοϓͷදࣔ৚݅Λ੍ޚ͢Δ #MPDΛڞ௨Ͱࢀর

  16. "QQ 4DSFFO 4DSFFO 4DSFFO 4DSFFO #MPD εΫϦʔϯ୯ҐͰݶΒΕͨڱ͍ൣғʹؔΘΔॲཧΛ·ͱΊΔ -PDBM#MPD

  17. ϩάΠϯը໘ ɾαΠϯΠϯॲཧ ɾϩάΠϯॲཧ ɾ(PPHMFϩάΠϯॲཧ ɾ'BDFCPPLϩάΠϯॲཧ ɾϝʔϧΞυϨεͷόϦσʔτॲཧ ɾύεϫʔυͷόϦσʔτॲཧ ɾύεϫʔυͷද੍ࣔޚॲཧ ಛఆͷը໘ͷΈͰར༻͢Δॲཧ ϩάΠϯϩάΞ΢τ

    Λ੍ޚ͢Δ -PDBM#MPD
  18. $PNQPOFOU#MPD ίϯϙʔωϯτ୯ҐͰ෦෼తʹؔΘΔॲཧΛ·ͱΊΔ 4DSFFO $PNQPOFOU $PNQPOFOU $PNQPOFOU $PNQPOFOU #MPD

  19. ͓ؾʹೖΓը໘ ϗʔϜը໘ $PNQPOFOU#MPD ҰݟҟͳΔ6*ߏ଄ Χʔυܕ ϦετΞΠςϜܕ ʹݟ͑Δ

  20. $PNQPOFOU#MPD $POE$BSE#MPD Λ࠶ར༻͍ͯ͠Δ ͔͠͠ɺഎޙͰར༻͍ͯ͠Δ#MPD͸ಉҰͷ΋ͷ ڞ௨ॲཧͷ࠶ར༻ ϗʔϜը໘ ͓ؾʹೖΓը໘

  21. 5FNQMBUF#MPD 4DSFFO 5NQ #MPD #MPD #MPD 4DSFFO 4DSFFO ڞ௨ར༻͢Δॲཧ୯ҐͰڱ͍ൣғʹؔΘΔॲཧΛ·ͱΊΔ ܧঝ֦ͯ͠ு

    ϓϨʔϯʹར༻
  22. 8FC7JFXͱͯ͠ͷجຊػೳ͸ಉ͡ͳͷͰɺಉҰͷ#MPDΛར༻͢Δ͕ɺ ֦ுػೳ͕ཉ͍͠৔߹ʹɺ#MPDࣗମΛܧঝͯ͠࠶ར༻ͭͭ͠ػೳ௥Ճ͢Δ #MPDΛܧঝ͠ɺ ػೳ֦ு͍ͯ͠Δ 1MBJOͳ#MPDΛ ͦͷ··ར༻͍ͯ͠Δ 5FNQMBUF#MPD ࣋ͪࠐΈը໘ αʔϏε֓ཁը໘

  23. ΞϓϦέʔγϣϯશମʹؔΘΔॲཧΛͭʹ·ͱΊΔ εΫϦʔϯ͚ͩͰར༻͢ΔॲཧΛͭʹ·ͱΊΔ ίϯϙʔωϯτͰར༻͢ΔॲཧΛͭʹ·ͱΊΔ ڞ௨ར༻͢ΔॲཧΛͭʹ·ͱΊΔ #MPD1BUUFSOΛద༻ͨ͜͠ͱͰݟ͑ͨͭͷ෼ׂํ਑

  24. l࡞ΒΕͨ#MPDͷ਺͸ݸzଟ͍ গͳ͍ʁ

  25. l࡞ΒΕͨ#MPDͷ਺͸ݸzଟ͍ গͳ͍ʁ ݸਓతʹ͸ɺ͜Μͳ΋ͷ͔ͳͱ͍͏ײ͡ɻ ࠓͷͱ͜Ζ։ൃӡ༻తʹ͸ಛʹෆ౎߹Λײͯ͡ͳ͍Ͱ͕͢ɺ ΋͔ͨ͠͠Βকདྷతʹɺ՝୊ʹײ͡Δ͜ͱ͕ग़Δ͔΋ʜ

  26. ·ͱΊ ɾҰॏʹ#MPD1BUUFSOͱݴ͑Ͳɺѻ͍ํ͸༷ʑଘࡏ͢Δ ɾ(MPCBM -PDBM $PNQPOFOU 5FNQMBUFͦΕͧΕͷ࢖͍ํΛݟۃΊͯѻ͏ ɾείʔϓͷ໌֬Խɺߏ଄ԽʹΑΓɺอकੑͷߴ͍ΞϓϦέʔγϣϯ։ൃ͕ՄೳʹͳΔ #MPD1BUUFSOࣗମͷద༻Λԣͷߏ଄Խ 6*ͱϩδοΫͷ෼཭ ͩͱ͢ΔͳΒɺ

    #MPDͷ࣮૷ύλʔϯΛద༻͢Δ͜ͱ͸ɺॎͷߏ଄Խ είʔϓʹΑΔϩδοΫ෼཭
  27. ͝੩ௌ͋Γ͕ͱ͏͍͟͝·ͨ͠ʂ