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

DDD導入して感じた課題(実装コスト) その解決のために行ったこと

DDD導入して感じた課題(実装コスト) その解決のために行ったこと

More Decks by 株式会社ビットキー / Bitkey Inc.

Other Decks in Technology

Transcript

  1. ࠤ౻୓ਓ 4BUP5BLVUP    େֶ ݐஙֶઐ߈ ଔۀޙɺ גࣜձࣾϫʔΫεΞϓϦέʔγϣϯζʹೖࣾ ձܭγεςϜͷιϑτ΢ΣΞ։ൃΛ୲౰

    ಛʹࡒ຿ձܭͷ࢓༁ؔ࿈ ϏοτΩʔ΁ࢀը &$αΠτͷ։ൃอकɺࣾ಺γεςϜͷ։ൃ 5B,V5Zͷ։ൃ ࠓͷ)PNFͷલ਎ͱͳΔ3FTJEFODFνʔϜʹ഑ଐ CJUMPDLΛѻ͏؅ཧը໘΍όοΫΤϯυɺBQQͷ։ൃ ʹैࣄ  )PNFϓϩμΫτ ෳࡶͳࣄ৅ΛಡΈղ͍ͯߏ଄Խ͠ɺந৅Խ൚༻Խ Ͱ͖ΔΑ͏ʹઃܭ͠ɺ௿ίετͰଟ͘ͷՁ஋Λͩͤ Δ։ൃΛ͢Δ͜ͱΛ޷Ή
  2.  ՝୊ - ଞػೳͰෆ੔߹ͱͳΔσʔλΛ࡞Δ࣮૷͕Մೳ - Өڹൣғͷ೺Ѳࠔ೉Ͱɺಛఆσʔλར༻ՕॴνΣοΫ͕ඞཁ & ͭΒ͍ - ௐࠪ࣌ͳͲσʔλ͔Βݱঢ়ͷεςʔλε೺Ѳ͕ࠔ೉

    (σʔλભҠ) - σʔλमਖ਼࣌ʹඞཁͳՕॴͷચ͍ग़͕͠ࠔ೉ (ػೳ × σʔλͷؔ࿈) - validation౳ͷϩδοΫ͕ࢄཚͯ͠ػೳमਖ਼͕େม… - ొ࿥஋ͷೝࣝͷ࢓ํ͕֤ػೳࠩҟ͕͋Γػೳमਖ਼࣌ʹͭΒ͍… - Ͳ͜ʹͲͷΑ͏ͳ࣮૷͞Ε͍ͯΔ͔ೝ͕ࣝͣΕΔ͜ͱ͕͋Δ - service૚ˠservice૚ˠ...→service૚ˠ update & commit  ͸͡Ίʹ
  3. ΍ͬͯΈͯ   BuildingFirestoreType BuildingFirestoreCollectionPath PropertyFirestoreType PropertyFirestoreCollectionPath RegisterBuildingUsecase BuildingEntity BuildingRepository

    AddressValueObject PropertryFirstCollection PropertyEntity RentChargeValueObject PropertyStatusValueObject CheckDuplicationDomainService υϝΠϯ σʔλϕʔε(Firestore)ͷఆٛ (ͦͷ··)
  4. ΍ͬͯΈͯ   BuildingFirestoreType BuildingFirestoreCollectionPath PropertyFirestoreType PropertyFirestoreCollectionPath RegisterBuildingUsecase BuildingEntity BuildingRepository

    AddressValueObject PropertryFirstCollection PropertyEntity RentChargeValueObject PropertyStatusValueObject CheckDuplicationDomainService υϝΠϯ BuildingRepositoryFirestore BuildingFirestoreConverter PropertyFirestoreConverter σʔλϕʔε(Firestore)ͷఆٛ (ͦͷ··) ϞσϧΛIFʹ σʔλϕʔεʹ ΞΫηε͢Δॲཧ
  5. ΍ͬͨ͜ͱ   BuildingFirestoreType BuildingFirestoreCollectionPath PropertyFirestoreType PropertyFirestoreCollectionPath RegisterBuildingUsecase BuildingEntity BuildingRepository

    AddressValueObject PropertryFirstCollection PropertyEntity RentChargeValueObject PropertyStatusValueObject CheckDuplicationDomainService BuildingRepositoryFirestore BuildingFirestoreConverter PropertyFirestoreConverter ྫ͑͹... Buildingͷ৔߹
  6. ΍ͬͨ͜ͱ   buildingRepository.ts IDΛݩʹऔಘ͢Δϝιου͸ อଘ͢Δϝιου͸ ݪଇඞཁͱͳΔͷͰ ػցతʹ࡞ͬͯ͠·͑Δ ಛఆͷϑΟʔϧυͰͷߜΓࠐΈ ͸

    ݸผ࣮૷͕ඞཁ buildingFirestoreType.ts Entityͱ࣋ͪํม͑ΔͳΒݸผఆ͕ٛඞཁ Entityͱಉ࣋ͪ͡ํ͢ΔͳΒػցతʹܾ·Δ (※EntityͷFirstCollection͸আ֎)
  7. ΍ͬͨ͜ͱ - ϑΝΠϧ໊ / Ϋϥε໊͸ػցతʹܾΊΒΕΔ - Entity΍Repository͸ڞ௨ॲཧΛ·ͱΊΒΕΔ ※ ܧঝͰղܾͰ͖Δ෦෼΋͋Δ -

    σʔλͷ࣋ͪํ = EntityͷཁૉͱͰ͖ΔͳΒɺ σʔλܕఆٛ΍convertॲཧ͸ػցతʹܾ·Δ  
  8. ΍ͬͨ͜ͱ ओͳม਺ - Ϟσϧ໊ (Building) - छผ (Entity / ValueObject

    / FirstCollection …) - ཁૉ (code:string, address: AddressValueObject)   → ্ه͕ఆٛ͞Ε͍ͯΕ͹ɺޙ͸ػցతʹܾΊΒΕͦ͏ ػցతʹܾΊΔͨΊʹඞཁͳཁૉ
  9. 

  10. Queue Smaple આ໌   1. Appendix ˙2VFVF ɾ2VFVFΛ؅ཧ͢ΔͨΊͷσʔλ ɾॲཧத͔൱͔ɺॲཧ͍ͯ͠ΔUBTL͕ͳʹ͔ͳͲΛ؅ཧ͢Δ

    ˙2VFVF5BTL ɾ2VFVFʹੵ·ΕͨλεΫ ɾॲཧதͱͳΔλΠϛϯάͰ࡟আ͞Εɺॲཧʹࣦഊ͠ϦτϥΠର৅ͱͳͬͨλΠϛϯάͰ࠶ੜ੒͞ΕΔ ɾجຊతʹ͸FORVFVF͞Εͨ೔࣌ॱʹλεΫΛ࣮ߦ͢Δ ɾ༏ઌ౓͕ࢦఆ͞Εͯݴ͏৔߹ʹ͸༏ઌ౓͕ߴ͍ॱʹ࣮ߦ͢Δ ˙2VFVF5BTL3FTVMU ɾ2VFVFͷ࣮ߦ݁ՌΛ؅ཧ͢ΔͨΊͷσʔλ ɾॲཧࣦഊͯ͠ϦτϥΠ͢Δ৔߹ͳͲ͸ɺϦτϥΠ͝ͱʹ݁ՌσʔλΛੜ੒͢Δ ɾ5BTL&OUSZʹ͸࠷ऴతͳ݁ՌͷΈ֨ೲ͢Δ ˙2VFVF&OUSZ ɾ2VFVFλεΫΛ؅ཧ͢Δݩσʔλ ɾλεΫੜ੒࣌ʹຊσʔλ͕ੜ੒͞ΕΔ ɾλεΫ࣮ߦʹඞཁͳ৘ใͱɺ࠷௿ݶͷεςʔλεͷ؅ཧΛߦ͏ ɾ࣮ࡍʹ2VFVF্ͷσʔλભҠΛ؅ཧ͢Δσʔλ͸ผ ˙2VFVF&OUSZ4VCUBTL ɾͭͷ&OUSZΛ࣮ݱ͢ΔͨΊʹෳ਺ͷ5BTLΛ࣮ߦ͢Δඞཁ͕͋Δ৔߹ʹ ɹෳ਺ͷ5BTLΛ4VC5BTLͱͯ͠؅ཧ͢Δ