Slide 1

Slide 1 text

גࣜձࣾΩοζελʔ CTO ৿ɹ఩࠸ CAFU v3 ׬શʹཧղͨ͠ - Zenject Λఴ͑ͯ -

Slide 2

Slide 2 text

͜Μʹͪ͸ʂ 2

Slide 3

Slide 3 text

w$"'6Wʹ͍ͭͯ w;FOKFDUʹ͍ͭͯ wॲཧͷྲྀΕΛ௥͏ wWˠWͷҠߦɾڞଘ 3 ͓͠ͳ͕͖

Slide 4

Slide 4 text

CAFU v3 ʹ͍ͭͯ 4

Slide 5

Slide 5 text

w׬શͳΔ$MFBO"SDIJUFDUVSFͷ࣮ݱ w $MFBO"SDIJUFDUVSFୡਓʹֶͿιϑτ΢ΣΞͷߏ଄ͱઃܭ
 3PCFSU$.BSUJO ֯੐య ߴ໦ਖ਼߂cຊc௨ൢ
 5 ίϯηϓτ About CAFU v3 > Changes

Slide 6

Slide 6 text

w1SFTFOUBUJPOϨΠϠͷґଘͷ޲͖Λ ٯస wਖ਼͍͠%*1ͷ࣮ݱ w&OUJUZͱ%BUB4USVDUVSFͷ෼཭ w.PEFMϨΠϠͷഇࢭ 6 Changes from v2 to v3 About CAFU v3

Slide 7

Slide 7 text

7 Presentation ͷґଘํ޲ٯస About CAFU v3 > Changes

Slide 8

Slide 8 text

8 Before About CAFU v3 > Changes > Dependency Inversion for Presentation

Slide 9

Slide 9 text

9 After About CAFU v3 > Changes > Dependency Inversion for Presentation

Slide 10

Slide 10 text

w্ҐͷϨΠϠଆʹJOUFSGBDFΛ࡞੒ w͜ΕͰϨΠϠΛލ͍ͩґଘΛճආ wԼҐϨΠϠ͸্ҐϨΠϠͷJOUFSGBDF Λ࣮૷ w6.-తͳݴ༿Ͱݴ͑͹࣮ݱ 10 ਖ਼͍͠ DIP ͷ࣮ݱ About CAFU v3 > Changes > Dependency Inversion for Presentation

Slide 11

Slide 11 text

w&OUJUZΛ࠷্ҐϨΠϠͱͯ͠࠶ఆٛ w੹຿ʹด࣮ͨ͡૷ w੹຿ʹԙ͚Δঢ়ଶ w%BUB4USVDUVSFͱͯ͠ɺ֤຤୺ϨΠϠͰ༻͍Δσʔλߏ଄Λ ఆٛ wͦΕͧΕ5SBOTMBUPSΛ௨ͯ͡&OUJUZ͔Β৘ใΛ΋Β͏ w%BUB4USVDUVSF͔ΒಡΈग़ͨ͠৘ใΛ&OUJUZʹ໭͢ͷ΋ 5SBOTMBUPSͷ੹຿ 11 Entity ͱ Data Structure ͷ෼཭ About CAFU v3 > Changes

Slide 12

Slide 12 text

wOBNFTQBDFϨϕϧͰ෼͚Δ͔Ͳ͏͔ ͸ࣗ͝༝ʹ 12 Entity ͱ Data Structure ͷ෼཭ About CAFU v3 > Changes > Split Entity and DataStructure W 㱺 W .PEFM 㱺 %BUB4USVDUVSF
 GPS1SFTFOUBUJPO-BZFS &OUJUZ 㱺 %BUB4USVDUVSF
 GPS%BUB-BZFS

Slide 13

Slide 13 text

wઌड़ͷ௨Γɺ.PEFMϨΠϠΛ
 %BUB4USVDUVSFͱͯ͠࠶ఆٛ 13 Model ϨΠϠͷഇࢭ About CAFU v3 > Changes > Split Entity and DataStructure

Slide 14

Slide 14 text

Zenject ʹ͍ͭͯ 14

Slide 15

Slide 15 text

15 Zenject ͱ͸ About Zenject w%*'SBNFXPSL w*OTUBMMFSʹܕͷੜ੒ํ๏Λఆٛ ʢ#JOEʣ w֤ΫϥεͰ͸஫ೖʢ*OKFDUʣͯ͠ཉ͠ ͍ܕΛએݴ

Slide 16

Slide 16 text

w;FOKFDU͸͡ΊͷҰา w;FOKFDU׬શʹཧղͨ͠6OJUZઋਓ w;FOKFDUͰષͷ৺ΛखʹೖΕΔ w͔ͤϊʔτ͔ͤ wͦͷଞ 16 ࢿྉ About Zenject

Slide 17

Slide 17 text

ॲཧͷྲྀΕ 17

Slide 18

Slide 18 text

wIUUQTHJUIVCDPNNPOSZDBGV@TBNQMF wHJUQVMMZBSO͓͍͍ͯͯͩ͘͠͞ 18 લஔ͖ Process flow

Slide 19

Slide 19 text

w*OTUBMMFSʹͯ;FOKFDU**OJUJBMJ[BCMFΛ࣮૷ͨ͠ 6TF$BTFΛ#JOE w6TF$BTF͔ΒҰ࿈ͷґଘΫϥεୡ͕*OKFDU͞Ε͍ͯ͘ w*OJUJBMJ[F ಺Ͱ֤छॳظԽΛߦ͏ wྫ(BNF4UBUF6TF$BTFͷ**OJUJBMJ[BCMF*OJUJBMJ[F ಺Ͱ։࢝༻4VCKFDUʹ0O/FYU w6TF$BTF͕ঢ়ଶΛ؅ཧ͢Δ&OUJUZΛૢ࡞͢Δ 19 γʔϯॳظԽ Process flow

Slide 20

Slide 20 text

w*OTUBMMFSʹ4FSJBMJ[F'JFME࡞ͬͯɺͦ ΕΛͦͷ··'SPN*OTUBODF ʹ౉͢ 20 γʔϯ্ͷཁૉΛ Bind ηΫγϣϯλΠτϧ [SerializeField] private ButtonStart buttonStart; private ButtonStart ButtonStart => buttonStart; Container.Bind() .WithId(Constant.InjectId.ButtonStart) .FromInstance(ButtonStart) .AsCached();

Slide 21

Slide 21 text

wϘλϯͱ͔ wDBGV@TBNQMFͰ͸ɺ໘౗ͩͬͨͷͰઐ༻ ͷJOUFSGBDF*5SJHHFSΛ࡞ͬͨ wݸผʹܕΛ༻ҙ͢Δ͔#JOE 8JUI*E Ͱ ΍Δ͔͸೰·͍͠ͱ͜Ζʜɻ wԿ͔ྑ͍ΞΠσΟΞ͋Γ·͔͢Ͷʁ 21 γʔϯ্ͷཁૉΛ Bind Process flow

Slide 22

Slide 22 text

22 Prefab ͔Βͷ Spawn Process flow [SerializeField] private Mole molePrefab; private Mole MolePrefab => molePrefab; [SerializeField] private Transform moleParent; private Transform MoleParent => moleParent; public override void InstallBindings() { Container // IMoleView の Factory を登録 .BindIFactory() // Mole 型として .To() // MolePrefab 内のコンポーネントを用いて .FromComponentInNewPrefab(MolePrefab) // MoleParent の配下に .UnderTransform(MoleParent);
 }

Slide 23

Slide 23 text

23 Prefab ͔Βͷ Spawn Process flow [Inject] private IFactory MoleViewFactory { get; } private List MoleViewList { get; } = new List(); public void Instantiate(int index, IMole mole) { var moleView = MoleViewFactory.Create(index, mole); MoleViewList.Add(moleView); } w͜ͷྫͷ৔߹ɺ1SFTFOUFSͰ4QBXO ͍ͯ͠Δײ͡

Slide 24

Slide 24 text

24 Prefab ͔Βͷ Spawn Process flow wύϥϝʔλ౉ͯ͠ॳظԽ͍ͨ͠৔߹ʹ 'BDUPSZ࢖͏ wγϯϓϧʹ*OTUBOUJBUF͢Δ͚ͩͳΒ 'BDUPSZφγͰ΋0, w6OEFS5SBOTGPSN Ͱ਌΋ࢦఆՄೳ

Slide 25

Slide 25 text

25 ը໘ભҠ Process flow w$"'6WUJNFT;FOKFDUͷͨΊͷը໘ભҠઐ ༻ͷVNNΛ࣮૷ࡁ w!VNNDBGV@TDFOF wݱࡏ"TTFU#VOEMFඇରԠ wͦΜͳʹֻ͚࣌ؒͣʹରԠͰ͖Δʜͱʜࢥʜʜ
 ʢ͜͜Ͱϝοηʔδ͸్੾Ε͍ͯΔʣ

Slide 26

Slide 26 text

26 ը໘ભҠ Process flow w!VNNDBGV@TDFOFͷػೳͱͯ͠
 ґଘγʔϯͷࣗಈಡࠐΛ࣮૷ࡁ w&EJUPSͰࣗಈతʹ1BSFOU$POUSBDUT ΛಡΈࠐΉͱ͔΋ରԠࡁ w4DFOF4USBUFHZ-JTUBTTFUʹ
 ґଘؔ܎Λఆٛ

Slide 27

Slide 27 text

w͜Ε·Ͱ͸֤γʔϯʹ6*༻ͷΧϝϥΛ༻ҙ͍ͯͨ͠ ͕ɺඳըॱͷ໰୊Λճආ͢ΔͨΊͷڞ௨γʔϯΛ࡞੒ w!VNN[FOKFDU@VJTDFOF w6*$BNFSB$PPSEJOBUPSίϯϙʔωϯτΛ$BOWBT ʹ෇͚Ε͹ɺϤγφʹ3FOEFS$BNFSBΛมߋ͢Δ w;FOKFDUͷ1BSFOU$POUSBDUͱͯ͠6*Λઃఆ͢ Δඞཁ͋Γ 27 UI γʔϯ ηΫγϣϯλΠτϧ

Slide 28

Slide 28 text

28 UI γʔϯ ηΫγϣϯλΠτϧ [SerializeField] private SceneStrategyList sceneStrategyList; private ISceneStrategyList SceneStrategyList => sceneStrategyList; public override void InstallBindings() { // シーン読み込みに関する処理群を Install // Generics ナシの SceneInstall の場合 SimpleLoaderUseCase が Bind される // PreLoad/PostUnload の設定を流し込みたいので StrategicLoaderUseCase を利用 SceneInstaller.Install(Container); Container.QueueForInject(SceneStrategyList); // シーン読み込み戦略データを Bind // PreLoad/PostUnload の設定を仕込む Container .Bind>() .WithId(CAFU.Scene.Application.Constant.InjectId.UseCase.SceneStrategyMap) .FromInstance(SceneStrategyList.AsDictionary()); }

Slide 29

Slide 29 text

29 σʔλಡΈॻ͖ Process flow w΋ͷੌ͘γϯϓϧͳσʔλಡΈॻ͖༻ͷVNNΛ࣮૷ࡁ w!VNNDBGV@EBUB w*&OVNFSBCMFCZUFΛΰχϣΰχϣ͢Δ܅ wݱࡏɺϩʔΧϧετϨʔδͱͷର࿩ͷΈ w*$SFBUPSͱ͔*8SJUFSͱ͔ͷ$36%38ͳJOUFSGBDFΛ
 ੾ͬͯ͋ΔͷͰɺ͜ͷVNNΛ֦ு͍͚ͯ͠͹ׂͱࣗ༝ʹ
 σʔλૢ࡞͕Ͱ͖ΔͷͰ͸

Slide 30

Slide 30 text

30 σʔλಡΈॻ͖ Process flow w!VNNDBGV@EBUBΛ࢖͏ͱ͖͸ɺ *OTUBMMFSͰҎԼΛ#JOE wͲͷ3FQPTJUPSZΛ࢖͏ͷ͔ʁ wͲͷ%BUB4UPSFΛ࢖͏ͷ͔ʁ

Slide 31

Slide 31 text

31 σʔλಡΈॻ͖ Process flow // Repositories Container .BindInterfacesTo() .AsCached(); // DataStores Container .BindInterfacesTo() .AsCached();

Slide 32

Slide 32 text

32 σʔλಡΈॻ͖ Process flow [Inject(Id = Constant.InjectId.ResultListFileUri)] private Uri ResultListFileUri { get; } [Inject] private IAsyncCRUDHandler AsyncCRUDHandler { get; } private async void Read() { var bytes = await AsyncCRUDHandler.ReadAsync(ResultListFileUri); RankingEntitySubject.OnNext( ResultListEntityTranslator.Translate( bytes.FromByteArray() ) ); RankingEntitySubject.OnCompleted(); } private async void Write() { // 念のため ResultListEntity の生成準備を待つ await RankingEntitySubject; await AsyncCRUDHandler.UpdateAsync( ResultListFileUri, DataResultListStructureTranslator.Translate( RankingEntitySubject.Value ).ToByteArray() ); }

Slide 33

Slide 33 text

v2 → v3 ͷҠߦɾڞଘ 33

Slide 34

Slide 34 text

34 v2 → v3 ͷҠߦ Migration & Coexistence w!VNNDBGV@DPSFͷ.BKPS7FSTJPO Λʹͯ͠ZBSOJOTUBMM wར༻͢Δ"TTFNCMZ%FpOJUJPO'JMFT ΛVNN!DBGV@DPSF!Wʹ͢Δ

Slide 35

Slide 35 text

35 v2 ɾ v3 ͷڞଘ Migration & Coexistence w"TTFNCMZ%FpOJUJPO'JMFTΛ෼͚ͯ ͋ΔͷͰ҆৺҆શ wಉ࣌ʹ࢖͏৔߹JOUFSGBDFͷީิ͕
 ྆ํͷόʔδϣϯͷιϨ͕ग़ͯ͘Δ
 ͷͰ*%&্ͰΠϥοͱ͢Δ͔΋

Slide 36

Slide 36 text

Thank you for your listening !! 36