ããªãã¡ã¯ã¿ãªã³ã°ãã®å®å ¨èªç ´ããã®1
ãã¡ã¦ã©ã¼ã®è¨ããã¨ç¥ããåèã ãã©ãç§ã¯15ç« æ§æã®ãã¡ã«ã¿ãã°é¨åï¼ç¬¬5ç« ã第12ç« ï¼ãä»ã¾ã§èªãã§ããªãã£ãã
çç±ã¨ãã¦ã¯ããã¯ãå¤ããã¨ããããªã«é£ããå
容ã§ã¯ç¡ããã¨ããªãã¡ã¯ã¿ãªã³ã°ã®ææ³ã¨ããæå³ã§ã¯ç解ãã¦ãããã¨ã
ãã³ãã«å¤ãæ¬ãªã®ã§ãããããããªã¨æã£ã¦ãããã ãã©ãå°ãèªã¿ç´ããããã£ã±ãä¸åº¦ã¯å
¨é¨æ¸ãã¹ãã ã£ãã
ãªãã¡ã¯ã¿ãªã³ã°ã®ææ³ã¨åãããããã«ã¿ãã°ã«ããå種æè¡ã¯éè¦ã ã£ãã
ããã«ãããããã®æ¬ã¯ï¼ãã¨èãããã¨ãã«ãã¨ãããããããæãããã¨ã¯å¤ãã¦ããã®ããå®èªãã¦ãªãã®ã¯è³ªãæªãã¨ããã®ãããã
ã¨ãããã¨ã§ãä»åã¯ãã¯ããã«ãã¨ã第1ç« ã
ã¯ããã«
ããã§ã¯æ¬æ¸ã®èª¬æã¨ããªãã¡ã¯ã¿ãªã³ã°ã«ã¤ãã¦ã®è©±ãå°ãã
ã»ãªãã¡ã¯ã¿ãªã³ã°ã¯ãªã¹ã¯ãé«ãã®ã§ãã¿ããã«è¡ã£ã¦ã¯ãããªããã¨ã
ã»æé ãå®ããä½ç³»çã«è¡ããã¨ã
ã»å
·ä½çã«ã¯ã1度ã«1ã¹ããããã¤ãè¡ããã¨ã
ããã«ããã¡ã¦ã©ã¼ã¨Kent Beckã以åã«ããä»äºã®è©±ããããããã£ã¨èªãã
第1ç« ããªãã¡ã¯ã¿ãªã³ã°ã¼æåã®ä¾
大ã¾ãã«ã¯ã3ã¤ã®ã¯ã©ã¹ãããªãã·ã¹ãã ããªãã¡ã¯ã¿ãªã³ã°ãã¦ããã¨ããæµãã
æåã®ç¶æ
ã§ã¯ãclass Customerãã巨大ãªstatement()ã¡ã½ãããæã£ã¦ãããæããã«æªãè¨è¨ã¨ãªã£ã¦ããã
ã¾ãã¯ãEclipseãèµ·åãã¦ãã®æªãã³ã¼ããæ¸ããæ¬æ¸ã®éãã«ãªãã¡ã¯ã¿ãªã³ã°ããã¦ããã
å
容ã¯ã1度ã«1ã¹ããããã¤ãã®ææ³ãå®ã£ã¦ããã®ã§ãé常ã«ç°¡åã
é ã使ãã®ã¯æå¾ã®ããªã¢ã¼ãã£ãºã ã ãã
ã¾ãæåã«ãã¹ãã®éè¦ããæ¸ãããã
ï¼P7~8ï¼ æåã«ãããã¨ã¯å¸¸ã«åãã§ãã対象ã¨ãªãã³ã¼ãã«ã¤ãã¦ãã¡ãã¨ãããã¹ã群ãä½ãããããã¨ã§ãã ãªãã¡ã¯ã¿ãªã³ã°ã®æåã¯ãè¯ããã¹ããç¨æã§ãããã§æ±ºã¾ãã¾ãã
ã¨ããããæ¬æ¸ã«ã¯ãã¹ãã³ã¼ãã¯ãªãã®ã§ãJUnitã使ã£ã¦èªåã§æ¸ãã
ããã¦ãªãã¡ã¯ã¿ãªã³ã°ãã¯ãããã
ã»ã¨ãã©ãåºæ¬çãªãã¨ã ãã©ãæ¹ãã¦èªãã¨åå¼·ã«ãªãã
ã¡ã½ããã®æ½åº(P110)
switchæãã¡ã½ããã«ããã
ãã¼ã«ã«ãªã¹ã³ã¼ããæã¤å¤æ°ã¯ãæ°è¦ã¡ã½ããã®å¼æ°ãä¸æå¤æ°ã«ãªããªããæ¤è¨ãããå¤æ´ãããªãå¤æ°ã¯ã¡ã½ããã®å¼æ°ã¨ãã¦æ¸¡ããã¨ãã§ããã
å¤æ°åãå¤æ´ãã
ã³ã³ãã¤ã©ãç解ã§ããã ãã§ã¯ãªãã人éã«ã¨ã£ã¦è§£ããããã³ã¼ãã«ããã
ã¡ã½ããã®ç§»å(P142)
使ç¨ãããã¼ã¿ãæã¤ãªãã¸ã§ã¯ãã«ã¡ã½ããã¯å®ç¾©ãããã¹ãã
åãåããã«ããä¸æå¤æ°ã®ç½®ãæã(P120)
代å
¥ããå¾ã«å¤æ´ãããªãä¸æå¤æ°ã¯ãåãåããã¡ã½ããã«ããã
ä¸æå¤æ°ã¯é·ãã¦è¤éãªã«ã¼ãã³ã®åå ã¨ãªãã®ã§ãã§ããã ãæ¸ããã
thisAmountãtotalAmountã®ãããªããã£ã½ãå¤æ°ãããããã
P34ãæéè¨ç®ã®æ¡ä»¶æãããªã¢ã¼ãã£ãºã ã«ç½®ãæãã
ããã ããã¡ãã£ã¨å¤§ããã
ãä»ã®ãªãã¸ã§ã¯ãã®å±æ§ã調ã¹ãswitchæãæ¸ããã¨ã¯ã常ã«ééãã§ããä»ã®ãªãã¸ã§ã¯ãã§ã¯ãªãèªåèªèº«ã«ã¤ãã¦è¡ãã¹ããªã®ã§ããã
ã¨ããããããå®ç¾ããããã®ããã«ä»¥ä¸ã®æé ãå¿
è¦ã
State/Strategyã«ããã¿ã¤ãã³ã¼ãã®ç½®ãæã(P227)
èªå·±ã«ãã»ã«åãã£ã¼ã«ã(P171)
ã¡ã½ããã®ç§»å(P142)
ããªã¢ã¼ãã£ãºã ã«ããæ¡ä»¶è¨è¿°ã®ç½®ãæã(P225)
ã¾ã¨ã
P52 ï¼ãªãã¡ã¯ã¿ãªã³ã°ã¯ï¼ã¯ã©ã¹ã®è²¬ä»»ãåå²ãããä¿å®ããããã³ã¼ããæ¸ãã®ã«å½¹ç«ã¡ã¾ãã æç¶ãçãªã³ã¼ãã¨ã¯ããªãæ§åãç°ãªãã®ã§ãæ £ããã®ã«ã¯æéããããããããã¾ããã ãããããã£ããæ £ãã¦ãã¾ãã°ãããæç¶ãçããã°ã©ãã³ã°ã«ã¯æ»ããªããã®ã§ãã
ãã¯ããã«ãã§ãã¡ã¦ã©ã¼ãè¨åããããã¸ã§ã¯ããæ±ãã³ã¼ãã ã£ããããã
ãã®ä¾ãå«ãããªãã¡ã¯ã¿ãªã³ã°ã®å·¥æ°ãè¦ç©ãããããã¸ã§ã¯ãã¨ããã®ã¯ã»ã¨ãã©ç¡ãã
æ¬æ¸ãèªãã§ããã®äºå®ã¯å¤ãããããããèªãã ããã£ã¦å·¥æ°ãããããããã§ã¯ãªãã
ãã ããããªä¸ã§ãæ¬æ¸ã®ã«ã¿ãã°ã«ããæè¡ãç¿å¾ããã®ã¯å¤§äºããªãã¡ã¯ã¿ãªã³ã°äºã
ã®åã«ãã³ã¼ãã®è³ªãè¯ããªãã
ãã³ãã«å¤ãæ¬ãªã®ã§ãä»é¢¨ã®æ¸ãæ¹ãã¨ããæå³ã§ã¯åèã«ãªããªããã©ãæè¡ã¨ãã¦ã¯ãã®ä¸æ©æåã®ãè¨è¨ããå¦ã¹ãã
ä¾ãã°ä¸è¨ã®å¼ç¨ã®éããJavaã§æ¸ããæç¶ãåã®ã³ã¼ããããã£ããããããã¹ãã¼ãã«ä¿®æ£ã§ããããã«ãªãã
並è¡ã§ä»ã«ãããããã¨èªãã§ãããã©ã8æä¸ã«ã¯ããªãã¡ã¯ã¿ãªã³ã°ããçµãããã