èªãåãæ¬ã®ååšãç¥ããææ³ãç¥ããèªåã®åŠã³ããããšãèšã
- èªåãã¹ãå šäœã®ä¿¡é Œæ§ãç¶æããããã«ã¯ã©ãããããããã¬ãªãåºæºã§ãã©ããããäœããã¹ã¢ãŒã«ã«åãåºããŠããã – ãã°ããŒTech https://logmi.jp/tech/articles/329185
æè¿è¯ãæ¬ãåºéããŠãç§ã®ä»äºãè ãããããªã©ã€ãã«ãåºãŠããŠããŸããäŸãã°ãåäœãã¹ãã®èãæ¹/䜿ãæ¹ããšããæ¬ããããŸãããã®æ¬ã¯å 容ãè¯éããŠãç§ããããã説æãããããšãã»ãšãã©ãã®æ¬ã«æžããŠãããããªäºæ ã«ãªã£ãŠããŸãããšãŠãè¯ãæ¬ãªã®ã§ããããã§ããç§ã®æŽ»èºã§ããé åãæããã«èãã§ããŠããããããè¯ãæ¬ã§ãã
- åç»ã¯ããã
- ã®æ¬¡ã®éšå
ããã§ãã®æ¬ãèªèããèå³ãæã£ãã
ãã³ãŒãã¬ãã¥ãŒãããšãã«äœ¿ãããã¬ãŒãºãæ¢ãããšå¿µé ã«ããã°èªãæã®ãšã£ãããã«ãªã£ãŠæããããä»ã«âãèªåãæ®æ®µæžããŠãããã¹ãã³ãŒãã¯æ¬ã®äžã§ã¯ã©ã®äœçœ®ã«ãããïŒã
ã©ããããã¿ãŒã³ã®ãã¹ããæžãã質ã®è¯ããã¹ãã»ã±ãŒã¹ãäœãæ¹æ³ãã¯åãæ±ã£ãŠãïŒå¢çå€ãšãã
èªãåãèªãã§ããéäžã«æ®ãããæ¬ã®å 容以å€ã«ã€ããŠã®ã¡ã¢
- ãã®æ¬ã«ã€ããŠ
- åäœãã¹ãã®èãæ¹/䜿ãæ¹ | ãã€ããããã¯ã¹ https://book.mynavi.jp/ec/products/detail/id=134252
- åäœãã¹ãã®èãæ¹/䜿ãæ¹ https://amzn.to/4cOZcHA
- ãåäœãã¹ãã®èãæ¹/䜿ãæ¹ãïœææ³ã»ã¬ãã¥ãŒã»è©Šãèªã¿ – èªæžã¡ãŒã¿ãŒ https://bookmeter.com/books/20438696
- åç»ã®äžã§çŽ¹ä»ãããŠãããå¥ã®æžç±ãæ°ã«ãªã£ãããã¹ãã®å€§ããã®èãæ¹ãããææ§ãã®å°ãªãåé¡ããã¹ããµã€ãºã
- èªåãã¹ãã®çš®é¡ã®ææ§ããå°ãªãããã¹ããµã€ãºããšããåé¡ãã¹ã³ãŒããšã®æãåããã§ãããâã³ã¹ãã®è¯ããã¹ãâ – ãã°ããŒTech https://logmi.jp/tech/articles/329184
- Googleã®ãœãããŠã§ã¢ãšã³ãžãã¢ãªã³ã° âæç¶å¯èœãªããã°ã©ãã³ã°ãæ¯ããæè¡ãæåãããã»ã¹ https://amzn.to/3LvGrga
- èªãã 人ã®ææ³ããŸãšã
- åäœãã¹ãã®èãæ¹/䜿ãæ¹ã®ã¡ã¢ã»åäœãã¹ãã«ã€ããŠåŠãã ããšïœããŒãŽãŒ https://note.com/kubopi/n/n6715a813ef1b
- åäœãã¹ãã®èãæ¹/䜿ãæ¹ããŸãšã https://zenn.dev/yudai64/articles/c1f7fba3c93536
- åäœãã¹ãã®èãæ¹/䜿ãæ¹ãèªãã ãèªãã§ããã£ãã – Mitsuyuki.Shiiba https://bufferings.hatenablog.com/entry/2024/08/02/010813
- èªæžäžã ããæ¬ã«æžãããŠããå
容ã身ã«ã€ããããããªãããšããæãã®åèããŒãž
- ãt-wadaãèªåãã¹ãã®ãåãããªãããæãŸããæ¯çã«è¿ã¥ããæ¹æ³ãDeveloper eXperience Day 2024 ã¬ããŒãã | ã¬ãããã¯ã©ãïŒã¬ãããã¯LABïŒ https://levtech.jp/media/article/column/detail_496/
- ãã¹ããæžãæ¹éãšååã®åå¿é² #ãã¹ãèªåå – Qiita https://qiita.com/nsym__m/items/a796d16c3999a1801dba
- (5) éçºçç£æ§ã®èŠ³ç¹ããèããèªåãã¹ã / ã¿ã¯ãŒãºã»ã¯ãšã¹ãæ ªåŒäŒç€Ÿ åç° å人 – YouTube https://youtu.be/ueqjypYJnxk?si=QzqvZPH53DbOQThm
- (5) ãDXD2024ãæãŸããèªåãã¹ããšã¯: ã©ã®ãããªãã¹ããéçºçç£æ§ãšéçºè äœéšãå ±ã«é«ããã®ãïŒ7/16 16:00ã16:45ïŒ – YouTube https://youtu.be/8MiWDWAG1XQ?si=iE0439H0NG8vDuuB
æ¬ãæã«åã£ãŠã¿ãŠ
ååããŠãæåãå°ããïŒæ¬æžã®çŽåã«èªãã æ¬ãããïŒã399ããŒãžããã
ææ³
第1éš: åäœïŒunitïŒãã¹ããšã¯ïŒ
第1ç« ãªããåäœ(unit)ãã¹ããè¡ãã®ãïŒ
第2ç« åäœãã¹ããšã¯äœã
å®éèªåãæžããŠãããã¹ãã³ãŒãã«ã¯ãå€å žåŠæŽŸãšãã³ãã³åŠæŽŸã®äžéäœã®ãšããã«ãªããšæããã§ã¯äœãå¢ç®ã«ãªãã®ããäŸãã°å€éšãžã®åãåãããã¬ã¹ããã«APIãšããããšãããåºæºã«ãªãã®ã§ã¯ãªããããããŠãããã£ãå¢ç®ã¯ãã°åºåãããããã®åºæºã«ããªãã®ã§ã¯ãªããã
以äžã®ããã«å°ãèªãã§äºæ³ããã
èªåãæ®æ®µæžããŠããã®ã¯ãæ¬æžã®å®çŸ©ã§ã¯ãããããŠããããã¹ãã«ã¯åœãŠã¯ãŸããªãã£ããçµ±åãã¹ãã«åœãŠã¯ãŸã£ããèªåã®æžããŠããçµ±åãã¹ãã¯ã1åäœã®æ¯ãèããæ€èšŒããããšãã匷ãæèãããã®ã§ããä»ã®ãã¹ãã»ã±ãŒã¹ããéé¢ãããç¶æ ã§å®è¡ãããããšããæºããããã«æžããŠãããèªåã®æžããã¹ãã³ãŒãã¯ããã»ã¹å€äŸåãããŒã¿ããŒã¹ããåºæ¬çã«åãã§ãããããã«ãããå®è¡æéãçãããšããæºããã«ããããã€ã³ã¡ã¢ãªã®SQLite ã䜿ãããšã§å®è¡æéãçãããåªåãããŠããããã ãã1åäœã®æ¯ãèãããã¹ãããããã®åæãè€éã«ãªãäºåæºåã®ããŒã¿ããŒã¹ã¬ã³ãŒããå¢ããããšã§å®è¡æéãåŸã ã«é·ããªã£ãŠããããšããçµéšãããããã£ãŠãæåã¯ãŠããããã¹ãã®æ¡ä»¶ãæºãããŠããããã·ã¹ãã ã倧ãããªãã«ã€ãå®è¡æéãçãä¿ã€ããšãã§ããªããªãããŠããããã¹ãã§ã¯ãªããªãããšãã圢ãšãªãã
ãŸããäŸåã®ç« ã®å 容ãããèªåã®æžããã¹ãã¯å€å žåŠæŽŸãã³ãã³åŠæŽŸã©ã¡ãã«ãå±ããªãããšãããã£ããã€ãŸããèªåã¯å ±æäŸåããã©ã€ããŒãäŸåããã©ã¡ãããã¹ãã»ããã«ã«çœ®ãæããŠããªãããšæã£ãããã€ã³ã¡ã¢ãªSQLiteã¯ã¡ãœããã®åºŠã«ãªã»ããããŠãããã¹ãéã§å ±æããŠããªãã®ã§ããŒã¿ããŒã¹ã¯ããããå ±æäŸåã«ãªã£ãŠããªãã£ãã
第3ç« åäœãã¹ãã®æ§é ç解æ
3.1.2 åäœãã¹ãã«ãããŠåé¿ãã¹ãããš åããã§ãŒãºãè€æ°çšæããããš
ãè€æ°ã®æ¯ãèããæ€èšŒããŠãããããã¯ã ãã
1ã€ã®ãã¹ãã»ã±ãŒã¹ã®äžã«ãè€æ°ã®å®è¡ãã§ãŒãºãšç¢ºèªãã§ãŒãºãååšããã®ã§ããã°ããã®ãã¹ãã»ã±ãŒã¹ãåå²ããŠã1ã€ã®å®è¡ãã§ãŒãºãš1ã€ã®ç¢ºèªãã§ãŒãºãæã€ãã¹ãã»ã±ãŒã¹ãè€æ°äœæããããã«ããŸãã
å®è·µãšããŠã¯ããã®ããã«ã³ãŒããæ¹åããã
ããã«ããã¹ãã»ã±ãŒã¹ã®ç解ã®ãããããä¿å®ã®ããããã®èŠ³ç¹ããèãããšãåããã§ãŒãºãè€æ°æã€ãããª1ã€ã®ãã¹ãã»ã±ãŒã¹ããããåãã§ãŒãºã1ã€ãããªãè€æ°ã®ãã¹ãã»ã±ãŒã¹ã®æ¹ãåªããŠããŸãã
æ¹åããå ã«ã¯ç解ãä¿å®ã«ã¡ãªãããçãŸããã
3.1.5 確èª(Assert)ãã§ãŒãºã§ç¢ºèªããé ç®ã¯ã©ã®ãããããã°è¯ãã®ãïŒ
1åäœã®æ¯ãèãã«ãã£ãŠãè€æ°ã®çµæãçããäºã¯ããåŸãããšã§ããã1ã€ã®ãã¹ãã»ã±ãŒã¹ã§ãã®çµæãå šãŠæ€èšŒããäºã¯èªç¶ãªããšãªã®ã§ãã
httpã¬ã¹ãã³ã¹ãããŒã¿ããŒã¹ã®äžèº«ãšãã£ãè€æ°ã®èŠ³ç¹ã®ç¢ºèªããããããã®èŠ³ç¹ã®äžã§è€æ°ã®é ç®ã確èªããäºã¯ãããã£ãŠããããããã¯åé¡ãªããšèšãèªä¿¡ãã€ããã
3.2 åäœãã¹ãã®ãã¬ãŒã ã¯ãŒã¯ã«ã€ããŠ
æ¬æžã§ã¯ãåäœãã¹ããäœæããéããã®ããã«èããããšãæšå¥šããŠããŸãããªããªããåäœãã¹ãã§ãã¹ãäºã¯ããããã¯ã·ã§ã³ã»ã³ãŒããäœãããããåã«åæããããšã§ã¯ãªããã¢ããªã±ãŒã·ã§ã³ã®æ¯ãèãã«ã€ããŠããé«ãã¬ãã«ã§æåããããšã ããã§ãããããŠãçæ³ãªã®ã¯ãåäœãã¹ãã§è¡šçŸããŠããããšãéçºè ã ãã§ãªããééçºè ã«ãäŒããããšã§ãã
ãã¹ãã±ãŒã¹ã«ã¯ã·ããªãªãç©èªãã¹ããŒãªãŒããèªãããšã倧äºã
3.3.2 ã³ã³ã¹ãã©ã¯ãã®å©çšã¯ãã¹ãã»ã±ãŒã¹ã®èªã¿ããããæãªãããŠããŸã
æºå(Arrange)ãã§ãŒãºã®ã³ãŒããã³ã³ã¹ãã©ã¯ã¿ã«æã£ãŠããããšã®ããäžã€ã®æ¬ ç¹ã¯ãã¹ãã»ã¡ãœãããèªã¿ã¥ãããªã£ãŠããŸãããšã§ãããªããªãããã¹ãã»ã¡ãœããã ããèŠãŠããæºåãã§ãŒãºã®ããžãã¯ãããã«ã¯ãªãããã
ã ãããããããã¡ã¯ããªãŒã»ãããçšæããŠããã¹ãã¡ãœããã®æåã«æžãããšã§æ瀺ãããšèšãããšãç解ãã§ããã
3.3.3 ãã¹ããã£ã¯ã¹ãã£ãŒã«é¢ããã³ãŒããå ±æããããã®ããè¯ãæ¹æ³
å ±éçã«å©çšãããã¹ãã»ãã£ã¯ã¹ãã£ã®æºåã«é¢ããã³ãŒãããã©ã€ããŒããªãã¡ã¯ããªã»ã¡ãœããã«å®çŸ©ããããšã§ããã¹ãã»ã³ãŒãã®éãæžããã®ãšåæã«åãã¹ãã»ã±ãŒã¹ã§äœãè¡ãããããå®å šã«ç解ã§ããããã«ãªããŸãã
3.4.2 æéã«åŸã£ãååã«å€ããå Žåã®äŸ
ã³ã©ã ãªãããã¹ã察象ã®ã¡ãœããåããã¹ãã»ã¡ãœããåã«å«ããã¹ãã§ã¯ãªãã®ãïŒ
ãã¹ã察象ã®ã¡ãœããåã¯ãã¹ãã»ã¡ãœããåã«å«ããã¹ãã§ã¯ãããŸããããã®çç±ã¯ãåäœãã¹ãã¯ã³ãŒã«ããã¹ãããŠããã®ã§ã¯ãªããã¢ããªã±ãŒã·ã§ã³ã®æ¯ãèãããã¹ãããŠããããã§ãã
ããããªããããã¹ãã¡ãœããåã«ãshould be(ã¹ãã§ãã)ããšã€ããäºã¯ããããã¢ã³ãã»ãã¿ãŒã³ã®1ã€ã§ã
ãã®ããããã¹ãã±ãŒã¹ã«ã¯ãäºå®ã«åºã¥ããååãã€ããã¹ãã§ãããã¹ãã§ãã(should be)ãããã§ãã(is)ãã«å€ããªããŠã¯ãªããŸãã
第2éš: åäœãã¹ããšãã®äŸ¡å€
第4ç« è¯ãåäœãã¹ããæ§æãã4æ¬ã®æ±
ã©ãããã°ã䟡å€ã®ãããã¹ãã»ã±ãŒã¹ãèªèã§ããããã«ãªãã®ã
4.1.1 1æ¬ç®ã®æ±: 察æ(regression)ã«å¯Ÿããä¿è·
éè¡ã§ææªãªã®ã¯ãæ±ã£ãŠããæ©èœãå¢ããã»ã©ãæ°ããªæ©èœãéçºãããã³ã«ãæ¢åã®æ©èœã®æ¯ãèãããããããªã£ãŠããŸãããšã§ãã
èªèº«ã®çµéšã§ã¯ããã°ã¬ãŒãããã°ã¬ãªã©ãšåŒãã§ãããããšåãããšã ãšæãã
4.1.2 2æ¬ç®ã®æ±: ãã¡ã¯ã¿ãªã³ã°ãžã®èæ§
ãã¡ã¯ã¿ãªã³ã°ãžã®èæ§ = åœéœæ§(false positive)ããªããã
- åœéœæ§: ç«ãåºãŠããªãã®ã«(ã³ãŒããæ£ããã®ã«)ç«çœå ±ç¥åšã鳎ã(ãã¹ãã倱æãã)ã
- åœé°æ§: ç«ãåºãŠããã®ã«ãç«çœå ±ç¥åšããªããªãã
åœéœæ§ã«ãã£ãŠãã¹ããå®æœããããšèªäœã®æå³ãæãããŠããŸããã
ãã¹ã察象ã®ã³ãŒããæ£ããæ¯ãèã£ãŠããã®ã«ããããããããã¹ãã倱æãããããªããšãç¶ããšãéçºè ã¯ãã®ããšã«æ £ããŠããŸãããã¹ãçµæãéèŠèŠããªããªãããã§ããã
4.1.3 äœãåœéœæ§(false positive)ãåŒãèµ·ããã®ãïŒ
åœéœæ§ãçã¿åºãå¯èœæ§ãæžããå¯äžã®æ¹æ³ã¯ãã¹ãã»ã³ãŒãããã¹ã察象ã®å éšçãªã³ãŒãããåãé¢ãããšã§ãã
ãã¹ãã»ã³ãŒãããã¹ã察象ãšãªãã³ãŒãã®è©³çŽ°ãšæ·±ãçµã³ã€ããšããªãã¡ã¯ã¿ãªã³ã°ãžã®èæ§ããªããªãããšããããšãããããŸãã
4.1.4 å®è£ ã®è©³çŽ°ã§ã¯ãªããæçµçãªçµæã確èªãã
質ã®è¯ããã¹ã:æçµçãªçµæã¯æ£ãããïŒ
質ã®æªããã¹ã:æé ã¯æ£ããã®ãïŒ
4.2 éè¡(regression)ã«å¯Ÿããä¿è·ãšãªãã¡ã¯ã¿ãªã³ã°ãžã®èæ§ãšã®é¢ä¿
ãããžã§ã¯ããå§ãŸã£ãŠãããã«éè¡ã«å¯Ÿããä¿è·ãåããããšãéèŠãšãªãã®ã«å¯Ÿãããªãã¡ã¯ã¿ãªã³ã°ãžã®èæ§ã¯ããã«å¿ èŠãšãªãããã§ã¯ãããŸããã
4.2.1 ãã¹ãã®æ£ç¢ºæ§ãæ倧éã«ããããš
ããšãã°ãã€ã³ãã«ãšã³ã¶ã®æ€æ»ãåãã人ãæ¬åœã«ã€ã³ãã«ãšã³ã¶ã«ããã£ãŠããå Žåããã®æ€æ»çµæã¯éœæ§ (positive) ãšãªããŸãã
éã«ãæ£è ãã€ã³ãã«ãšã³ã¶ã«ããã£ãŠããªãã®ã§ããã°ããã®æ€æ»ã§åå¿ã瀺ããŠã¯ãªãããæ€æ»çµæã¯é°æ§ (negative) ãšãªããªããŠã¯ãªããŸããã
4.2.2 åœéœæ§ (false positive) ãšåœé°æ§ (false negative) ã®éèŠæ§ã®éã
ããã§ã¯ããªãããããžã§ã¯ãã®åæ段éã«ãããŠãå©çšæ§ã¯ããã»ã©å€§ããªåŒå®³ã«ãªããªãã®ã§ããããïŒãã®çç±ã¯ããããžã§ã¯ãã®åæ段éã«ã¯ãªãã¡ã¯ã¿ãªã³ã°ãããå¿ èŠæ§ããªãããšã«ãããŸãã
ã»ãšãã©ã®éçºè ã¯ãåœéœæ§ã®ããšãåé¡ãšããŠã¯èªèããŠããŸããããªããªããå€ãã®éçºè ã¯1æ¬ç®ã®æ±ã§ããéè¡ã«å¯Ÿããä¿è·ã ãã«ç®ã奪ãããŠããŸãããã§ãã
4.4 çæ³çãªãã¹ãã®æ¢æ±
èŠããŠãããŠã»ããã®ã¯ããã¹ãã»ã³ãŒããå«ãããã¹ãŠã®ã³ãŒãã¯è² åµã§ãããšããããšã§ãã
4.4.2 極端ãªäŸ #1: E2E (End-to-End) ãã¹ã
ããããªããããã®ãããªå¹æãããã®ã«ãããããããE2Eãã¹ãã«ã¯å€§ããªæ¬ ç¹ããããŸããããã¯ãã¹ããå®è¡ãçµãããŸã§ã«æéãããã£ãŠããŸãããšã§ãã
4.4.4 極端ãªäŸ #3: å£ãããããã¹ã
åæ§ã«ãå®è¡æéãçããéè¡ãèŠã€ããããšã«åªããŠã¯ããŠããå€ãã®åœéœæ§ãæã¡èŸŒãã§ããŸããã¹ããç°¡åã«äœæã§ããŠããŸããŸãããã®ãããªãã¹ãã®ããšãæ¬æžã§ã¯å£ãããããã¹ããšåŒãã§ããŸãã
4.4.5 çæ³çãªãã¹ãã«é¢ããçµè«
ããããªãããçŸå®ã«ãããŠãªãã¡ã¯ã¿ãªã³ã°ãžã®èæ§ãç ç²ã«ããããšã¯ã§ããŸããããªããªããªãã¡ã¯ã¿ãªã³ã°ãžã®èæ§ã¯å¯èœãªéãåããªããŠã¯ãªããªãæ§è³ªã ããã§ãããã®ããã«ã¯äœæãããã¹ãã»ã±ãŒã¹ã«å¯ŸããŠååãªå®è¡é床ãæãããªããŠã¯ãªããŸãããã€ãŸãE2Eãã¹ãã ãã§ãã¹ãã»ã¹ã€ãŒããæ§æãããããªããšã¯ããŠã¯ãªããªããšããããšãªã®ã§ãã
4.5.1 ãã¹ãã»ãã©ããã
ãã¹ããã©ããããåäœãã¹ããçµ±åãã¹ããEZãã¹ãã®3çš®é¡ã«ãã£ãŠæ§æããŠãããGoogleã®ãœãããŠã§ã¢ãšã³ãžãã¢ãªã³ã°ã®æ¬ã«ãã£ããµã€ãºã«ããåé¡åãã§ã¯ãªããæ¬æžã®æ¹ãå€ãïŒåœããåãªã®ã ããèè ãæžããæç¹ã§ã®æ å ±ãªã®ã§ããæ°ããæ å ±ã¯èŒã£ãŠããªãããã®æ¬ã«ã¯ãããè¯ãããšãæžããŠãããäžæ¹ã§ãã®æ¬ã®å 容ãããããé³è åããŠããã®ã ããããã®æ¬ä»¥å€ã®æ¬ãèªãã§ããããšã§ããã®ãããªããšãæãããããèªæžã®é¢çœããããããã¯ããããèãæ¹ãéãïŒ
4.5.2 ãã©ãã¯ã»ããã¯ã¹ã»ãã¹ããšãã¯ã€ãã»ããã¯ã¹ã»ãã¹ã
ãã ããããã§å¿ã«çããŠãããŠæ¬²ããã®ã¯ããã¹ããåæããéã¯ããã¯ã€ãã»ããã¯ã¹ã»ãã¹ãã®ææ³ãçšããããšãã§ãããšããããšã§ãã
ãã®ããã«ããã©ãã¯ã»ããã¯ã¹ã»ãã¹ããšãã¯ã€ãã»ããã¯ã¹ã»ãã¹ããçµã¿åãããããšã§ããã¹ãã»ã¹ã€ãŒãã®è³ªãããé«ããããããã«ãªããŸãã
ãŸãšã
åœéœæ§ã¯ããã¹ãã»ã±ãŒã¹ããã¹ã察象ã®å éšçãªã³ãŒããšçµã³ã€ãããšã§çºçããã
ãªãã¡ã¯ã¿ãªã³ã°ãžã®èæ§ãæé€ããããšã¯ã§ããªãããªããªãããã®æ±ã¯ãã¹ãã»ã±ãŒã¹ã«åãããåŠãã®éžæããã§ããªãããã§ããã
第5ç« ã¢ãã¯ã®å©çšãšãã¹ãã®å£ãããã
äžæ¹ãå€å žåŠæŽŸã§ã¯åäœãã¹ãã®ãã¹ãã»ã±ãŒã¹èªäœãéé¢ãã¹ãã ãšèããŠãããããããããšã§ãè€æ°ã®ãã¹ãã»ã±ãŒã¹ãåæã«å®è¡ã§ããããã«ããããšãæå±ããŠããŸãã ãã®ãããå€å žåŠæŽŸã§ã¯ãã¹ãã»ã±ãŒã¹éã§å ±æãããäŸåã«å¯ŸããŠã®ã¿ãã¹ãã»ããã«ã䜿ãããã«ããŠããŸãã
5.1.1 ãã¹ãã»ããã«ã®çš®é¡
ãã¹ãã»ããã«ãšã¯ããããã¯ã·ã§ã³ã»ã³ãŒãã«ã¯å«ãŸããããã¹ãã§ãã䜿ãããªãåœãã®äŸåãšããŠè¡šçŸããããããã¹ãŠã®ãã®ãå æ¬çã«æå³ãããã®ã§ãããã®çšèªã¯ãæ ç»ã®ã¹ã¿ã³ããã³ (è±èªã ãšãstunt doubleã) ãèªæºãšããŠããŸãã
ã¢ãã¯ã¯ããã¹ã察象ã·ã¹ãã ãããã®äŸåã«åãã£ãŠè¡ãããå€éšã«åããã³ããã±ãŒã·ã§ã³(åºå)ãæš¡å£ãããããŠãæ€èšŒããã®ã«äœ¿ãããã
ã¹ã¿ãã¯äŸåãããã¹ã察象ã·ã¹ãã ã«åãã£ãŠè¡ãããå éšã«åããã³ããã±ãŒã·ã§ã³(å ¥å)ãæš¡å£ããã®ã«äœ¿ãããã
- ãã¹ãã»ããã«
- ã¢ãã¯: ã¡ãŒã«éä¿¡ãå¯äœçšãçºçããããæ€èšŒæã«äœ¿ãããã
- ã¹ã¿ã: ããŒã¿ããŒã¹ããããŒã¿ååŸãå¯äœçšã¯çºçããªããæ€èšŒæã«äœ¿ãããªãã
ãã®ããšã«å ããã¢ãã¯ã¯ãã¹ã察象ã·ã¹ãã ãšãã®äŸåãšã®ã³ãã¥ãã±ãŒã·ã§ã³ãæš¡å£ããã ãã§ã¯ãªããæ€èšŒãè¡ãã®ã«å¯Ÿããã¹ã¿ãã¯ãã¹ã察象ã·ã¹ãã ãšãã®äŸåãšã®ã³ãã¥ãã±ãŒã·ã§ã³ã®æš¡å£ã ãããè¡ããªããšèšãéãããããŸãã
5.1.3 ã¹ã¿ãããšã®ã³ãã¥ãã±ãŒã·ã§ã³ã¯æ€èšŒããªã
ãã¹ãã®èŠ³ç¹ã«ãããŠããã¹ã察象ã®ã³ãŒããæ£ããçµæãè¿ãéããæçµçãªçµæãã©ã®ããã«äœæããŠããã®ãã«ã€ããŠã¯ç®ãåããå¿ èŠã¯ç¡ãã®ã§ãã
ã¹ã¿ãã«å¯ŸããŠã¯ããããªãã³ãã¥ãã±ãŒã·ã§ã³ã§ãã£ãŠããæ€èšŒãã¹ãã§ã¯ãããŸãããã
5.1.5 ã¢ãã¯ãšã¹ã¿ããããããã©ã®ããã«ã³ãã³ããšã¯ãšãªã«çµã³ã€ãã®ã?
ã¢ãã¯ãšã¹ã¿ãã®èãæ¹ã¯ãã³ãã³ãã»ã¯ãšãªåé¢ (Command Query Separation: CQS) ã®ååãšã®é¢é£æ§ããããŸãã ã³ãã³ãã»ã¯ãšãªåé¢ã®ååã§ã¯ã次ã®å³5.3ã§ç€ºãããã«ããã¹ãŠã®ã¡ãœããã¯ã³ãã³ããã¯ãšãªã®ã©ã¡ããã«ãªãã¹ãã§ãããäž¡æ¹ã®æ§è³ªãæã€ã¹ãã§ã¯ãªãããšããããšãæå±ããŠããŸãã
- ã³ãã³ã(å¯äœçšæããæ»ãå€ç¡ã) â ã¢ãã¯
- ã¯ãšãª(å¯äœçšç¡ããæ»ãå€æã) â ã¹ã¿ã
5.2.1 芳å¯å¯èœãªæ¯ãèããšå ¬éãããAPIãšã®éã
çæ³ãªã®ã¯ãã·ã¹ãã ãå ¬éããŠããAPIã芳å¯å¯èœãªæ¯ãèããšäžèŽãããã®äžæ¹ã§ããã®ã·ã¹ãã ã®ãã¹ãŠã®å®è£ ã®è©³çŽ°ãã¯ã©ã€ã¢ã³ãããå®å šã«é ããããã«ãªã£ãŠããããšã§ãã
5.2.3 ãã¡ããšèšèšãããAPIãšã«ãã»ã«å
çµå±ã®ãšãããã«ãã»ã«åãç®æããŠããã®ã¯åäœãã¹ããšåããœãããŠã§ã¢éçºã®æç¶å¯èœãªæé·ãªã®ã§ãã
ãããšåããããªååã«ãå°ãããªåœãã(Tell, Donât Ask)ããšãããã®ããããŸãã
5.3.2 ã·ã¹ãã å ã³ããã±ãŒã·ã§ã³ãšã·ã¹ãã éã³ããã±ãŒã·ã§ã³
ãããŠããã®èŠ³å¯å¯èœãªæ¯ãèãã¯ãã¹ã察象ã®ã¢ããªã±ãŒã·ã§ã³ãåžžã«å°å®ããªããã°ãªããªãå¥çŽã®äžéšãªã®ã§ã(å³5.12)ã
ãããŠãã®ãããªã·ã¹ãã éã³ããã±ãŒã·ã§ã³ãæ€èšŒããã®ã«å¹æãçºæ®ããã®ãã¢ãã¯ã«ãªããŸããããããªããããããã¢ãã¯ãã·ã¹ãã å ã³ããã±ãŒã·ã§ã³ã®æ€èšŒã«äœ¿ã£ãŠããŸããšããã¹ããå®è£ ã®è©³çŽ°ãšæ·±ãçµã³ã€ããŠããŸãããªãã¡ã¯ã¿ãªã³ã°ãžã®èæ§ã倱ãããšã«ãªããŸãã
5.4.1 ã¢ãã¯ã«çœ®ãæããå¿ èŠã®ãªãããã»ã¹å€äŸå
ãšãããããã®ãããªå®å šã«å¶åŸ¡å¯èœãªããã»ã¹å€äŸåãã¢ãã¯ã«çœ®ãæããŠæ€èšŒããããšããã®ãã¹ãã»ã±ãŒã¹ã¯å£ãããããªã£ãŠããŸããŸãã
ãã®ããããã®ãããªããŒã¿ããŒã¹ãšã¢ããªã±ãŒã·ã§ã³ã¯ã1ã€ã®ã·ã¹ãã ãšããŠæ±ãããªããã°ãªããŸããã
ãŸãšã
ãããŠãã³ãã³ããšã¯ãšãªããã¹ãã»ããã«ã«çœ®ãæããå Žåãã³ãã³ãã®ä»£ããã«ãªãã®ãã¢ãã¯ã§ãããã¯ãšãªã®ä»£ãããšãªãã®ãã¹ã¿ãã§ããã
â ã³ãã³ãã»ã¯ãšãªåé¢ (Command Query Separation: CQS)
第6ç« åäœãã¹ãã®3ã€ã®ææ³
ãŠããããã¹ãåŽã®èŠç¹ããããããã¯ã·ã§ã³ã³ãŒãã®ã¢ãã³ãªããã°ã©ãã³ã°ã®ããæ¹ã«ãèžã¿èŸŒãã§ãããè¯ãã
6.1.3 ã³ãã¥ãã±ãŒã·ã§ã³ã»ããŒã¹ã»ãã¹ããšã¯?
å€å žåŠæŽŸã¯ã³ãã¥ãã±ãŒã·ã§ã³ã»ããŒã¹ã»ãã¹ããããç¶æ ããŒã¹ã»ãã¹ãã®æ¹ãè¡ãã®ã«å¯Ÿãããã³ãã³åŠæŽŸã¯ã³ãã¥ãã±ãŒã·ã§ã³ã»ããŒã¹ã»ãã¹ãã®æ¹ã奜ã¿ãŸãã
6.3.1 é¢æ°åããã°ã©ãã³ã°ãšã¯?
å¯äœçšãšã¯ã¡ãœããã»ã·ã°ããã£ã«ã¯è¡šçŸãããŠããªãåºåã®ããšã§ãããã€ãŸããå¯äœçšã¯é ããåºåãæå³ããã
ã€ãŸããäŸå€ã¯ã¡ãœããã»ã·ã°ããã£ã«ã¯å®çŸ©ãããŠããªãé ããåºåãæå³ããããšã«ãªãã
ã€ãŸãããã®ãããªããšãããã¡ãœããã«ã¯é ããå ¥åãååšããããšã«ãªãã
6.3.2 é¢æ°åã¢ãŒããã¯ãã£ãšã¯äœãïŒ
é¢æ°åããã°ã©ãã³ã°ãç®æšãšããŠããäºã¯ãå¯äœçšãå®å šã«åãé€ãããšã§ã¯ãªããããžãã¹ã»ããžãã¯ãæ±ãã³ãŒããšå¯äœçšãèµ·ããã³ãŒããåé¢ããããšã«ãããŸãã
ãã®ãããäž¡æ¹ã®è²¬åã1ã€ã®ã¡ãœããã«æ··ãã£ãŠããŸããšãè€éããåå¢ããã³ãŒããé·ãéä¿å®ããããšãé£ãããªã£ãŠããŸããŸãã
èšãæãããšãå¯å€æ®»ã¯å¯èœãªéãæ瀺ãããããšã ãããè¡ããªããããªäœãã«ããããšããããšã§ãã ããããããšã§ãåäœãã¹ãã¯åºåå€ããŒã¹ã»ãã¹ããçšããŠé¢æ°çæ žã ããæ€èšŒã§ããããã«ãªããŸãã äžæ¹ãå¯å€æ®»ã®æ€èšŒã¯ããã¹ãã±ãŒã¹ãåäœãã¹ããããå°ãªãçµ±åãã¹ãã«ä»»ããããã«ããŸãã
6.3.3 é¢æ°åã¢ãŒããã¯ãã£ãšãããµãŽãã«ã»ã¢ãŒããã¯ãã£ã®æ¯èŒ
é¢æ°åã¢ãŒããã¯ãã£ãšãããµãŽãã«ã»ã¢ãŒããã¯ãã£ã«ã¯å€ãã®é¡äŒŒç¹ããããäž¡æ¹ãšãé¢å¿ã®åé¢ (separation of concerns) ãåºç€ãšãªã£ãŠããŸãã
ããã«ãä»ã®é¡äŒŒç¹ãšããŠãäŸåã®æµããäžæ¹åã«ãªã£ãŠãããšããããšããããŸãã
é¢æ°åã¢ãŒããã¯ãã£ã§ã¯ããã¹ãŠã®å¯äœçšãé¢æ°çæ žã®å€ã«åºããããžãã¹ã»ãªãã¬ãŒã·ã§ã³ã®æåãæåŸã«æã¡èŸŒãããã«ããŸãã äžæ¹ããããµãŽãã«ã»ã¢ãŒããã¯ãã£ã§ã¯ããã¡ã€ã³å±€å ã«éå®ãããéããå¯äœçšãèµ·ããããšãèš±ãããŠããŸãã
6.4 é¢æ°åã¢ãŒããã¯ãã£åã³åºåå€ããŒã¹ã»ãã¹ããžã®ç§»è¡
ã©ã®ããã«é¢æ°åã¢ãŒããã¯ãã£ãšãªãããã«ããªãã¡ã¯ã¿ãªã³ã°ãããã®ãããšããããšãèŠãŠãããŸãã ãã®ãã¡ã¯ã¿ãªã³ã°ã¯æ¬¡ã®2ã€ã®ç§»è¡ãé ãèžãã§è¡ãããšã§å®æœãããŸã:
- ããã»ã¹å€äŸåã®å©çšããã¢ãã¯ã®å©çšãžã®ç§»è¡
- ã¢ãã¯ã®å©çšãããé¢æ°åã¢ãŒããã¯ãã£ã®å©çšãžã®ç§»è¡
6.4.1 ãµã³ãã«ã»ãããžã§ã¯ã(蚪åè èšé²ã·ã¹ãã )ã«ã€ããŠ
ãã¹ããè¡ãã¥ãããªã£ãŠããåå ã¯ããã¡ã€ã«ã»ã·ã¹ãã ãçŽæ¥æ±ã£ãŠããããšã«ãããŸãããªããªãããã®ãã¡ã€ã«ã·ã¹ãã ã¯å ±æäŸåã§ããããã ãããä»ã®ãã¹ãã»ã±ãŒã¹ããã®ãã¡ã€ã«ã»ã·ã¹ãã ã«å¯ŸããŠäœããã®æäœãè¡ãã®ã§ããã°ããã®ããšã«é¢ããŠäœããã®å¯ŸçãããªããŠã¯ãªããªãããã§ãã
6.4.2 ã¢ãã¯ãçšããããšã«ããåäœãã¹ããšãã¡ã€ã«ã»ã·ã¹ãã ã®åé¢
ããã§å¿ã«çããŠãããŠã»ããããšã¯ããããæ£åœãªã¢ãã¯ã®äœ¿ãæ¹ã§ããããšããããšã§ãã ãã®èšªåè èšé²ã·ã¹ãã ãäœæãããã¡ã€ã«ã¯ãšã³ãã»ãŠãŒã¶ãŒãããã¢ã¯ã»ã¹ãããããšãæ³å®ããããã®ã§ã
ãã®ããããã¡ã€ã«ã»ã·ã¹ãã ãšã®ã³ãã¥ãã±ãŒã·ã§ã³ãããã³ããã®éã«çºçããå¯äœçšã¯ã蚪åè èšé²ã·ã¹ãã ã®èŠ³å¯å¯èœãªæ¯ãèãã®1éšãšãªããŸãã
å çšã®ãªã¹ã6.11ã®ãã¹ãã»ã±ãŒã¹ã¯ãæºå (Arrange) ãã§ãŒãºã«èšè¿°ãããã³ãŒããä¿®æ£åãããè€éã«ãªã£ãŠãããããä¿å®ã³ã¹ãã®èŠ³ç¹ã§èšãã°ãçæ³çãªå®è£ ã«ã¯ãªã£ãŠããŸããã
6.4.3 é¢æ°åã¢ãŒããã¯ãã£ãžã®ãªãã¡ã¯ã¿ãªã³ã°
èŠã¯ãPersister ã¯ã©ã¹ãå¯å€æ®»(mutable shell)ãšããŠã®åœ¹å²ãæ ãäžæ¹ãAuditManager ã¯ã©ã¹ãé¢æ°çè§ (functional core) ãšããŠã®åœ¹å²ãæ ãããã«ããã®ã§ãã
ãããŠãã®ã¯ã©ã¹ã«ã¯ãæ¡ä»¶åå² (ifæ) ã¯ãããŸãããã€ãŸããããžãã¹ã»ããžãã¯ã«é¢ãããã¹ãŠã®è€éãã¯AuditManagerã¯ã©ã¹ãæ ãããšã«ãªãã®ã§ãããŸãã«ããã®ããšãããžãã¹ã»ããžãã¯ãšçºçããå¯äœçšã®åé¢ãªã®ã§ãã
é¢æ°çæ žã®å€ã«ããã³ãŒã (å¯å€æ®») ã¯ãè€éãªããšãããªããŠãæžãããã«ãªããŸãã
å³ 6.15 P198 å³ 6.14 ãšæµããåã!
6.5.1 é¢æ°åã¢ãŒããã¯ãã£ã®å°å ¥ãé£ããå Žå
第2ç« ã§èŠãããã«ãååè ãªããžã§ã¯ããšã¯ã次ã®æ§è³ªã1ã€ä»¥äžæã€äŸåã®ããšã§ã:
- å¯å€ã§ãã(ç¶æ ãå€ããããšãã§ãã)ããš
- ãŸã ã¡ã¢ãªäžã«ã¯ãªãããŒã¿ã®æ©æž¡ãããããã®(å ±æäŸå)ã§ããããš
NOTE: é¢æ°çæ ž (functional core) ã«å±ããã¯ã©ã¹ã¯ååè ãªããžã§ã¯ããšå ±ã«åŠçãè¡ãã®ã§ã¯ãªãããã®ååè ãªããžã§ã¯ãã«ãã£ãŠåŸãããçµæ(ã€ãŸããå€)ãçšããŠåŠçãããããã«ããŸãã
6.5.2 ããã©ãŒãã³ã¹ã«é¢ããæ¬ ç¹
ããããªãããé¢æ°åã¢ãŒããã¯ãã£ãšãªãããã«ä¿®æ£ããããŒãžã§ã³ã§ã¯ã蚪åè ã®èšé²ãè¿œå ããããã«ã¯ãæåã«ãã¹ãŠã®ãã¡ã€ã«ãèªã¿èŸŒãŸãªããŠã¯ãªããªãããã«ãªã£ãŠããŸã (é¢æ°åã¢ãŒããã¯ãã£ã®ãå ¥åããŒã¿ã®åéâ決å®âå®è¡ãã®åœ¢åŒã«æºæ ããããã)ã
6.5.3 ã³ãŒãããŒã¹ã倧ãããªã£ãŠããŸãæ¬ ç¹
é¢æ°åã¢ãŒããã¯ãã£ã§ã¯ãé¢æ°çæ ž (functional core) ãšå¯å€æ®» (mutable shell) ãæ確ã«åé¢ããããã«ãªã£ãŠãããããæåã¯å®è£ ããªããŠã¯ãªããªãã³ãŒãéãå€ããªããŸããããããªãããæçµçã«ã¯ãã³ãŒãã®è€éããæžããããä¿å®ã¯ãããããªããŸãã
ãã®ããã«åºåå€ããŒã¹ã»ãã¹ãã§ã¯ãªããã¹ãã»ã±ãŒã¹ãçšããäºã¯äœãåé¡ããªãã®ã§ããæ¬æžããã®ç« ã§èªè ã«æ±ããŠããããšã¯ããã¹ãŠã®ãã¹ãã»ã±ãŒã¹ãåºåå€ããŒã¹ã»ãã¹ãã«ããããšã§ã¯ãªããã§ããã ãå€ãã®ãã¹ãã»ã±ãŒã¹ãåºåå€ããŒã¹ã»ãã¹ãã«ããããšããããšãªã®ã§ãããã®éãã¯ããããªéãã§ãããéèŠãªéãã§ãã
ãŸãšã
åºåå€ããŒã¹ã»ãã¹ããšã¯ããã¹ã察象ã·ã¹ãã ã«å ¥åå€ãäžããããã§çæãããçµæãæ€èšŒããåäœãã¹ãã®ææ³ã®ããšã§ããã
ç¶æ ããŒã¹ã»ãã¹ããšã¯ããã¹ã察象ã·ã¹ãã ãšååè ãªããžã§ã¯ãã®ç¶æ ãæ€èšŒããåäœãã¹ãã®ææ³ã®ããšã§ããã
ã³ãã¥ãã±ãŒã·ã§ã³ã»ããŒã¹ã»ãã¹ããšã¯ã¢ãã¯ã䜿ã£ãŠãã¹ã察象ã·ã¹ãã ãšååè ãªããžã§ã¯ãã®ã³ããã±ãŒã·ã§ã³ãæ€èšŒããåäœãã¹ãã®ææ³ã®ããšã§ããã
åºåå€ããŒã¹ã»ãã¹ããåäœãã¹ãã®3ã€ã®ææ³ã®äžã§ããã£ãšã質ã®é«ããã¹ãã±ãŒã¹ãäœæã§ããããã®çç±ã¯ããã¹ãã»ã±ãŒã¹ãå®è£ ã®è©³çŽ°ãšçµã³ã€ãããšãããŸããªãããããªãã¡ã¯ã¿ãªã³ã°ãžã®èæ§ããã¹ãã»ã±ãŒã¹ã«èªç¶ãšåããããã§ããã
ããšãã°ãåäœãã¹ããè¡ããããã«ããããããã©ã€ããŒãã®ç¶æ ãå ¬éãããããªäºã¯æ±ºããŠè¡ã£ãŠã¯ãªããªãã
ãã®ããã«ã¯ãæ€èšŒã®å¯Ÿè±¡ãšãªãã³ããã±ãŒã·ã§ã³ãã¢ããªã±ãŒã·ã§ã³ã®å¢çãè¶ ããŠè¡ããããã€ãå€éšãã確èªã§ããå¯äœçšãçºçãããå Žåã«ã®ã¿ãã³ããã±ãŒã·ã§ã³ã»ããŒã¹ã»ãã¹ããçšããããã«ããã
é¢æ°åããã°ã©ãã³ã°ãå°å ¥ããããšã§éæãããããšã¯ãããžãã¹ã»ããžãã¯ãšå¯äœçšãåé¢ããããšã§ããã
é¢æ°åã¢ãŒããã¯ãã£ã¯ãå¯äœçšãããžãã¹ã»ãªãã¬ãŒã·ã§ã³ã®æåãæåŸã«æã£ãŠããããšã§åé¢ãå®çŸããããšãããã®ã§ããã
é¢æ°çæ ž (functional core) ã¯æ±ºå®ãäžããã®ã§ãããå¯å€æ®» (mutable shell) ã¯ãé¢æ°çæ žã«å¯ŸããŠå ¥åå€ãæäŸããããé¢æ°çæ žã§äžããã決å®ã«åºã¥ããŠå¯äœçšãèµ·ããåŠçãè¡ã£ãããããã®ã§ããã
é¢æ°åã¢ãŒããã¯ãã£ãå°å ¥ãããšãããã©ãŒãã³ã¹ã¯ç ç²ã«ãªããããã®ããããä¿å®ã¯ãããããªãã
ãããã·ã¹ãã ãåçŽã§ãããŸã§éèŠæ§ããªãã®ã§ããã°ãé¢æ°åã¢ãŒããã¯ãã£ãå°å ¥ããã®ã«å¿ èŠãªåæã³ã¹ãã®æ¹ãåŸã§åŸããã䟡å€ãããé«ããªãå¯èœæ§ãããã
第7ç« : åäœãã¹ãã®äŸ¡å€ãé«ãããªãã¡ã¯ã¿ãªã³ã°
ãªããªããåäœãã¹ããšãã®ãã¹ã察象ãšãªãã³ãŒãã¯ãäºãã«åœ±é¿ããã£ãŠããããããã¯ã·ã§ã³ã»ã³ãŒãã®æ¹åãªãã«äŸ¡å€ã®ããçã¿åºãããšãã§ããªãããã§ãã
ãã®ç« ã§ã¯ããã®ã¢ãããŒããå¹ åºãç¯å²ã®ã¢ããªã±ãŒã·ã§ã³ (é¢æ°åã¢ãŒããã¯ãã£ãé©çšã§ããªãã¢ããªã±ãŒã·ã§ã³ãå«ã) ã«æµžéãããã«ã¯ã©ãããã®ãããšããããšãèŠãŠãããŸãã
7.1 ãªãã¡ã¯ã¿ãªã³ã°ãå¿ èŠãªã³ãŒãã®èå¥
ãããªãçç±ã¯ããã¹ãã»ã³ãŒããšãããã¯ã·ã§ã³ã»ã³ãŒãã¯æ¬è³ªçã«åœ±é¿ããããã®ã ããã§ãã ããã§ããã®7.1ç¯ã§ã¯ããªãã¡ã¯ã¿ãªã³ã°ã®æ¹åæ§ãèŠæ¥µããã®ã«å¿ èŠãªãããã¯ã·ã§ã³ã»ã³ãŒãã®çš®é¡ã«ã€ããŠåŠã³ããã¹ã察象ãšãªãã³ãŒãã¯ã©ã®ããã«åé¡ããã®ããèŠãŠãããŸãã
7.1.1 4çš®é¡ã®ãããã¯ã·ã§ã³ã³ãŒã
ãã¹ãŠã®ãããã¯ã·ã§ã³ã»ã³ãŒãã¯ã次ã®2ã€ã®èŠç¹ã§åé¡ã§ããŸã: ã»ã³ãŒãã®è€éãããããã¯ãã¡ã€ã³ã«ãããéèŠæ§ ã» ååè ãªããžã§ã¯ãã®æ°
åäœãã¹ããè¡ã䟡å€ãæãé«ããããã¯ã·ã§ã³ã»ã³ãŒãã¯è€éãªã³ãŒãããããã¯ãã¡ã€ã³ã«ãããéèŠæ§ãé«ãã³ãŒãã§ãããªããªãããã®ãããªã³ãŒãããã¹ãããããšã§ãéè¡ (regression) ã«å¯Ÿããä¿è·ãåããããã«ãªãããã§ãã
第2ç« ã§è¿°ã¹ãããã«ãååè ãªããžã§ã¯ããšã¯ãå¯å€ (mutable) ãããã¯ããã»ã¹å€ã®äŸåã®ããšã§ã (ãããã¯ãã®äž¡æ¹ã®æ§è³ªãæã€äŸå) ã
ãã®ããããã®ç« ã§ã¯ãã©ã®ããã«ãã®ãžã¬ã³ããåé¿ããã®ãããšããããšãäž»ã«èããŠãããŸãã
NOTE: 質ã®æªããã¹ãã»ã±ãŒã¹ãäœæããããããªãããã®ãããªãã¹ãã»ã±ãŒã¹ããŸã£ããäœæããªãæ¹ãããã§ãããã
7.1.2 è³ªçŽ ãªãªããžã§ã¯ã (Humble Object) ãçšããé床ã«è€éãªã³ãŒãã®åå²
å€ãã®å Žåããã¹ããããããšãé£ãããªãã®ã¯ããã¹ã察象ã®ã³ãŒãããã¬ãŒã ã¯ãŒã¯ãšãªãäŸåã«çŽæ¥çµã³ã€ãå Žåã§ã (å³7.3) ã
ãã®ããžãã¹ã»ããžãã¯ã«é¢ãã責åãšé£æºã®ææ®ã«é¢ãã責åã¯ãããããã³ãŒãã®æ·±ã (è€éããéèŠæ§) ãã³ãŒãã®åºã (ååè ãªããžã§ã¯ãã®æ°) ãšããŠèããããšãã§ããŸãã
ã³ã³ãããŒã©ãããã«å€ãã®ãªããžã§ã¯ããææ®ããŠããŠãããã®ã³ã³ãããŒã©ã¯è€éããæã£ãŠã¯ãªããªããäžæ¹ããã¡ã€ã³ã»ã¯ã©ã¹ã¯éãšãªãããã«ããªããŠã¯ãªããªãã
ãã®å ŽåãéçŽå ã®ã¯ã©ã¹ã¯ãäºããå¯æ¥ã«çµã³ã€ããŠããŸãã®ã§ãããéçŽå士ã¯ççµåã®é¢ä¿ãç¯ãããšã«ãªããŸãã
ãã ããããã§æ³šæããŠæ¬²ããã®ã¯ãããžãã¹ãã»ãžãã¯ãšãªãéšåãšé£æºãææ®ããéšåãšã®åé¢ãç¶æããçç±ã¯ãã¹ããè¡ããããããããšã ãã§ã¯ãªãããšããããšã§ãããã®ãããªåé¢ã¯ãããã¯ã·ã§ã³ã»ã³ãŒãã®è€éãã解決ããã®ã«ã圹ç«ã¡ãŸãã
ãã®ããã«ãã¹ããè¡ããããèšèšã«ããããšãåã«ãã¹ããããããã«ç¹ããã ãã§ã¯ãªããä¿å®ã®ããããã«ãç¹ããããšã«ç§ã¯ãã€ãé åãæããŠããŸãã
7.2 åäœãã¹ãã«äŸ¡å€ãæãããããã®ãªãã¡ã¯ã¿ãªã³ã°
ä»åã¯ãè³ªçŽ ãªãªããžã§ã¯ã (Humble Object) ãçšããŠããã®é¢æ°åã¢ãŒããã¯ãã£ãžã®ç§»è¡ããã¹ãŠã®ãšã³ã¿ãŒãã©ã€ãºã»ã¬ãã«ã®ã¢ããªã±ãŒã·ã§ã³ã«é©å¿ã§ãããããªæ±çšåãè¡ã£ãŠãããŸãã
7.2.5 3åç®ã®ãªãã¡ã¯ã¿ãªã³ã°: æ°ã㪠Company ã¯ã©ã¹ã®å°å ¥
ãªããªãããã®ããã«ãªãã¡ã¯ã¿ãªã³ã°ããããšã§ãåäœãã¹ãã¯ããã»ã¹å€äŸåãæ€èšŒããªããŠæžãããã«ãªãããã®çµæã³ããã±ãŒã·ã§ã³ã»ããŒã¹ãã¹ããè¡ãå¿ èŠããªããªãããã§ãããããªããšåäœãã¹ãã§è¡ããã¹ãŠã®æ€èšŒã¯ãã¡ã¢ãªäžã®ãªããžã§ã¯ãã«å¯ŸããŠåºåå€ããŒã¹ã»ãã¹ããšç¶æ ããŒã¹ã»ãã¹ãã ããçšããŠè¡ããããã«ãªããŸãã
7.3.3 äºåæ¡ä»¶ããã¹ããã¹ãã?
ãã®ããããã®ãããªã»ãŒããã£ãŒã»ããããèšããŠããããšã§ããœãããŠã§ã¢ã¯æ©æ倱æ (Fail Fast) ããééããåºãã£ãŠããããšããã®ééããããŒã¿ããŒã¹ã«ãŸã§åã¶ããšãé²ããããã«ãªããŸãã
ããããªãããæ¬æžãæšå¥šããäžè¬çãªæéã¯ããããäºåæ¡ä»¶ããã¡ã€ã³ã«ãããŠéèŠã§ããã°ããã®äºåæ¡ä»¶ã¯ãã¹ããããã¹ãããšãããã®ã§ãã
7.4 ã³ã³ãããŒã©ã«ãããæ¡ä»¶ã«ã€ãããžãã¯ã®æ±ã
ããžãã¹ã»ããžãã¯ã®ã³ãŒããšé£æºãææ®ããã³ãŒãã®åé¢ãæãè¡ããããã®ã¯ã1ã€ã®ããžãã¹ã»ãªãã¬ãŒã·ã§ã³ã次ã®3段éã®æµãã«ãªã£ãŠããå Žåã§ã (å³ 7.10) : 1. ã¹ãã¬ãŒãžããã®ããŒã¿ã®ååŸ 2. ããžãã¹ããžãã¯ã®å®è¡ 3. å€æŽãããããŒã¿ã®ä¿å
ããããªããããããã®æé ãå®ç§ã«éµå®ã§ããªãå ŽåããããããŸããããšãã°ãåç« ã§è¿°ã¹ãããã«ã決å®ãäžãéçšã®äžã§ãéäžã§åŸãçµæã䜿ã£ãŠããã»ã¹å€äŸåããæ°ãã«ããŒã¿ãååŸããªããã°ãªããªããããªå Žåã§ã (å³ 7.11) ã
å³ 7.11 ããžãã¹ã»ãªãã¬ãŒã·ã§ã³ãå®æœããŠããæäžã«ããã»ã¹å€äŸåãžã®ã¢ã¯ã»ã¹ãèŠæ±ãããå ŽåããããµãŽãã«ã»ã¢ãŒããã¯ãã£ã¯ããŸãæ©èœããªã
ãããªããšãéžã¹ããã®ã¯3ã€ç®ã®éžæè¢ (決å®ãäžãéçšãããã«çŽ°ããåå²ãã) ã ãã«ãªããŸãããã ãããã®éžæè¢ãéžã¶ãšãã³ã³ãããŒã©ã®ã³ãŒãã¯è€éã«ãªã£ãŠããŸãããã®å®è£ ãé床ã«è€éãªã³ãŒãã®é åã«è¿ã¥ãããšã«ãªããŸããããããªããããã®åé¡ã¯ããçšåºŠã§ããã°å¯ŸåŠããããšãå¯èœã§ãã
7.4.1 確èªåŸå®è¡ (CanExecute/Execute) ãã¿ãŒã³ã®é©çš
ã³ã³ãããŒã©ãŒãããè€éã«ãªã£ãŠããããšãžã®å¯ŸçãšããŠãæåã«ã§ããäºã¯ç¢ºèªåŸå®è¡ (CanExecute/Execute) ãã¿ãŒã³ãæ¡çšããããšã§ãããã®ãã¿ãŒã³ã¯ãã¡ã€ã³ã»ã¢ãã«ã«ããããžãã¹ã»ããžãã¯ãã³ã³ãããŒã©ã«æµåºããããšãé²ãããã®ãã®ã§ãã
ãããªããšããã¹ãŠã®æ±ºå®ã¯ User ã¯ã©ã¹ã§äžãããŠããããšãšãªããã³ã³ãããŒã©ãŒã¯ãã®æ±ºå®ã«åºã¥ããæ¯ãèããããŠããã ãã«ãªããŸãã
7.4.2 ãã¡ã€ã³ã»ã¢ãã«ã®ç¶æ ã远跡ãããšãã¡ã€ã³ã»ã€ãã³ãã®å©çš
ããããªãããã¢ããªã±ãŒã·ã§ã³ã§äœãèµ·ãã£ãã®ããæ£ç¢ºã«å€éšã·ã¹ãã ã«äŒããªããã°ãªããªãããããã®çµç·¯ãç¥ãããšãéèŠã«ãªãå ŽåããããŸãã
ããã§ããã®ãããªè€éããã³ã³ãããŒã©ã«æã¡èŸŒãããšãé¿ããããããã¡ã€ã³ã»ã¢ãã«ã§èµ·ãã£ãéèŠãªç¶æ ã®å€æŽãææ¡ã§ããããã«ãããã®å€æŽãçºçãããããžãã¹ã»ãªãã¬ãŒã·ã§ã³ãçµãã£ãããšã«ãããã»ã¹å€äŸåã«å¯ŸããŠå€æŽããã£ãããšãäŒããããã«ããŸãããŸãã«ãã®ãããªå Žå䜿ããã®ããã¡ã€ã³ã»ã€ãã³ããªã®ã§ããã
ããããªãããçŸå®ã®ãããžã§ã¯ãã«ãããŠãããã»ã¹å€äŸåããã¡ã€ã³ã»ã¢ãã«ã«æž¡ããŠããŸããšãã¢ããªã±ãŒã·ã§ã³ãããã»ã¹å€äŸåãäžå¿ èŠã«åŒã³åºãããšãé²ãããšãé£ãããªã£ãŠããŸããŸãã
ãã®ãã¡ã€ã³ã»ã€ãã³ããå®è£ ã®èŠ³ç¹ããèŠããšããã¡ã€ã³ã»ã€ãã³ããšã¯ãå€éšã·ã¹ãã ã«äŒããªããŠã¯ãªããªãããŒã¿ãå«ãã ã¯ã©ã¹ã®ããšã«ãªããŸãã
7.5 çµè«
ããã§ã¯ããã®ç« ã®äž»é¡ã§ããå€éšã·ã¹ãã ã«å¯ŸããŠçºçãããå¯äœçšããã¡ã€ã³å±€ããåãé€ãæœè±¡åã«ã€ããŠæ¯ãè¿ã£ãŠãããŸãããã ãã®ç« ã§ã¯ããã®ãããªå¯äœçšãèµ·ããåŠçãããžãã¹ã»ãªãã¬ãŒã·ã§ã³ã®æåŸãŸã§å®è¡ãããªãããã«ãããããŸã§ã®éã¡ã¢ãªäžã§äœæ¥ãè¡ããããããªæœè±¡åãè¡ãããšã§ãããã»ã¹å€äŸåãå·»ã蟌ãŸãã«åäœãã¹ããè¡ããããã«ãªãããšãèŠãŠããŸãããããã«ããã¡ã€ã³ã»ã€ãã³ããã³ã¬ã¯ã·ã§ã³ã«è¿œå ããããšãã¡ãã»ãŒãžã»ãã¹ãžã¡ãã»ãŒãžãéä¿¡ããããšã®æœè±¡åã§ããããšããããŠããã¡ã€ã³ã»ã¯ã©ã¹ã®ç¶æ ãå€æŽããããšãããŒã¿ããŒã¹ã®ç¶æ ãå€æŽããããšã®æœè±¡åã§ããããšãèŠãŠããŸããã
ãŸããããžãã¹ã»ããžãã¯ãã³ã³ãããŒã©ã«æã¡èŸŒãã§ããŸãããšãé¿ããããªãã®ãšåãããã«ããã¡ã€ã³ã»ã¯ã©ã¹ãããã¹ãŠã®ååè ãªããžã§ã¯ããå®å šã«åãé€ããããšãæ» å€ã«ãããŸãããããããªããããã®ããšã«é¢ããŠç¥çµè³ªã«ãªãå¿ èŠã¯ãããŸããããªããªããä»®ã«ã1ã€ã2ã€ãå Žåã«ãã£ãŠã¯ã3ã€ã®ååè ãªããžã§ã¯ãããã¡ã€ã³ã»ã¯ã©ã¹ã«å«ãŸããŠãããšããŠãããããã®ååè ãªããžã§ã¯ããããã»ã¹å€äŸåã§ãªãéãããã¡ã€ã³ã»ã¯ã©ã¹ãé床ã«è€éãªã³ãŒãã«ãªãããšã¯ãªãããã§ãã
ãã®ããã«ã芳å¯å¯èœãªæ¯ãèããšå®è£ ã®è©³çŽ°ãšã®é¢ä¿ã¯çããã®å±€ã®ããã«èããããšãã§ããŸããåå±€ã®ãã¹ãã¯1ã€äžã®å±€ã®èŠç¹ã§è¡ãããã¹ã察象ãšãªãå±€ããã®äžã«ããå±€ãšäœãããŠããã®ãã«ã€ããŠã¯æèããªãããã«ããŸãã
ãŸãšã
決å®ãäžãéçšãããã«çŽ°ããåå²ããããšã¯ãåæ§è³ªã®é·æãšçæãèæ ®ããæåã®ãã¬ãŒãã»ãªãã®çµæã§ããã次ã®2ã€ã®èšèšãã¿ãŒã³ãçšããããšã§ãã³ã³ãããŒã©ãè€éã«ãªã£ãŠããŸãããšãžã®å¯Ÿçãè¡ãã:
- 確èªåŸå®è¡(CanExecute/Execute)ãã¿ãŒã³ãšã¯ãäœããå®è¡ããã¡ãœãã(Execute ã¡ãœãã)ã«å¯ŸããŠå®è¡å¯èœãªã®ãåŠãã確èªããã¡ãœãã(CanExecute)ãçšæããããšã§ã察象ã®åŠçãæ£ããå®è¡ããããã®äºåæ¡ä»¶ãå¿ ãæºããããããšãä¿èšŒããèšèšãšã§ããããã®ãã¿ã³ãçšããããšã§ãåŠçãå®è¡ããã¡ãœãããåŒã³åºãããåã«å¿ ãäºåæ¡ä»¶ã®ç¢ºèªãè¡ãã¡ãœãããåŒã³åºãããããã«ãªããããã³ã³ãããŒã©ã決å®ãäžã責任ãæ¬è³ªçã«åãé€ãããšã«ãªãã
- ãã¡ã€ã³ã»ã€ãã³ããå°å ¥ããããšã§ããã¡ã€ã³ã»ã¢ãã«ã§çºçããéèŠãªç¶æ ãå€æŽã远跡ã§ããããã«ãªãããããŠãçºçãããã¡ã€ã³ã»ã€ãã³ããããšã«ããã»ã¹å€äŸåãžåŒã³åºããè¡ãããã«ããããã®ããã«ããã¡ã€ã³ã»ã€ãã³ããçšããããšã§ãã³ã³ãããŒã©ããç¶æ ã®å€æŽã远跡ãã責åãåãé€ããããã«ãªãã
第3éš: çµ±åïŒintegrationïŒãã¹ã
第8ç« : ãªããçµ±åïŒintegrationïŒãã¹ããè¡ãã®ãïŒ
8.1.1 çµ±åãã¹ãã®åœ¹å²
èŠãŠã®éããåäœãã¹ãã¯ãã¡ã€ã³ã»ã¢ãã«ãæ€èšŒããçµ±åãã¹ãã¯ãã¡ã€ã³ã»ã¢ãã«ãšããã»ã¹å€äŸåãšãçµã³ã€ããã³ãŒããæ€èšŒããŸãã
ããããªãããã»ãšãã©ã®ã¢ããªã±ãŒã·ã§ã³ã«ã¯ãã¢ãã¯ã«çœ®ãæããã¹ãã§ã¯ãªãããã»ã¹å€äŸåãååšããŸãããã®äŸåãšã¯ããŒã¿ããŒã¹ã®ããšã§ãã
ã€ãŸãããã¹ãŠã®ãã¹ãã»ã±ãŒã¹ã«ãããŠãæ€èšŒå¯Ÿè±¡ãšãªãã³ãŒãã¯ããã¡ã€ã³ã»ã¢ãã«(ãŸãã¯ãã¢ã«ãŽãªãºã )ããããã¯ãã³ã³ãããŒã©ã®ã©ã¡ããã ãã§ããããšããããšã§ãã
8.1.2 ãã¹ããã©ãããã®æ¯ãè¿ã
ãŸããåäœãã¹ããšçµ±åãã¹ãã®é©åãªãã¹ãã±ãŒã¹ã®å²åã¯ãããžã§ã¯ãã«ãã£ãŠç°ãªãã®ã§ãããäžè¬çã«ãåäœãã¹ãã¯ããžãã¹ã»ã·ããªãªã«ãããç°åžžã±ãŒã¹ (edge case) ãã§ããã ãå€ãæ€èšŒããã®ã«å¯Ÿããçµåãã¹ãã¯1件ã®ããããŒã»ãã¹ (happy path) ãšåäœãã¹ãã§ã¯æ€èšŒã§ããªããã¹ãŠã®ç°åžžã±ãŒã¹ãæ€èšŒããããšãé©åã ãšèããããŠããŸãã
8.2.1 2çš®é¡ã®ããã»ã¹å€äŸå
管çäžã«ããäŸå (managed dependency) – ãã®äŸåã¯ããã¹ã察象ã®ã¢ããªã±ãŒã·ã§ã³ã奜ããªããã«ããããšãã§ããããã»ã¹ãäŸåã§ããã âŠç¥âŠ 管çäžã«ããäŸåã®å žåçãªäŸã«ããã¹ã察象ã®ã¢ããªã±ãŒã·ã§ã³ããã¢ã¯ã»ã¹ããªãããŒã¿ããŒã¹ãããã
管çäžã«ãªãäŸå (unmanaged dependency) – ãã®äŸåã¯ããã¹ã察象ã®ã¢ããªã±ãŒã·ã§ã³ãå°ãªãããã«ããããšãã§ããªããããã»ã¹ãäŸåã§ããã âŠç¥âŠ 管çäžã«ãªãäŸåã®å žåçãªäŸã«ã¡ãŒã«ãµãŒãã¹ãã¡ãã»ãŒãžãã¹ããããäž¡æ¹ãšãä»ã®ã¢ããªã±ãŒã·ã§ã³ã«èŠããå¯äœçšãçºçãããã
éèŠ : 管çäžã«ããäŸåã«å¯ŸããŠã¯ãå®éã®ã€ã³ã¹ã¿ã³ã¹ã䜿ãããã«ãã管çäžã«ãªãäŸåã«å¯ŸããŠã¯ã¢ãã¯ã䜿ãããã«ããŸãããã
8.2.3 çµ±åãã¹ãã§ãå®éã®ããŒã¿ããŒã¹ã䜿ããªãå Žå
ãã®ããããããå®éã®ããŒã¿ããŒã¹ã䜿ã£ãŠæ€èšŒã§ããªãã®ã§ããã°ããã®ããšã«é¢ããçµ±åãã¹ããäœæããããã¡ã€ã³ã»ã¢ãã«ã®åäœãã¹ããäœæããããšã ãã«å°å¿µããããã«ããŸãããããããŠãåžžã«ææ°ã®æ³šæãæã£ãŠããã¹ãŠã®ãã¹ãã»ã±ãŒã¹ã粟æ»ãããããããŸã䟡å€ã®ãªããã¹ãã»ã±ãŒã¹ãèŠã€ããå Žåã¯ããã®ãã¹ãã»ã±ãŒã¹ããã¹ãã»ã¹ã€ãŒãããåãé€ãããã«ããŸãããã
8.3.4 çµ±åãã¹ãã®äœæ
ããŒã¿ããŒã¹ã®ç¶æ ã確èªããéãæ€èšŒããããŒã¿ãå ¥åå€ãšããŠäœ¿ã£ãããŒã¿ãšã¯ç°ãªãçµç±ã§ååŸãããã®ã«ããäºã¯ãã¹ãã«ãããŠéèŠãªããšã§ãã
8.4 ã€ã³ã¿ãŒãã§ãŒã¹ã䜿ã£ãäŸåã®æœè±¡å
åäœãã¹ãã«é¢ããŠèª€è§£ãçãã§ããããšã®1ã€ã«ã€ã³ã¿ãŒãã§ã€ã¹ã®å©çšããããŸãããªããã€ã³ã¿ãŒãã§ãŒã¹ã䜿ãã®ãããšããããšã«é¢ããŠééã£ãèªèãããŠããéçºè ã¯å€ãããã®çµæãã€ã³ã¿ãŒãã§ã€ã¹ãé床ã«äœ¿ãããŠããŸãããšãå€ã ãããŸãã
ãã®ç« ãèªãã§ããã®ã楜ãã¿ãèªåãééã£ãŠäœ¿ã£ãŠãããã䜿ãéããªã®ã§æãããããããšèšãããšã ãªã
8.4.1 ã€ã³ã¿ãŒãã§ã€ã¹ãšççµåã®é¢ä¿
ãŸãã€ã³ã¿ãŒãã§ã€ã¹ã®å®è£ ã¯ã©ã¹ã1ã€ãããªãã®ã§ããã°ããã®ã€ã³ã¿ãŒãã§ã€ã¹ã¯æœè±¡ã§ã¯ãããŸããã âŠç¥âŠ æ¬æ¥ãæœè±¡åãšã¯ãçºèŠããããšã§ãããäœãåºãããšã§ã¯ãªãã®ã§ãã âŠç¥âŠ ãã®ãããã€ã³ã¿ãŒãã§ã€ã¹ãæ¬åœã®æœè±¡ã«ãªãããã«ã¯ã2ã€ä»¥äžã®å®è£ ã¯ã©ã¹ãååšããªããŠã¯ãªããŸãã
äžæ¹ãããäžã€ã®èªè(æ¢åã®ã³ãŒããå€æŽããããšãªããæ°ããæ©èœãè¿œå ã§ããããã«ãªã)ããŸãééã£ãèªèã§ãããªããªãããã®ãããªçç±ã§ã€ã³ã¿ãŒãã§ã€ã¹ãçšæããããšã¯èšèšã®ããæ ¹æ¬çãªååã§ãã YAGNI (You Arenât Gonna Need It) ååããå€ããããšã«ãªãããã§ãã
TIP: ã³ãŒããæžãããšã¯ã³ã¹ãã®ãããåé¡è§£æ±ºã®æ¹æ³ã§ãããã®ãããåé¡ã解決ããã®ã«èšè¿°ããªããŠã¯ãªããªãã³ãŒãã¯å°ãªããŠç°¡æœãªã»ã©è¯ãããšããããšã«ãªããŸãã
8.4.2 ãªããããã»ã¹å€äŸåã«ã€ã³ã¿ãŒãã§ã€ã¹ã䜿ãã®ãïŒ
ããã§ã¯ãã€ã³ã¿ãŒãã§ã€ã¹ãå®è£ ããã¯ã©ã¹ã1ã€ãããªãã®ã«ããããããããªããããã»ã¹å€äŸåã«å¯ŸããŠã€ã³ã¿ãŒãã§ã€ã¹ã䜿ãã®ã§ããããïŒããã¯ã¢ãã¯ãäœããããã«ããããããšããéåžžã«å®è·µçã§çŸå®çãªçç±ãçãã«ãªããŸãã
ãã®ããšãç ®è©°ããŠãããšã管çäžã«ãªãäŸåã«å¯ŸããŠã®ã¿ã€ã³ã¿ãŒãã§ãŒã¹ãçšæããããšããçµè«ã«è³ããŸããäžæ¹ã管çäžã«ããäŸåã«å¯ŸããŠã¯å ·è±¡ã¯ã©ã¹ã䜿ãããã«ãããã®å ·è±¡ã¯ã©ã¹ãã³ã³ãããŒã©ã«æ瀺çã«æ³šå ¥ããããã«ããŸãã
äŸãã°ã管çäžã«ãªãäŸåãšããã®ã¯ã¡ãŒã«éä¿¡ã管çäžã«ããäŸåãšããã®ã¯ããŒã¿ããŒã¹ãžã®ã¢ã¯ã»ã¹ã
8.5.1 ãã¡ã€ã³ã»ã¢ãã«ã®å¢çãæ確ã«ãã
çµ±åãã¹ãããã¹ã察象ãšããã®ã¯ã³ã³ãããŒã©ãŒã§ãããã®ããããã¡ã€ã³ã»ã¯ã©ã¹ãšã³ã³ãããŒã©ãšã®å¢çãæ確ã«ãªã£ãŠããã°ãåäœãã¹ããšçµ±åãã¹ãã®åºå¥ããããããªããŸãã
8.5.2 ã¢ããªã±ãŒã·ã§ã³ãæ§æããå±€ãæžãã
ãã®ãããªæœè±¡åãé床ã«å¢ããŠããŸããšãåäœãã¹ããçµ±åãã¹ããè¡ãã¥ãããªã£ãŠããŸããŸãããªããªããéæ¥åç §ã®å±€ãå€ãã³ãŒãããŒã¹ã ãšã³ã³ãããŒã©ãšãã¡ã€ã³ã»ã¢ãã«ã®å¢çãææ§ã«ãªãããšãããããããã§ãã(ãããŠã第7ç« ã§è¿°ã¹ãããã«ããã®å¢çã®ååšã¯å¹æçãªãã¹ããè¡ãããã«å¿ èŠãªãã®ã§ã)ã
ãã®ãããéæ¥åç §ã®å±€ã¯ã§ããã ãå°ãªããªãããã«åªããªããŠã¯ãªããŸãããããã¯ãšã³ãã®ã·ã¹ãã ã§ããã°ãã»ãšãã©ã®å Žåã次ã®å³8.10ã§ç€ºãããã«ããã¡ã€ã³å±€(ããžãã¹ã»ããžãã¯ãå«ãå±€)ãã¢ããªã±ãŒã·ã§ã³ã»ãµãŒãã¹å±€(ã³ã³ãããŒã©ã®å±€)ãã€ã³ãã©å±€ã®3ã€ã®å±€ã ãã§å åãªã¯ãã§ãã
8.5.3 埪ç°äŸåãåãé€ã
埪ç°äŸåããŸããé床ã«å€ãéæ¥åç §ã®å±€ãšåãããã«ãã³ãŒããèªãã§ç解ããããšãé£ããããéçºè ã«å¯ŸããŠèšå€§ãªèªç¥çè² è·ãäžãããã®ã§ãã
ãããªããšãã€ã³ã¿ãŒãã§ã€ã¹ãçšããŠåŸªç°äŸåãé ããããªããšããããããããã®åŸªç°äŸåãå®å šã«åãé€ããŠããŸãæ¹ãè¯ãã§ãããã
ãã¡ãããã³ãŒãããŒã¹ãããã¹ãŠã®åŸªç°äŸåãåãé€ãããšã¯ã§ããªãããšã®ã»ããå€ãã§ãããã
8.5.4 1ã€ã®ãã¹ãã»ã±ãŒã¹ã«è€æ°ã®å®è¡ (Act) ãã§ãŒãºãçšããå Žå
ãã®ããã«ãè€æ°ã®å®è¡ãã§ãŒãºãæã£ããã¹ãã»ã±ãŒã¹ã®äœæã蚱容ã§ããã®ã¯ãéçºè ããã¹ããããã®ã«å¥œããªããã«ããã»ã¹å€äŸåãæ±ããªãå Žåã ãã§ãããŸãã«ããã®ããšãåäœãã¹ãã«å¯ŸããŠè€æ°ã®å®è¡ãã§ãŒãºãæã£ããã¹ãã»ã±ãŒã¹ãäœã£ãŠã¯ãªããªãçç±ãªã®ã§ãã(ãªããªããåäœãã¹ãã§ã¯ãããã»ã¹å€äŸåãæ±ãã¹ãã§ã¯ãªãããã§ã)ãããã«ãçµ±åãã¹ãã®å Žåã§ããããè€æ°ã®å®è¡ãã§ãŒãºãæã€ãã¹ãã»ã±ãŒã¹ãäœãããšã«æå³ãããããšã¯æ» å€ã«ãããŸãããå®éã®ãšãããè€æ°ã®å®è¡ãã§ãŒãºãæã€ãããªãã¹ãã»ã±ãŒã¹ãäœæããã®ã¯ãE2Eãã¹ãã«åé¡ããããã¹ãã§è¡ãããšãã»ãšãã©ã§ãã
8.6.1 ããããããã°åºåããã¹ããã¹ããïŒ
ãã®æå³ã«ãããŠããã°åºåã¯ä»ã®æ©èœãšäœãéããšããã¯ãããŸããããŸãããã°åºåã¯æçµçã«ããã¹ãã»ãã¡ã€ã«ãããŒã¿ããŒã¹ãªã©ã®ããã»ã¹å€äŸåã«å¯ŸããŠå¯äœçšãèµ·ãããã®ã§ãããããŠãããããã®ãããªå¯äœçšãå€éš(ãŠãŒã¶ãã¢ããªã±ãŒã·ã§ã³ã®ã¯ã©ã€ã¢ã³ããééçºè )ãããèŠãããããšãæå³ããŠããã®ã§ããã°ããã®ãã°åºåã¯èŠ³å¯å¯èœãªæ¯ãèãã§ããããã®ããããã¹ãããããªããŠã¯ãªããŸãããäžæ¹ããããåºåããããã°ãèŠãã®ãéçºè ã ãã§ããå Žåããã®ãã°åºåã¯å®è£ ã®è©³çŽ°ã§ãããéçºè ã¯å€éšã«æ°ã䜿ãããšãªããã®ãã°åºåãä¿®æ£ã§ããŸãããã®ããããã®å Žåã®ãã°åºåã¯ãã¹ããããã¹ãã§ã¯ãããŸããã
- ãµããŒãã»ãã° – ã·ã¹ãã ã®ãµããŒãã»ã¹ã¿ãããã·ã¹ãã 管çè ã«ãã£ãŠèŠãããããšãæå³ããç¹å®ã®ã€ãã³ããèšé²ãããã°ã
- 蚺æãã° – éçºè ãã¢ããªã±ãŒã·ã§ã³å ã§äœãèµ·ãã£ãŠããã®ããææ¡ã§ããããã«ããããã®ãã°
äœããã°åºåããã¹ããªã®ãïŒä»ãŸã§ãã°ãã°æ©ãã§ããããçãã®æããããã²ãšã€èŠã€ãã£ãããã«æããâ ãã°åºåããã¹ããã®ã¯ããžãã¹èŠä»¶ã®å¯Ÿè±¡ã§ãããšãã決ãããããžãã¹èŠä»¶ãšå®ãããã°åºåã¯ãã¡ãŒã«éä¿¡ãšåååçãšã¿ãªããšèšããããšèãããšçãè¯ãããã
ãã¹ãã®äºã ãã§ã¯ãªããã·ã¹ãã ã®äœãæ¹ã«å¯ŸããåŠã³ãèãããã£ãããåŸãããããšãŠãè¯ãæ¬ã ã
8.6.2 ã©ã®ããã«ãã°åºåããã¹ããã¹ããïŒ
ãã°åºåã¯ãããã»ã¹å€äŸåã«å¯ŸããŠå¯äœçšãçºçãããæ©èœã§ããããããã¹ãã®éã¯ããã»ã¹å€äŸåãšã®ãããšããè¡ãä»ã®æ©èœãšåãã«ãŒã«ãé©çšãããããšã«ãªããŸããã€ãŸããã¢ãã¯ã䜿ã£ãŠãã¢ããªã±ãŒã·ã§ã³ãšãã°ã»ã¹ãã¬ãŒãžãšã®ããã ã§è¡ããããããšããæ€èšŒããããšã«ãªããŸãã
ããã§ããã¹ãŠã®ãµããŒãã»ãã°ãåã¡ãœãããšããŠå®çŸ©ããã DomainLogger ã¯ã©ã¹ãäœæãããã® DomainLogger ã¯ã©ã¹ãããµããŒãã»ãã°ãåºåããããã«ããŸãã
ã€ãŸããUser ã¯ã©ã¹ã§ããã»ã¹å€äŸåã§ãã DomainLogger ã¯ã©ã¹ã䜿ããšãUser ã¯ã©ã¹ã¯ãã¹ããä¿å®ãããããšãé£ããé床ã«è€éãªã³ãŒãã«å±ããã³ãŒãã«ãªã£ãŠããŸãã®ã§ãã(詳现ã«ã€ããŠã¯ç¬¬7ç« ãåç §)ããã ãããã®åé¡ã¯ããã¡ã€ã³ã»ã€ãã³ããæå ¥ããŠãã¡ãŒã«ã»ã¢ãã¬ã¹ãå€æŽãããããšãå€éšã·ã¹ãã ãžéç¥ããããã«ããæãšåãæ¹æ³(詳现ã¯ç¬¬7ç« ãåç §)ã§è§£æ±ºã§ããŸãã
8.6.3 ã©ã®ãããã®ãã°ãåºåããã°å åãªã®ãïŒ
ãã¡ããããµããŒãã»ãã°ã¯ããžãã¹èŠä»¶ã§ããããã確å®ã«åºåããªããã°ãªããŸããã
蚺æãã°ã®å ŽåãéèŠãªã®ã¯é床ã«åºåããªãããšã§ãããªããªãã蚺æãã°ã®é床ãªåºåã¯æ¬¡ã®èª²é¡ãæ±ããããšã«ãªãããã§ãã
ã»ãšãã©ã®å Žåããã¡ã€ã³ã»ã¯ã©ã¹ã§åºåãããŠãããã°ãã³ã³ãããŒã©ã«åºåããããããªãªãã¡ã¯ã¿ãªã³ã°ã¯å®å šã«è¡ããŸãã
ã€ãŸãããããã°ãçµãã£ããããã®ãã°åºåã®ã³ãŒããåãé€ããŠããŸãã®ã§ããçæ³ãªã®ã¯ãæ³å®å€ã®åé¡ãèµ·ãã£ããšãã«ã ãã蚺æãã°ã䜿ãããã«ããããšã§ãã
ãããã°çšã®ãã°ã¯ããŸã䜿ãããããšèãæ®ããŠãããããªãèªæã«é§ãããã®ã ãããã®æ¬ã§ã¯åãé€ãããšãæšå¥šããŠããã確ãã«ãä»ã¡ã³ããŒã®ãããã°ãã°ã¯ã¬ãã¥ãŒæã«èªç¥è² è·ã®äžæèŠå ãšãªã£ãããå¿ããé ã«ã³ãŒããèŠããšãã«éªéãšæããããšãå€ãããã«æãã
8.7 çµè«
ãã¹ãŠã®ããã»ã¹å€äŸåãšã®ã³ãã¥ãã±ãŒã·ã§ã³ã«å¯ŸããŠããã®ã³ããã±ãŒã·ã§ã³ã芳å¯å¯èœãªæ¯ãèãã®äžéšãªã®ãããããšãå®è£ ã®è©³çŽ°ãªã®ãããšããããšãèããããã«ããŸãããããã®æå³ã«ãããŠã¯ããã°åºåãåãã§ãã
ãŸãšã
çµ±åãã¹ãã¯ãåäœãã¹ããããåªããéè¡ã«å¯Ÿããä¿è·ãšãªãã¡ã¯ã¿ãªã³ã°ãžã®èæ§ãæäŸããäžæ¹ãåäœãã¹ãã¯çµ±åãã¹ããããåªããä¿å®ã®ãããããšè¿ éãªãã£ãŒãããã¯ãæäŸããã
åäœãã¹ãã§ã¯ãããžãã¹ã»ã·ããªãªã«ãããç°åžžã±ãŒã¹ãå¯èœãªéãå€ãæ±ãããã«ãããäžæ¹ãçµ±åãã¹ããã§ã¯1件ã®ããããŒã»ãã¹ãããã³ãåäœãã¹ãã§ã¯æ±ããªãã£ãç°åžžã±ãŒã¹ãã§ããã ãå€ãæ±ãããã«ããã
**æ©æ倱æ(Fail Fast)**ãšã¯åé¡(ãã°)ãçºçããããããã«åŠçã倱æãããããšãæå±ããŠããååã§ãããçµ±åãã¹ãã®ä»£ãããšããŠå®éã«äœ¿ããååã§ããã
**管çäžã«ããäŸå(managed dependency)**ãšã¯ããã¹ã察象ã®ã¢ããªã±ãŒã·ã§ã³ãçµç±ããããšã§ããã¢ã¯ã»ã¹ã§ããªãããã»ã¹å€äŸåã®ããšã§ããããã®ããã管çäžã«ããäŸåãšã®ãããšããå€éšããèŠãããšã¯ã§ããªãã管çäžã«ããäŸåã®äŸãšããŠããããã®ãããã¹ã察象ã®ã¢ããªã±ãŒã·ã§ã³ããã¢ã¯ã»ã¹ããªãããŒã¿ããŒã¹ã§ããã
**管çäžã«ãªãäŸå(unmanaged dependency)**ãšã¯ãä»ã®ã¢ããªã±ãŒã·ã§ã³ãããã¢ã¯ã»ã¹ãããããã»ã¹å€äŸåã®ããšã§ããããã®ããã管çäžã«ãªãäŸåãšã®ã³ãã¥ãã±ãŒã·ã§ã³ã¯ãå€éšããèŠãããšãã§ããã管çäžã«ãªãäŸåã®äŸãšããŠããããã®ããã¡ãŒã«ã»ãµãŒãã¹ãã¡ãã»ãŒãžã»ãã¹ã§ããã
çµ±åãã¹ãã®å Žåã管çäžã«ããäŸåã«å¯ŸããŠã¯å®éã®äŸåã䜿ãã管çäžã«ãªãäŸåã«å¯ŸããŠã¯ã¢ãã¯ã䜿ãããã«ããã
ãµããŒãã»ãã°ã¯ãã·ã¹ãã ã®ãµããŒãã»ã¹ã¿ãããã·ã¹ãã 管çè ã«ãã£ãŠèŠãããããšãæå³ãããã°ã§ãããã¢ããªã±ãŒã·ã§ã³ã®èŠ³å¯å¯èœãªæ¯ãèãã®äžéšã«åé¡ããããäžæ¹ã蚺æ(diagnostic)ãã°ã¯ãéçºè ãã¢ããªã±ãŒã·ã§ã³ã®äžã§äœãèµ·ãã£ãŠããã®ããææ¡ããããã«å©çšãããã°ã§ãããå®è£ ã®è©³çŽ°ã«åé¡ãããã
蚺æãã°ã®åºåã¯ãã¹ããããã¹ãã§ã¯ãªãããŸããµããŒãã»ãã°ãšã¯ç°ãªãã蚺æãã°ããã¡ã€ã³ã»ã¢ãã«ã§çŽæ¥åºåããŠãåé¡ã¯ç¡ãã
ãã¹ãŠã®äŸå(ãã°åºåãªããžã§ã¯ããå«ã)ã¯ãåžžã«ãã³ã³ã¹ãã©ã¯ã¿ãã¡ãœããã®åŒæ°ãçµç±ããŠæ瀺çã«æ³šå ¥ãããããã«ãã¹ãã§ããã
åŒçšããŠããç®æããã®ãŸãŸãŸãšãã«ãªã£ãŠãããäžæãäŒãããããšãæŸããŠããæãããããããèªæãéãããã
第9ç« : ã¢ãã¯ã®ãã¹ãã»ãã©ã¯ãã£ã¹
ããã§ããã®ç« ã§ã¯ãæåã«å°éãããŸã§ã®æ®ãã®éã®ãã«ã€ããŠèŠãŠãããŸããã€ãŸããããã§ã¯ã¢ãã¯ãçšããçµ±åãã¹ããäœæããéã«ããã®ãã¹ãã»ã±ãŒã¹ã«éè¡(regression)ã«å¯Ÿããä¿è·ãšãªãã¡ã¯ã¿ãªã³ã°ãžã®èæ§ãæ倧éã«åããããã«ã¯ãããã«äœããã¹ããªã®ãããšããããšãèŠãŠãããŸãã
9.1.1 ã¢ããªã±ãŒã·ã§ã³ã®å¢çãè¶ ããŠè¡ãããã³ããã±ãŒã·ã§ã³ã®æ€èšŒ
TIP : 管çäžã«ãªãäŸåãžã®åŒã³åºããã¢ããªã±ãŒã·ã§ã³ã®å¢çãè¶ãããŸã§ããã®åŒã³åºãã«ã¯æ§ã ãªã³ã³ããŒãã³ããçµç±ããããšã«ãªããŸãããã®ãããå€éšãšã®å¢çã«æãè¿ãã³ã³ããŒãã³ããã¢ãã¯ã«çœ®ãæããããã«ããŸããããããããšã§ãå€éšã·ã¹ãã ãšã®ãããšãã«ãããŠãåŸæ¹äºæãä¿ãŠãããã«ãªããŸãããŸãã«ããã®åŸæ¹äºæã®ä¿èšŒããã¹ãã«å¯ŸããŠæ±ããããŠããããšã§ãããã¢ãã¯ãå°å ¥ããç®çãªã®ã§ãã
9.2.1 ã¢ãã¯ã®å©çšã¯çµ±åãã¹ãã«éå®ãã
ãã®ãã¹ãã»ãã©ã¯ãã£ã¹ã¯ãããžãã¹ã»ããžãã¯ã«é¢ããã³ãŒããšé£æºãææ®ããã³ãŒããšãåé¢ãããšèšãåºæ¬åå(第7ç« ãåç §)ããæ¥ãŠããŸãã
9.2.2 1ã€ã®ãã¹ãã»ã±ãŒã¹ã«ã¯ãè€æ°ã®ã¢ãã¯ãæãããŠã¯ãªããªãããšãã誀解
ããããªãããåäœãã¹ãã®ãåäœããæå³ããäºã¯ãã1åäœã®ã³ãŒã(a unit of code)ãã§ã¯ãªããã1åäœã®æ¯ãèã(a unit of behavior)ãã§ãã
9.2.3 ã¢ãã¯ã®åŒã³åºãåæ°ãåžžã«ç¢ºèªãã
管çäžã«ãªãäŸåãšã®ã³ãã¥ãã±ãŒã·ã§ã³ãæ€èšŒããéã«éèŠãªäºã¯æ¬¡ã®2ã€ã®ããšãäž¡æ¹ãšãä¿èšŒããããšã§ã: – æ³å®ããåŒã³åºããè¡ãããŠããããš – æ³å®ããªãåŒã³åºãã¯è¡ãããŠããªãããš
9.2.4 ã¢ãã¯ã®å¯Ÿè±¡ã«ãªãåã¯èªèº«ã®ãããžã§ã¯ããææããåã®ã¿ã«ãã
ãã®ãããªããšãããã®ã«ã¯ã次ã®çç±ããããŸã:
- ãµãŒãã»ããŒãã£è£œã®ã©ã€ãã©ãªãå®éã«ã©ã®ããã«æ©èœããŠããã®ããæ·±ãç¥ãäºã¯æ» å€ã«ã§ããªãããã
- ãµãŒãã»ããŒãã£è£œã®ã©ã€ãã©ãªèªäœãå©çšå¯èœãªã€ã³ã¿ãŒãã§ãŒã¹ãæ¢ã«æäŸããŠããå Žåããã®ã€ã³ã¿ãŒãã§ãŒã¹ãã¢ãã¯ã«çœ®ãæãã察象ã«ãããšãã¢ãã¯ã®æ¯ãèããšãµãŒãã»ããŒãã£è£œã®ã©ã€ãã©ãªã®å®éã®æ¯ãèããšãäžèŽããããšãä¿èšŒããªããŠã¯ãªããªããªãããªã¹ã¯ã䌎ãããšã«ãªãããã
- ã¢ããã¿ãæãããšã§ããµãŒãã»ããŒãã£è£œã®ã©ã€ãã©ãªã«å«ãŸããããžãã¹çã«æ¬è³ªã§ã¯ãªããæè¡çãªè©³çŽ°ãé èœçã§ããããã«ãªããããã«ãèªèº«ã®ã¢ããªã±ãŒã·ã§ã³ã®çšèªãçšããŠã©ã€ãã©ãªãšã®é¢ä¿ãå®çŸ©ã§ããããã«ãªãããã
ãã ããããã§æ³šæããŠã»ããã®ã¯ãèªèº«ã®ãããžã§ã¯ããææããåã®ã¿ãã¢ãã¯ã«çœ®ãæããããšããæéã¯åãããã»ã¹å ã®äŸåã«å¯ŸããŠã¯**該åœããªãã**ãšèšãããšã§ãã
第10ç« : ããŒã¿ããŒã¹ã«å¯Ÿãããã¹ã
10.1 ããŒã¿ããŒã¹ããã¹ãããã®ã«å¿ èŠãªäºåæºå
ãããããªããçµ±åãã¹ããäœãããšããªããŠããããã§èŠãŠãããã©ã¯ãã£ã¹ã®äžããåŠã¹ãäºã¯ãããããããšæ¬æžã§ã¯èããŠããŸãã
10.1.1 ãœãŒã¹ã³ãŒã管çã·ã¹ãã ãçšããã¹ããŒãã®ç®¡ç
äžæ¹ããããã¹ããŒãã«é¢ããå€æŽããã¹ãŠãœãŒã¹ã³ãŒã管çã·ã¹ãã ã«æ ŒçŽããŠããã°ãçå®ã瀺ãæ å ±æºã¯1ã€ã ããšãªã管çããããããªããŸããããã«ããããã¯ã·ã§ã³ã»ã³ãŒãã®å€æŽã«äŒŽã£ãããŒã¿ããŒã¹ã®å€æŽãèšé²ã§ããããã«ãªããŸãã
10.1.2 ã¹ããŒãã«åç §ããŒã¿(reference data)ãå«ããããš
**å®çŸ©: åç §ããŒã¿(reference data)**ãšã¯ã¢ããªã±ãŒã·ã§ã³ãé©åã«æ©èœãããããã«ãäºåã«çšæããªããŠã¯ãªããªãããŒã¿ã®ããšã§ã
åç §ããŒã¿ã¯ã¢ããªã±ãŒã·ã§ã³ã«ãšã£ãŠå¿ èŠäžå¯æ¬ ãªãã®ã§ãããããããŒãã«ããã¥ãŒãªã©ã®ã¹ããŒããšå ±ã«SQLã®åã®INSERTæã®åœ¢ã§ãœãŒã¹ã³ãŒã管çã·ã¹ãã ã«æ ŒçŽããã®ãè¯ãã§ãããã
10.1.3 éçºè ããšã«åå¥ã®ããŒã¿ããŒã¹ã»ã€ã³ã¹ã¿ã³ã¹ãçšæãã
- è€æ°äººã®éçºè ãåæã«ãã¹ããå®æœãããšããäºãã®ãã¹ãã«åœ±é¿ãåºãŠããŸãã
- åŸæ¹äºæã®ãªãå€æŽãå ãããšãã«ãä»ã®éçºè ã®äœæ¥ãæ¢ããŠããŸãã
10.1.4 ããŒã¿ããŒã¹ã«å¯Ÿããå€æŽã®æ¬çªç°å¢ãžã®åæ :ç¶æ ããŒã¹ VS. 移è¡ããŒã¹
移è¡ããŒã¹ãçšããå Žåãéçºè èªèº«ãæ¬çªç°å¢ã«å€æŽãåæ ããSQLã¹ã¯ãªãããäœæããŸãã
ãã®ããã«ã移è¡ããŒã¹ãçšããå ŽåãããŒã¿ããŒã¹ãã©ã®ãããªç¶æ ã«å€ãã£ãã®ãã§ã¯ãªããããŒã¿ããŒã¹ã«å¯ŸããŠäœãè¡ã£ãã®ãããœãŒã¹ã³ãŒã管çã·ã¹ãã ã§ç®¡çãããããšã«ãªããŸãã
**å®çŸ©: ããŒã¿ã»ã¢ãŒã·ã§ã³(data motion)**ãšã¯æ¢åã®ããŒã¿ã®åœ¢ç¶ãå€ããæ°ãããªã£ãã¹ããŒãã«ãã®ããŒã¿ãåãããã«ããããšãæããŸãã
ããããªãããã»ãšãã©ã®ãããžã§ã¯ãã«ãããŠãããŒã¿ã»ã¢ãŒã·ã§ã³ã®åãçµã¿ã®æ¹ãããŒãžç«¶åã®å¯ŸåŠãããã¯ããã«éèŠãšãªãã®ãæ®éã§ãããªããªããã¢ããªã±ãŒã·ã§ã³ãæ¬çªç°å¢ã«ãªãªãŒã¹ãããŠããŸããšãæ¬çªç°å¢ã®ããŒã¿ããŒã¹ã¯ç°¡åã«ã¯ç Žæ£ã§ããªãããŒã¿ãåžžã«æã€ããšã«ãªãããã§ãã
ãããªãçç±ã¯ãã¹ããŒãèªäœãç®çã§ããã®ã«å¯Ÿãã(ã€ãŸãã¹ããŒããã©ã®ããã«å€æŽããã®ãã®è§£éã¯äžæ¹åã«ãããªããªãã®ã«å¯Ÿã)ãããŒã¿ã¯æèã«äŸåãããã®ã ããã§ãã
ã¹ããŒãèªäœã¯ç®çãããŒã¿ã¯æèã«äŸåããã®èšãåããäœã奜ããå°è±¡çã ã£ããæå³ã¯ç解ããããŠããªãããã©ãã
ã€ãŸããé©åãªå€æãè¡ãããã«ã¯ãéçºè ããã¡ã€ã³ç¹æã®ã«ãŒã«ãèªåã®æã§é©çšããªããŠã¯ãªããªãã®ã§ãã
ããããªãããã¢ããªã±ãŒã·ã§ã³ããŸã æ¬çªç°å¢ã«ãªãªãŒã¹ãããŠããªãã®ã§ããã°ãç¶æ ããŒã¹ã¯ååã«å©çšå¯èœãªãã¯ããã¯ã§ãã
ããã¯å®è·µããŠãããååã®æ¬çªãªãªãŒã¹åãŸã§ã¯ãã€ã°ã¬ãŒã·ã§ã³ãã¡ã€ã«ãçŽæ¥æžãæããŠããã
10.2.1 ãããã¯ã·ã§ã³ã»ã³ãŒãã«ãããããŒã¿ããŒã¹ã»ãã©ã³ã¶ã¯ã·ã§ã³ã®ç®¡ç
ããããªãããããŒã¿ã®å€æŽã䌎ãããžãã¹ã»ãªãã¬ãŒã·ã§ã³ã®å Žåããã¹ãŠã®æŽæ°ãã¢ãããã¯(atomic)ã«è¡ãããªããšãããŒã¿äžæŽåãçã¿åºãå¯èœæ§ãåºãŠããŸãã
å®çŸ©: ã¢ãããã¯ã®æŽæ°ãšã¯ãè€æ°ã®æŽæ°ãäžé£ã®ã€ãªãããæã£ãŠè¡ãããªããŠã¯ãªããªãå Žåã«ãåŠçã®éäžã§äœãåé¡ããªããã°ããã¹ãŠã®ããŒã¿ã®å€æŽãããŒã¿ããŒã¹ã«åæ ãããã®éã«ãåŠçã®éäžã§äœããã®åé¡ãçºçããããã©ã®å€æŽãããŒã¿ããŒã¹ã«ã¯åæ ããã«åŠçãçµããããšããäºè æäžã®æŽæ°ã®ããšãæããŸãã
**å®çŸ©: åäœäœæ¥(Unit of Work)**ãšã¯1ã€ã®ããžãã¹ã»ãªãã¬ãŒã·ã§ã³äžã§ããŒã¿ã®å€æŽãçºçãããªããžã§ã¯ããå šãŠä¿æãããã®ããžãã¹ã»ãªãã¬ãŒã·ã§ã³ãå®äºãããšãã«ããããã®ãªããžã§ã¯ãã«å¯ŸããŠè¡ãããããŒã¿ã®å€æŽ(äœæ¥)ã1åäœã«ãŸãšããŠããŒã¿ããŒã¹ã«åæ ãããã¿ãŒã³ã®ããšã§ã(ãã®ããšããŸãã«ãã®ãã¿ãŒã³ã®ååã®ç±æ¥ãšãªã£ãŠããŸã)ã
ããããªããããªã¬ãŒã·ã§ãã«ã»ããŒã¿ããŒã¹ã§ã¯ãªãããŒã¿ã¹ãã¢ã§ã¯ãããŒã¿äžæŽåãžã®å¯Ÿçãå¥ã®èŠ³ç¹ã§è¡ããŸãããã®å¯Ÿçãšã¯ã1ã€ã®ããžãã¹ã»ãªãã¬ãŒã·ã§ã³ã®äžã§è€æ°ã®ããã¥ã¡ã³ããå€æŽããªããŠãæžããããªããã¥ã¡ã³ãã®èšèšãè¡ãããšã§ãã
10.3 ãã¹ãã»ããŒã¿ã®ã©ã€ãã»ãµã€ã¯ã«
ãã®ããšãããçµ±åãã¹ãã§ã¯ããã¹ãã»ã±ãŒã¹ãèªèº«ã§çšæããŠããªãããŒã¿ããŒã¹ã®ç¶æ ã«äŸåãã¹ãã§ã¯ãªãããšããçµè«ã«è³ããŸãã
10.3.1 çµ±åãã¹ãã«ããããã¹ãã»ã±ãŒã¹ã®å®è¡: åæã«è€æ°å®è¡ãã¹ããããããã¯ã1ã€ãã€å®è¡ãã¹ããïŒ
ãã®ãããçµ±åãã¹ãã®ããã©ãŒãã³ã¹ãæ¹åããããã«ãå€ãã®æéãšåŽåãè²»ãããŠãè€æ°ã®ãã¹ãã±ãŒã¹ãç¡çããŠåæã«å®è¡ããããã«ããããã¯ããã¹ãã»ã±ãŒã¹ã1ã€ãã€å®è¡ããŠè¡ãæ¹ãçŸå®çã§ãã
æ±ããåå¥ã«ããŒã¿ããŒã¹ã»ã€ã³ã¹ã¿ã³ã¹ãæãŠãããã«ããããšã®æ¹ãçŸå®çãªã®ã§ãããã ããæ¬æžã¯ãDockerã䜿ã£ãŠãåéçºè ã1ã€ã®ããŒã¿ããŒã¹ã€ã³ã¹ã¿ã³ã¹ãæ±ããããã«ããããšã«ç°ãå±ããŠããããã§ã¯ãããŸãããæ¬æžãç°ãå±ããŠããã®ã¯Dockerã䜿ã£ãæªçãªäžŠååã«å¯ŸããŠã§ãããDockerã®äœ¿çšèªäœã§ã¯ãªãã®ã§ãã
10.3.2 çµ±åãã¹ãã§ã®ããŒã¿ã®åŸå§æ«
TIP: ããŒã¿ã®åŸå§æ«ãè¡ãã¹ã¯ãªããã§ã¯ãéåžžããŒã¿ã¯å šãŠåãé€ãããã®ã§ãããåç §ããŒã¿ã¯æ¶ããŠåãé€ãããªãããã«ããªããŠã¯ãªããŸããããªããªããåç §ããŒã¿ã®å€æŽã¯ã¹ããŒããšå ±ã«ç§»è¡ã§ããè¡ã£ãŠã¯ãªããªãããã§ãã
10.3.3 ã¡ã¢ãªå (in-memory)ããŒã¿ããŒã¹ã®äœ¿çšã«é¢ããåé¡
çµ±åãã¹ãã§äœ¿ãããããŒã¿ããŒã¹ã¯å ±æäŸåã§ã¯ãªãããã(ãã®ããŒã¿ããŒã¹ããããžã§ã¯ãå ã§å¯äžã®ç®¡çäžã«ããäŸåã§ããããšããåæã®å Žåã)ãã®ããŒã¿ããŒã¹ãã¡ã¢ãªå ããŒã¿ããŒã¹ã«çœ®ãæããããšã§ãçµ±åãã¹ããå®è³ªçã«åäœãã¹ãã®ããã«æ±ããããã«ãªããŸããããã¯åè¿°ã®ã³ã³ããã䜿ã£ãã¢ãããŒãã«äŒŒãŠããŸãã
ããããªããããããã®å¹æãããã®ã«ãããããããæ¬æžã§ã¯ããã¹ãã®éã«ãã¡ã¢ãªå ããŒã¿ããŒã¹ã䜿ãããšãæšå¥šããŠããŸããããã®çç±ã¯ãã¡ã¢ãªå ããŒã¿ããŒã¹ã¯æ©èœçã«ãããŠäžè¬çãªããŒã¿ããŒã¹ãšç°ãªãéšåãããããã§ãããã®ããšã¯ãæ¬çªç°å¢ãšãã¹ãç°å¢ã§è¡ãããšãç°ãªããšé©åãªãã¹ããè¡ããªããªãåé¡ãšåãã§ãã
æ®æ®µããSQLiteã®ã€ã³ã¡ã¢ãªããŒã¿ããŒã¹ã䜿ã£ãŠçµ±åãã¹ããè¡ã£ãŠãããæ¬çªç°å¢ãšå šãç°ãªãããŒã¿ããŒã¹ã䜿ã£ãŠããããšãããåžžã«åœéœæ§åœé°æ§ãèµ·ããããããšãæèããªããã°ãªããªãããã ããšãŠãæ©ããã¹ããå®è¡ã§ããã¡ãªãããããã®ã§ãããããã䜿ãç¶ãããšæãã
TIPS: ãã¹ãç°å¢ã§äœ¿çšããããŒã¿ããŒã¹ã管çã·ã¹ãã (DataBase Management System: DBMS)ãšæ¬çªç°å¢ã§äœ¿çšããããŒã¿ããŒã¹ç®¡çã·ã¹ãã ã¯åãçš®é¡ã®ãã®ãçšæããªããŠã¯ãªããŸãããå€ãã®å ŽåãããŒãžã§ã³ããšãã£ãã·ã§ã³ãéã£ãŠãããããŸã§æ°ã«ããå¿ èŠã¯ç¡ãã®ã§ããããã³ããŒã«é¢ããŠã¯å¿ ãåããã³ããŒã«ããªããŠã¯ãªããŸããã
10.4 ãã¹ãã»ã³ãŒãã®åå©çš
ããã§ããã®10.4ç¯ã§ã¯ããã¹ãã»ã±ãŒã¹ã®æºåãã§ãŒãºãå®è¡ãã§ãŒãºã確èªãã§ãŒãºã®3ã€ã®ãã§ãŒãºã«ãããŠãããããã©ãããã°ã³ãŒãéãæžããããšãã§ããã®ãããšããäºã«ã€ããŠèŠãŠãããŸãã
10.4.1 æºå(Arrange)ãã§ãŒãºã§ã®ã³ãŒãã®åå©çš
ãŸãã¯ç°¡åã«ã§ããããšããå§ããŠãããŸããããã€ãŸããæåã¯ãå ã®ã³ãŒãããã£ããã¹ãã»ã¯ã©ã¹ãšåããã¹ãã»ã¯ã©ã¹ã®äžã«ãã¡ã¯ããªã»ã¡ãœãããé 眮ããã®ã§ãããããŠã»ã³ãŒãã®éè€ãç®ç«ã£ãŠãããããã®ãšãã«ããã¡ã¯ããªã»ã¡ãœãããåå¥ã®ãã«ããŒã»ã¯ã©ã¹ã«ç§»ãããã«ããŸãããã ãããã¡ã¯ããªã»ã¡ãœãããåºåºã¯ã©ã¹ã«é 眮ããããšã¯è¡ããªãããã«ããŸãããããªããªããåºåºã¯ã©ã¹ã«ã¯ããã¹ãŠã®ãã¹ãã»ã¡ãœããã§å®è¡ãããã³ãŒã(ããšãã°ããã¹ãã§äœ¿ãããããŒã¿ã®åŸå§æ«ãªã©ãè¡ãã³ãŒã)ã ããæž¡ããããã«ãã¹ãã ããã§ãã
ãã¹ãã³ãŒã以å€ã®æ®æ®µã®éçºã§ãåãèãæ¹ã倧äºã ãšæã£ãã
10.4.2 å®è¡(Act)ãã§ãŒãºã§ã®ã³ãŒãã®åå©çš
ãã®å®è¡ãã§ãŒãºããªãã¡ã¯ã¿ãªã³ã°ãå¯èœã§ããããšãã°ã次ã®ãªã¹ã10.11ã§ç€ºãããã«ããã¹ã察象ã·ã¹ãã (ä»åã®å Žåã¯ãUserController)ã®æ©èœãžã®åŒã³åºããå§è²ãããã¡ãœãããå°å ¥ããããšãèããããŸãã
10.4.3 確èª(Assert)ãã§ãŒãºã§ã®ã³ãŒãã®åå©çš
確èªãã§ãŒãºã®ãªãã¡ã¯ã¿ãªã³ã°ãåè¿°ã®æºå(Arrange)ãã§ãŒãºãšåãããã«ãCreateUserã¡ãœãããCreateCompanyã¡ãœããã®ãããªãã«ããŒã»ã¡ãœãããå°å ¥ããããšãã§ããŸãã
10.4.4 ãã¹ãã®éã«ããŒã¿ããŒã¹ã»ãã©ã³ã¶ã¯ã·ã§ã³ã®æ°ãå€ããªãäºã¯åé¡ã«ã¯ãªããªãã®ãïŒ
ããã§èããªããŠã¯ãªããªãäºã¯ãããŒã¿ããŒã¹ã»ãã©ã³ã¶ã¯ã·ã§ã³ã®æ°ãå¢ããäºã¯åé¡ãªã®ãããããŠãããããããåé¡ãªã®ã§ããã°ããã®åé¡ã«å¯ŸããŠäœãã§ããã®ãããšããããšã§ãã
10.5.2 ãªããžããªããã¹ããã¹ãã?
ãã®ãããO/RããããŒã䜿ã£ãŠããã®ã§ããã°ããªããžããªãçŽæ¥æ€èšŒããã®ã§ã¯ãªããçµ±åãã¹ãã®ã·ããªãªã®äžéšã«å«ããŠæ€èšŒããããã«ããŸãããã åæ§ã«ãEventDispatcher ã¯ã©ã¹(ãã¡ã€ã³ã»ã€ãã³ããããšã«ç®¡çäžã«ãªãäŸåãžã®åŒã³åºããè¡ãã¯ã©ã¹)ãåå¥ã«ãã¹ãããªãããã«ããŸãããããªããªãããã®ãããªã¯ã©ã¹ããã¹ãããŠããè€éãªã¢ãã¯ã®ä»çµã¿ãç¶æããããã«èšå€§ãªã³ã¹ãããããã®ã«ãããããããéè¡ã«å¯Ÿããä¿è·ã¯ã»ãšãã©åŸãããªãããã§ãã
第4éš: åäœãã¹ãã®ã¢ã³ãã»ãã¿ãŒã³
第11ç« : åäœãã¹ãã®ã¢ã³ãã»ãã¿ãŒã³
11.1.3 ãã©ã€ããŒããªã¡ãœãããçŽæ¥ãã¹ãããããšãåãå ¥ããããã®ã¯ã©ã®ãããªå Žåãªã®ã?
ãã ããããã§æ³šæããŠæ¬²ããã®ã¯ããã©ã€ããŒããªã¡ãœããããã¹ãããããšèªäœã¯æªãããšã§ã¯ç¡ãããšããããšã§ãããã©ã€ããŒããªã¡ãœããããã¹ããã¹ãã§ã¯ãªãå¯äžã®çç±ã¯ããã©ã€ããŒããªã¡ãœããã¯å®è£ ã®è©³çŽ°ã«ç¹ãããã®ã§ãããããå®è£ ã®è©³çŽ°ããã¹ããããããã«ãªããšããã®ãã¹ãã¯å£ãããããã®ã«ãªã£ãŠããŸãããã§ãããšã¯èšãã極ããŠãŸãã«ããã©ã€ããŒãã§ãããªããã芳å¯å¯èœãªæ¯ãèãã®äžéšãšãªãã¡ãœãããååšããããšããããŸã(ãããŠããã®ããšã¯ãè¡š11.1ã®ã該åœãªããã¯æ£ç¢ºã«ã¯æ£ãããªãããšã«ãªããŸã)ã
ãŸãããããšã¯å¥ã®éžæè¢ãšããŠãããããã®ã¯ã©ã¹ã®APIããã©ã€ããŒãã®ãŸãŸã«ãããã®ã§ããã°ããã¹ãã®éã«ãªãã¬ã¯ã·ã§ã³ãçšããŠInquiryã¯ã©ã¹ã®ã€ã³ã¹ã¿ã³ã¹ãçæããããšãå¯èœã§ããããã¯ããçš®ã®è£æã®ããã«æãããããããŸããããO/RããããŒãšåãããšãããŠããã ãã«éããŸããã(O/RããããŒããå éšã§ã¯ãªãã¬ã¯ã·ã§ã³ãçšããŠã€ã³ã¹ã¿ã³ã¹ãçæããŠããŸã)ã
11.2 ãã©ã€ããŒããªç¶æ ã®å ¬é
ããããªãããããã¯ã¢ã³ããã¿ãŒã³ã§ããããã§æãåºããŠã»ããã®ãããã¹ãã§ã¯ãæ¬çªç°å¢ãšå šãåãæ¹æ³ã§ãã¹ã察象ã®ã³ãŒããšããåããããªããŠã¯ãªããªãããšããããšã§ããã€ãŸãããã¹ãã ãããšèšã£ãŠç¹å¥ãªããšãèš±ãããããã§ã¯ãªãã®ã§ãã
11.3 ãã¹ããžã®ãã¡ã€ã³ç¥èã®æŒæŽ©
åºæ¬çã«ããã®ãããªãã¹ãã¯ãããã¯ã·ã§ã³ã»ã³ãŒãããã¹ãã³ãŒãã«ã³ããŒ&ããŒã¹ãããŠãããšäœãå€ããããªãããšã«ãªããŸãã ãçµå±ã®ãšããããã®ãããªãã¹ãã¯å®è£ ã®è©³çŽ°ãšçµã³ã€ããå¥ã®åœ¢ã®äŸã«éããŸããããã®ããããã®ãããªãã¹ãã¯ãªãã¡ã¯ã¿ãªã³ã°ãžã®èæ§ãã»ãŒæã£ãŠãããããã¹ããšããŠã®äŸ¡å€ããªãããšã«ãªããŸãã
ãã®ä»£ããã次ã®ãªã¹ã11.7ã§ç€ºãããã«ãæåŸ å€ãã®ãã®ããã¹ãã»ã³ãŒãã«çŽæ¥æžã蟌ã¿ãŸãã
ãªããªããæåŸ å€ãçŽæ¥æžã蟌ãäºã¯ããããã¯ã·ã§ã³ã»ã³ãŒãã䜿ããã«å¥ã®æ¹æ³ã§ãã®çµæãç®åºããããšãæå³ããããã§ãã
11.4 ãããã¯ã·ã§ã³ã³ãŒããžã®æ±æ
å®çŸ©: ãããã¯ã·ã§ã³ã»ã³ãŒããžã®æ±æãšã¯ããã¹ãã§ã®ã¿å¿ èŠãšãããã³ãŒãããããã¯ã·ã§ã³ã»ã³ãŒãã«å ããããšãæããŸãã
ãã ããããã§æ³šæããŠã»ããã®ã¯ãILoggerã€ã³ã¿ãŒãã§ã€ã¹ã®å°å ¥ãééããªããããã¯ã·ã§ã³ã»ã³ãŒããžã®æ±æã§ããããšããããšã§ãããªããªãããã®ã€ã³ã¿ãŒãã§ã€ã¹ã®å°å ¥ã¯ãã¹ãã®ããã ãã«è¡ã£ãããšã ããã§ããããã§ã¯ããã®ãããªå®è£ ã«ããããšã§äœã以åããè¯ããªãã®ã§ããããïŒ ããŸãILoggerã€ã³ã¿ãŒãã§ã€ã¹ã®å°å ¥ã«ãã£ãŠçãããããã¯ã·ã§ã³ã»ã³ãŒããžã®æ±æã¯ãçåœå€ãçšããå Žåãšæ¯ã¹ãŠåœ±é¿ãå°ãªãããã®å¯ŸåŠãç°¡åã«è¡ããŸããããã«ãçåœå€ãçšããŠããæãšã¯ç°ãªãããã¹ãæã«ãã䜿ãããªãã¯ãã®ã³ãŒããééã£ãŠæ¬çªç°å¢ã§åŒã³åºãããããšããªããªããŸããå ããŠãã€ã³ã¿ãŒãã§ãŒã¹ã«ã¯ãã°ãå«ããäºã¯ã§ããŸããããªããªããã€ã³ã¿ãŒãã§ã€ã¹ã¯åãªãå¥çŽã§ãããå ·äœçãªã³ãŒããæã€ããã§ã¯ãªãããã§ãããã®ããã«ãã€ã³ã¿ãŒãã§ã€ã¹ã®å°å ¥ã¯ãçåœå€ãçšããå Žåãšã¯ç°ãªããåŠçã«é¢ããã³ãŒããããã«å«ãŸããããã§ã¯ãªãããããã®ããšãåå ã§ãã°ãçããäºã¯ç¡ãã®ã§ãã
11.5 å ·è±¡ã¯ã©ã¹ã«å¯Ÿãããã¹ãã»ããã«
NOTE: æ¢åã®æ©èœããã®ãŸãŸäœ¿ããããã«ããããã«ãå ·è±¡ã¯ã©ã¹ããã¹ãã»ããã«ã®å¯Ÿè±¡ã«ããäºã¯ã¢ã³ãã»ãã¿ãŒã³ã§ãããããããããªããŠã¯ãªããªãã®ã§ããã°ããã®å ·è±¡ã¯ã©ã¹ãåäžè²¬ä»»ã®ååãéµå®ããŠããªãããšãåå ãšãªã£ãŠããå¯èœæ§ããããŸãã
ãŸãšã
çŸåšæ¥æã ç°å¢ã³ã³ããã¹ã(ambient context) ãšããŠè¡šçŸããäºã¯ãããã¯ã·ã§ã³ã»ã³ãŒããæ±æããããšã§ããããã¹ãã®å®æœãé£ããããŠããŸãããã®ãããçŸåšæ¥æã¯æ瀺çã«äŸåãšããŠæ³šå ¥ãããªããŠã¯ãªããªãããŸãããã®æ³šå ¥ã«ã¯ãµãŒãã¹ãšããŠæ³šå ¥ããæ¹æ³ãšå€ãšããŠæ³šå ¥ããæ¹æ³ã®2ã€ã®æ¹æ³ããããå¯èœãªéããå€ãšããŠæ³šå ¥ããããšãéžæããã
ãããã«
èªã¿å§ããã®ã¯2024幎7æ25æ¥(æš)ããããŠãèªã¿çµãã£ãã®ã¯2024幎10æ7æ¥(æ)ã75æ¥éããã£ãã
äžæ¥ã«äžåæ¬ãã²ããã°åã¡ïŒ1ããŒãžèªãã°å€§åå©ïŒãšããç®æšã§èªã¿é²ããŠããŸããã
ä»åã¯å€§äºã ãªããšæã£ãããããã¯å°è±¡ã«æ®ã£ããªããšæã£ãéšåãããŒã«ãã³ã§äžç·ãåŒãããããåŒçšããŠæãåºãããããŠã³ã¡ã³ãããããã°ããããšããããšãèšé²ãšããŠæ®ããŸããã
ãã£ãšæŽçãããããŸãšãããããæ¹ãããè¯ãã®ã§ãããããèªæžãç¶ç¶ããããšããããšãç®æšã«ãããã£ãã®ã§ã劥åããŠæãæããŠãããã§ãããšããŸããã
åŸæ¥ãåãã®æ¬ã§èªãã ãããªãã ã£ãïŒãšãªãããã®ããŒãžãèŠãŠãããããã ãšæ¬ã«èŸ¿ãçããããªããšãèµ·ããã°ãæåããšèããŠããŸãã ãã ããããã®ããã°ããŒãžãæžããŠããä»ããšãŠãé·ãåéã«ãªãããããŠããã¯ã»ãŒåŒçšã§ããããšããããã§ã«ãããããŸãèªã¿è¿ããããªããªããšæããŠããŸããæ°è»œã«ãã®ããŒãžãèªã¿çŽãããã«ã§ããããšæããŸãããäœãæ¹åã§ããããšã¯ããã§ããããïŒ
ãšã¯ããããã°ãããã®ããæ¹ãããŒã¹ã«ããŠã次ã®æ¬ããããŠãŸã次ã®æ¬ãšãèªæžãéåããããªãã§ç¶ããŠãããããªãšèããŠããŸãã
以äžã§ãã