# Code Complete
- åºç€
- ã¡ã¿ãã¡ã«ããéçºãžã®ç解ãæ·±ãã
- äžæµå·¥çš
- ã³ã³ã¹ãã©ã¯ã·ã§ã³ã®éèŠãªæ±ºæ
- èšèš
- ã¯ã©ã¹ã®äœæ
- é«å質ãªã«ãŒãã³
- é²åŸ¡çããã°ã©ãã³ã°
- å€æ°ã®äœ¿çš
- å€æ°åã®å
- åºæ¬çãªããŒã¿å
- ç¹æ®ãªããŒã¿å
- ã¹ãã¬ãŒããªã³ãŒãã®æ§æ
- æ¡ä»¶æã®äœ¿çš
- ã«ãŒã
- ç¹æ®ãªå¶åŸ¡æ§é
- ããŒãã«é§åæ¹åŒ
- å¶åŸ¡æ§é ã®åé¡
# åºç€
# ãœãããŠã§ã¢ã³ã³ã¹ãã©ã¯ã·ã§ã³ãšã¯
- ã³ã³ã¹ãã©ã¯ã·ã§ã³ãšã¯ããã°ã©ãã³ã°ã®ããš
- ã³ãŒãã£ã³ã°ïŒãããã°ïŒ αïŒè©³çŽ°èšèšããŠããããã¹ããªã©ïŒãããªã
- ãã³ãŒãã£ã³ã°ããšããèšèåäœã¯ãåãªãæ©æ¢°çãªäœæ¥ãé£æ³ããããããã³ã³ã¹ãã©ã¯ã·ã§ã³ã®èª¬æãšããŠã¯é©åã§ã¯ãªã
- ã³ã³ã¹ãã©ã¯ã·ã§ã³ä»¥å€ã®äœæ¥ã¯ïŒ
- ãããžã§ã¯ããããžã¡ã³ã
- èŠæ±éçºïŒèŠä»¶å®çŸ©ïŒ
- æŠèŠèšèšïŒã¢ãŒããã¯ãã£ïŒ
- UI èšèš
- ã·ã¹ãã ãã¹ã
- ä¿å®
# ãªãã³ã³ã¹ãã©ã¯ã·ã§ã³ãéèŠã
- éçºæéã®å€§éšåãå ãããã
- éçºã®äžå¿ã§ãããã
- ã³ã³ã¹ãã©ã¯ã·ã§ã³ã®æ¹åã¯é©ãã¹ãå¹æããããããã
- ã³ãŒããå¯äžã®ããã¥ã¡ã³ãã«ãªã£ãŠããŸãããšããããããã
- ã©ãã ãæ¥ãã§ããŠã絶察ã«çç¥ã§ããªãå·¥çšã§ãããã
# ã¡ã¿ãã¡ã«ããéçºãžã®ç解ãæ·±ãã
# ã¡ã¿ãã¡ã®éèŠæ§
- ã¡ã¿ãã¡ã䜿ã£ãç解ããã¢ããªã³ã°ããšãã
- ããç解ã§ããªããã®ããæ¢ã«ç解ããŠãããã®ãšç §ããåãããããšã§ãç解ãæ·±ãŸãããš
- æŠå¿µå šäœãææ¡ãããããªã
# ã¡ã¿ãã¡ã®äœ¿çšæ¹æ³
ã¡ã¿ãã¡ã¯ãã¥ãŒãªã¹ãã£ã¯ã¹ã®æå³åãã匷ããã©ãããã°ç©äºãããŸãããããèããããã«äœ¿ããã®ã§ããã
- ã¢ã«ãŽãªãºã
- å³å¯ã«å®çŸ©ãããäžé£ã®åœä»€
- ãã¥ãŒãªã¹ãã£ã¯ã¹ïŒçºèŠçïŒ
- çããèŠã€ããããã«åœ¹ç«ã€ãã¯ããã¯
# ã·ã¹ãã æ§ç¯ã®ã¡ã¿ãã¡
- BAD) ã³ãŒããæžã
- æçŽãæžãã€ã¡ãŒãž
- æžããŠçµããããããŒã®ã
- BAD) ã·ã¹ãã ãè²ãŠã
- äœç©ãè²ãŠãã€ã¡ãŒãž
- ã³ãŒãã¯ããããè²ããªããåç©«ãã§ããªãã®ã
- SOSO) ã·ã¹ãã ãã€ã³ã¯ãªã¡ã³ã¿ã«ã«éçºãã
- çç é€æ®ã®ã€ã¡ãŒãž
- GOOD) ã·ã¹ãã ãæ§ç¯ãã
- 建ç¯ã®ã€ã¡ãŒãž
- çŸä»£ã®ã·ã¹ãã éçºã«ãããçšèªã®å€ãã¯å»ºç¯ç±æ¥ãe.g. ã¢ãŒããã¯ãã£ããã«ããetc
話ã¯éžãããã©ãç¥èãåžžã«åéããŠã¹ããã¯ããŠãããç¥çéå ·ç®±ããšããã¡ã¿ãã¡ãããã
# äžæµå·¥çš
# æºåã®éèŠæ§
- å質åäžãããã¿ã€ãã³ã°ã
- ãããžã§ã¯ãã®çµããã®å Žå
- ã·ã¹ãã ãã¹ãã匷åãã
- ãã ããã©ãã ããã¹ãããããšããã§ãããšãã¯ãœãªãæå³ããªã
- ãããžã§ã¯ãã®éäžã®å Žå
- ã³ã³ã¹ãã©ã¯ã·ã§ã³ã®ãã©ã¯ãã£ã¹ã匷åãã
- ãããžã§ã¯ãã®æåã®å Žå
- é«å質ãªèšç»ãèŠæ±ãèšèšãè¡ã
- å®ãè»ãšããŠèšèšãããã®ã¯ãã©ãã ãåŸæ®µã§åªåããŠãããŒã«ã¹ãã€ã¹ã«ã¯ãªããªãããã
- ãããžã§ã¯ãã®çµããã®å Žå
# æºåã®æ倧ã®ç®æš
ãªã¹ã¯ãæžããããšã
# æºåäžè¶³ã®åå
- äžæµæ åœéçºè ãä»äºãããªãã ãã®ç¥èãæã£ãŠããªããã
- ããã«ã³ãŒããæžãããè¡åãæŒãããããªãéçºè ããããã
- æºåã«ãããæéãäžåžãããæããªãããã察åŠæ³ïŒ
- ã¯ã£ããæã
- ã³ãŒãã£ã³ã°ããŠãããµãããã
- æºåãæ ãå±éºãäžåžã«å©ã蟌ã
- 転è·ãã
# æºåã«æå¥ãèšãããªãããã«ã¯
- è«çã§èšŽãã
- ãŠãŒã¶ãæ±ããŠããªããã®ãäœããšç®ãåœãŠãããªãã
- å€ãªæ§ç¯ããããšå¿ èŠã®ãªããã®ã«èšå€§ãªæéãšè³éãæ¶ããŠããã
- äŸãã§èšŽãã
- ãã©ã³ã¯ãã³ããŽããæãªããããã¯ãžã©ãæ»ã¬ãã¿ãããªé£ç©é£éã®äŸãšã
- ããŒã¿ã§èšŽãã
- åé¡ã®ä¿®æ£ææãããšã«ãªãã»ã©ãã³ã¹ãã¯ææ°çã«å¢ããã
- ããã¯ãŠã©ãŒã¿ãŒãã©ãŒã«ã»ã¢ãžã£ã€ã«ãåããªã
# ãœãããŠã§ã¢ã®çš®é¡
- ãããã·ã¹ãã
- ã¢ãžã£ã€ã«éçº
- å埩å ã®éçºææ³ãé©ããŠããïŒä»¥äžã亀äºã«ç¹°è¿ãè¡ãïŒ
- èšç»ãèŠä»¶å®çŸ©ãã¢ãŒããã¯ãã£ã®çå®
- ã³ã³ã¹ãã©ã¯ã·ã§ã³ãã·ã¹ãã ãã¹ããå質ä¿èšŒ
- ãã£ãããšããèŠæ±ä»æ§ã®çå®
- èšèšãšã³ãŒãã£ã³ã°ãåæã«ãã£ãŠããŸã
- å¥ããŒã ã§ã®ãã¹ãã QA ã¯ãªã
- ãããã·ã¹ãã
- ãŠã©ãŒã¿ãŒãã©ãŒã«éçº
- é次ç ãªéçºææ³ãé©ããŠãã
- ã¡ãããšããèŠæ±ä»æ§ã®çå®
- ã¢ãŒããã¯ãã£ã®èšèšãšã¬ãã¥ãŒ
- 詳现èšèšãšã¬ãã¥ãŒ
- å¥ããŒã ã§ã®ãã¹ã
- QA
# å埩åææ³
ã³ã¹ãã¯ä»¥äžã®é ã«å®ããªã
- æºåãªãã®é次åïŒé«ãïŒ
- æºåãªãã®å埩å
- æºåããã®é次å
- æºåããã®å埩åïŒå®ãïŒ
ã©ããªãããžã§ã¯ãã§ããæãéèŠãªèŠæ±ãšã¢ãŒããã¯ãã£ã®èŠçŽ ãæ©æã«æŽãåºãããšãã倧äºãç®å®ãšããŠïŒ
- é次åãªãäºåã« 80%ã®èŠæ±ãæããã«ããŠãã
- å埩åãªãäºåã« 20%ã®èŠæ±ãæããã«ããŠãã
# å埩å or é次å
- é次åã«åããŠãããã®
- èŠæ±ãå®å®ããŠãã
- èšèšãåçŽã§ç解ãããã
- ã¡ã³ããŒãåéã«ç²ŸéããŠãã
- ãããžã§ã¯ãã®ãªã¹ã¯ãäœã
- é·æçãªäºæž¬ãéèŠã§ãã
- äžæµã§ã®å€æŽãé«ãä»ã
- å埩åã«åããŠãããã®
- èŠæ±ãäžéæ
- èšèšãè€éã§ç解ãã«ãããæéãããã
- ã¡ã³ããŒãåéã«æãããªã
- ãããžã§ã¯ãã®ãªã¹ã¯ãé«ã
- é·æçãªäºæž¬ãéèŠã§ãªã
- äžæµã§ã®å€æŽã¯å®äŸ¡ã§ãã
以äžããããžã§ã¯ãã«é©ããã³ã³ã¹ãã©ã¯ã·ã§ã³ã®æºåãšã¯äœããèããŠã¿ã
# æºåïŒèª²é¡å®çŸ©
Product vision statement / Mission statement / 課é¡å®çŸ©
- ã·ã¹ãã ã解決ãã課é¡ãäœã§ããããå®çŸ©ãããã®
- ãœãªã¥ãŒã·ã§ã³ã«ã€ããŠã¯äžåèšåããªã
- ãŠãŒã¶ã®èšèã§æžããã³ã³ãã¥ãŒã¿çšèªã¯äœ¿ããªãã
- 以äžãé²ãããã®ãã®
- 誀ã£ã課é¡ã解決ããããšããŠæéãç¡é§ã«ããããš
- æ¬æ¥ã®èª²é¡ã解決ãããªãããš
# æºåïŒèŠæ±
èŠæ± / èŠæ±éçº / èŠæ±åæ / èŠæ±å®çŸ© / ä»æ§ / æ©èœä»æ§ / ã¹ãã㯠ãšã¯ïŒ
- ã·ã¹ãã ãäœããã¹ãããå®çŸ©ãããã®
# èŠæ±ãå¿ èŠãªçç±
- ã·ã¹ãã ã®æ©èœããŠãŒã¶äž»å°(not ããã°ã©ã)ã§æ±ºå®ããã®ã«åœ¹ç«ã€
- ããã°ã©ãå士ã®è°è«ãæžããã
- ææ»ããæå¶ã§ãã
# èŠæ±ã¯å€ãã
- 顧客ã¯ãéçºã®éçšãéããŠèªåèªèº«ã®ããŒãºãç解ããŠãããã®ã ãã
- å¹³åããŠåœåã®ä»æ§ã® 25% ã¯å€æŽããã
# èŠæ±å€æŽãžã®å¯ŸåŠæ¹æ³
- èŠæ±ããã¡ããšå®çŸ©ãããŠããããã§ãã¯ãªã¹ãã§ç¢ºèªãã
- ã³ã¹ããé¢ä¿è å šå¡ã«èªèããã
- å€æŽã®ç®¡çæé ãäºãå®ããŠãã
- å€æŽã«å¯Ÿå¿ã§ããéçºææ³ããšã
- ãããžã§ã¯ããäžæ¢ãã
- ãã®å€æŽãæ¬åœã«ããžãã¹ã«äŸ¡å€ãããããã®ãèãããã
# ã¢ãŒããã¯ãã£
- æäžäœã¬ãã«ã®èšèšãæŠç¥èšèšã®ããš
- æçµçãªã·ã¹ãã ã®å質ã決å®ãã
- åŸã§å€æŽãããšèšå€§ãªã³ã¹ããããã
# ã¢ãŒããã¯ãã£ã®æ§æèŠçŽ
- æŠèŠ
- å šäœæ§æããã£ãšèª¬æãããã®
- ã©ããªããŒããããã®ãåæ
- åããŒãã®åœ¹å²ã¯ïŒã€ã«çµã
- ããŒãéã®ããåãèŠåã¯æ確ã«ãã
- äž»èŠãªã¯ã©ã¹
- ã·ã¹ãã ã®ïŒå²ãåžãïŒå²ã®ã¯ã©ã¹ãæèšããæã
- ããŒã¿èšèš
- DB ã®å€§ãŸããªæ§é ãšå 容
- æ¥åã«ãŒã«
- äŸãã°é¡§å®¢æ å ±ã¯ 30 æ¥ããå€ããªã£ãŠã¯ãªããªãããªã©ããã°
- UI èšèš
- ãªãœãŒã¹ç®¡ç
- ã»ãã¥ãªãã£
- ããã©ãŒãã³ã¹
- ã¹ã±ãŒã©ããªãã£
- i18n, l10n
- ãšã©ãŒåŠç
- ã¡ãã»ãŒãžèŠçŽãªã©
- ãã©ãŒã«ããã¬ã©ã³ã¹
- ãªãŒããŒãšã³ãžãã¢ãªã³ã°
- ã©ããããå ç¢ã«ãã¹ãã
# ããã¢ãŒããã¯ãã£ãšã¯
- æ¡çšããçç±ãæ¡çšããªãã£ãçç±ãæèšãããŠãã
- éäžå€æŽããå Žåã¯å šäœãšèª¿åããããã«ãã
- ç®çãæ確ã§ããïŒããã©ãŒãã³ã¹éèŠãæè»ãªå€æŽå¯èœæ§éèŠããªã©ïŒ
- ãã·ã³ãèšèªã«äŸåããŠããªã
- éäžè¶³ããªãäžåºŠãã
- ãªã¹ã¯ãæèšãããŠãã
- è€æ°ã®è§åºŠããã®èŠè§£ãçã蟌ãŸããŠãã
- äžå®èŠçŽ ããªã
# äžæµå·¥çšã«ãããæé
ã¹ã±ãžã¥ãŒã«å šäœã®ïŒå²ããïŒå²
# ã³ã³ã¹ãã©ã¯ã·ã§ã³ã®éèŠãªæ±ºæ
# èšèª
- 䜿ãæ £ããèšèªã ãšçç£æ§ãé«ãŸã
- é«çŽèšèªã®çç£æ§ã¯äœçŽèšèªã® 5 ãã 15 å
- èããèœåã¯èšè(â ããã°ã©ãã³ã°èšèª)ãç¥ã£ãŠãããã©ããã§æ±ºãŸã
# èšèš
# èšèšã®é£ãã
èšèšã®é£ããã¯ãèšèšãïŒ
- wicked problem ã§ãããã
- wicked problem ãïŒããã£ãããªåé¡
- ãã£ãŠã¿ãŠåããŠæ°ãã€ãåé¡ãå å ãããŠããããš
- ã«ãŒãºãªããã»ã¹ã§ãããã
- è¯ãæ¹æ³ãšæªãæ¹æ³ã®éãããããã§ãããééãããã
- ã©ãã ãããã°ååãããããªããããããã®ã¯ãæéããªããªã£ããã
- 劥åãšåªå é äœä»ãã®ç£ç©ã§ãããã
- å¶éãã€ããã®ã§ãããã
- é決å®è«çã§ãããã
- ç¡éã«ããæ¹ããã
- ãã¥ãŒãªã¹ãã£ãã¯ãªããã»ã¹ã§ãããã
- çºèŠçãè©Šè¡é¯èª€ç
- è©ŠããŠã¿ãªããšããããªã
- åµçºçã§ãããã
- åžžã«åãç¶ããã¬ãã¥ãŒã話ãåããçµéšãéããŠæ¹åãããŠãããã®
# éèŠãªèšèšæŠå¿µ
# éåïŒè€éããžã®å¯Ÿå¿
- essential(æ¬è³ªç)åé¡ãš accidentalïŒå¶çºçã»ä»éçïŒåé¡
- ãªãè€éããžã®å¯Ÿå¿ãå¿
èŠãïŒ
- 人éã®é ã¯ããã°ã©ã å šäœãç解ããããšã¯ã§ããªããã
- è€éãªåé¡ã åçŽãªåé¡ã«åå²ãã ããšãå¿ èŠ
- æ¹é
- äžåºŠã«å¯ŸåŠããªããã°ãªããªãæ¬è³ªçãªè€éããæå°éã«æãã
- å¶çºçãªè€éããå¿ èŠä»¥äžã«å¢ãããªã
# é«å質ãªèšèšãšã¯
- æå°éã®è€éããåã£ãèšèšã«ãããª
- ä¿å®æ§
- ççµå
- æ¡åŒµæ§
- åå©çšæ§
- é«ããã¡ã³ã€ã³
- ããã¯ã©ã¹ããä»ã®ããããã®ã¯ã©ã¹ã§äœ¿ãããŠãã
- äœããã¡ã³ã¢ãŠã
- 1 ã€ã®ã¯ã©ã¹ã䜿çšããä»ã®ã¯ã©ã¹ãå°ãªã
- 移æ€æ§
- ç¡é§ããªãã足ããã®ããªãåããã®ããªã
- éå±€å
- æ±ãã³ãŒããèŠãã€ã³ã¿ãŒãã§ãŒã¹å±€ãè¿œå ããããªã©
- æšæºå
- ç¬èªã®ãã¬ãŒã ã¯ãŒã¯ãã€ãããããäžè¬çãªãã¶ã€ã³ãã¿ãŒã³ãæ¡çšããããªã©
# èšèšã®ã¬ãã«
- Lv1 ãœãããŠã§ã¢
- Lv2 ãµãã·ã¹ãã ã»ããã±ãŒãž
- Lv3 ã¯ã©ã¹
- Lv4 ã«ãŒãã³
- Lv5 ã«ãŒãã³å éš
# Lv1 ãœãããŠã§ã¢
ã·ã¹ãã å šäœã®ããšã
# Lv2 ãµãã·ã¹ãã ã»ããã±ãŒãžã«åå²
- 倧ããªåäœã§ã·ã¹ãã ãåå²ããããããããµãã·ã¹ãã ã®åãæ¹ïŒ
- æ¥åã«ãŒã«ãæºæ³åŸŽåé¡ã®èšç®ããªã©
- ãŠãŒã¶ãŒã€ã³ã¿ãŒãã§ãŒã¹ãç»é¢æå
- DB ã¢ã¯ã»ã¹
- ã·ã¹ãã ãžã®äŸåéšåã windows çšã³ãŒããMac çšã³ãŒããªã©
- ãµãã·ã¹ãã éã®ããåããå¯èœãªéãå°ãªããã => è€éããžã®å¯ŸåŠ
- ãã¹ãããµãã·ã¹ãã ãå¥ã®ãµãã·ã¹ãã ã®ã«ãŒãã³ãåŒã¶
- ãŸããŸãããµãã·ã¹ãã ãå¥ã®ãµãã·ã¹ãã ã®ã¯ã©ã¹ãå«ã
- ã ãããµãã·ã¹ãã ãå¥ã®ãµãã·ã¹ãã ã®ã¯ã©ã¹ãç¶æ¿ãã
# Lv3 ã¯ã©ã¹ã«åå²
- ããã±ãŒãžå ã§ãæ©èœãã¯ã©ã¹ã«åå²ããã¯ã©ã¹ãèšèšãã
- ã¯ã©ã¹ã®ã€ã³ã¿ãŒãã§ãŒã¹ïŒãããªãã¯ãªã«ãŒãã³ïŒãæ€èšãã
# Lv4 ã«ãŒãã³ã«åå²
- åã¯ã©ã¹ãã«ãŒãã³ïŒãã©ã€ããŒããªã«ãŒãã³ãå«ãïŒã«åå²ããã«ãŒãã³ãèšèšãã
- ãã®ã¬ãã«ã§æ€èšããçµæãLv3 ã«æ»ã£ãŠã€ã³ã¿ãŒãã§ãŒã¹ãå€æŽããã®ãã¢ãª
- æ åœãšã³ãžãã¢ã®é ã®äžã§è¡ãããããšãå€ã
# Lv5 ã«ãŒãã³ã®å éšèšèš
- ã«ãŒãã³ã®èšèšãè¡ã
- æ åœãšã³ãžãã¢ã®é ã®äžã§è¡ãããããšãå€ã
# æ§æèŠçŽ ã®èšèšïŒãã¥ãŒãªã¹ãã£ã¯ã¹
èšèšã«ã¯ãå¿ ãæ£ããçããããããã§ã¯ãªããåžžã«çºèŠçã»è©Šè¡é¯èª€çã§ããã ãã®ãããå®ç§ã§ã¯ãªããã®ã®ãæŠãè¯ãçããåºãã§ãããæ¹æ³ïŒâ çµéšåïŒãã§èšèšã¯è¡ãããã ãã®æ¹æ³ã®ããšããã¥ãŒãªã¹ãã£ã¯ã¹ãšåŒã¶ã
以äžãããã€ãã®ãã¥ãŒãªã¹ãã£ã¯ã¹ã説æããã
# çŸå®ã®äžçããªããžã§ã¯ãã«ãã
- å±æ§ã決ãã
- ã¡ãœããã決ãã
- å å«ãç¶æ¿ã®é¢ä¿ã決ãã
- å±æ§ã»ã¡ãœããã®ãããªãã¯ã»ãã©ã€ããŒãã®å¥ã決ãã
# äžè²«ããæœè±¡åãè¡ã
- æœè±¡åãšã¯ã詳现ã«ãã ãããæŠå¿µã ããè¡šãããš
- è€éãªéšåãç¡èŠããŠç°¡åã«ããããšã§ãé ã®äžã§æŽçã§ããããã«ãã
- 人éã¯ãéåãæ±ãå Žåã¯å¿
ãæœè±¡åãè¡ã
- ãã¬ã©ã¹ã»æšã»éã®çµã¿åãããïŒã家ããªã©
- æœè±¡åã®ã¬ãã«ãæããããš
- ã«ãŒãã³ã®ã€ã³ã¿ãŒãã§ãŒã¹ãïŒããã¢ãã
- ã¯ã©ã¹ã®ã€ã³ã¿ãŒãã§ãŒã¹ãïŒããã¢
- ããã±ãŒãžã®ã€ã³ã¿ãŒãã§ãŒã¹ãïŒã家
- 極端ã«çŽ°ãããã or 倧ããããåäœã§æœè±¡åããªããé ã®äžã§äžåºŠã«ç解ã§ããªãããã
- æšã®ç¹ç¶ãéã®ååã¬ãã«
# å®è£ ã®è©³çŽ°ãã«ãã»ã«åãã
- ã«ãã»ã«åïŒè€éãªè©³çŽ°ããé ã
- æœè±¡åïŒè€éãªè©³çŽ°ããåçŽã«èŠãã
# ç¶æ¿ãã
å¯èœãã€æé©ãªå Žåã¯ãç¶æ¿ã䜿ããšè¯ãã 掟é£ç€Ÿå¡ãšæ£ç€Ÿå¡ã¯ãã©ã¡ããã瀟å¡ãã®å±æ§ãšæ¯ãèããç¶æ¿ã§ããã (掟é£ç€Ÿå¡ 'is-a' 瀟å¡ãæ£ç€Ÿå¡ 'is-a' 瀟å¡)
# ç§å¯ãé èœãã
é èœã¯ã䟡å€ãæçœã«å®èšŒãããé·ãã«æž¡ã£ãŠãã®äŸ¡å€ã倱ããªããæ°å°ãªãçè«çææ³ã®äžã€ã 以äžã®ãããªæ å ±ã¯é èœããå€éšã«ã¯ã€ã³ã¿ãŒãã§ãŒã¹ã®ã¿ãæäŸããããšã äœãé èœãã¹ãããåžžã«æèãããããžã§ã¯ãå šäœã«æ å ±ãã°ããŸããªãããšã
- å€æŽãããå¯èœæ§ã®é«ãé åã®ã³ãŒã
- ãã·ã³åºæã®ã³ãŒã
- åã®å®è£ ã®è©³çŽ°ïŒint ã§ã¯ãªããŠãŒã¶å®çŸ©åã䜿ãããªã©ïŒ
ããããããšã§ä»¥äžã®ã¡ãªãããæã
- å€æŽæã« 1 ç®æå€ããã°ããïŒã³ã¹ããæãããã
- é ã®äžã§ 1 床ã«æŽçãã¹ãäºé ãå°ãªããªãããšã§ããè€éããžã®å¯ŸåŠããè¡ãããšãã§ãã
# å€æŽã®å¯èœæ§ãé«ãé åãç¹å®ãã
å€æŽãããããªéšåã¯ãç¬ç«ããã¯ã©ã¹ã«ããŠãããäžè¬çã«å€æŽãããããé åã¯ä»¥äžã®éãã
- æ¥åã«ãŒã«
- ããã¯ããŒãã«é§ååã«ããŠãããšãªããã
- ããŒããŠã§ã¢ã«äŸåããéšå
- å ¥åºåã€ã³ã¿ãŒãã§ã€ã¹ïŒãã¡ã€ã«ã®ãã©ãŒããããªã©ïŒ
- èšèšãå®è£ ã®é£åºŠãé«ãéšå
- ããã°ã©ã ã®ç¶æ
å€æ°
- ããŒã«åã§ã¯ãªãåæåã«ãã
- ã¢ã¯ã»ã¹ã«ãŒãã³ãä»ããŠå©çšãã
- ããŒã¿ãµã€ãºã®å¶çŽ
# ççµåã«ãã
ççµåã®å€æåºæº
- æ°
- ãããªãã¯ã¡ãœããã®æ°ã¯å°ãªã
- åŒæ°ã®æ°ã¯å°ãªã
- å¯èŠæ§
- ããŒã¿ã¯åŒæ°ãšããŠæ瀺çã«æž¡ã
- ããããã°ããŒãã«ããŒã¿ãèŠã«è¡ã£ããããã®ã¯ Ã
- æè»æ§
- ã©ããªå Žé¢ã§ã䜿ããããããš
çµåã®çš®é¡
- åçŽããŒã¿ãã©ã¡ãŒã¿çµå
- ã¢ãžã¥ãŒã«éããããªããã£ããªåŒæ°ã®ã¿ã§ãããšã
- ãªããžã§ã¯ããã©ã¡ãŒã¿çµå
- ã¢ãžã¥ãŒã«éãããªããžã§ã¯ãïŒãšããããã¯ã©ã¹ã€ã³ã¹ã¿ã³ã¹ãªã©ïŒãåŒæ°ãšããŠãããšã
- 1 ããã¯å¯çµå
- åçŽãªããžã§ã¯ãçµå
- ã¢ãžã¥ãŒã«ãšããã®äžã§ã€ã³ã¹ã¿ã³ã¹åããããªããžã§ã¯ãã®é¢ä¿ã®ããš
- ã»ãã³ãã£ãã¯çµå
- çžæã¢ãžã¥ãŒã«ã®å éšã®ä»çµã¿ãæã«æšå¯ããŠãäœããè¡ãããš
- 極ããŠå±éºã§ããã£ãããªåé¡ãèµ·ããã®ã§ã䜿ããª
# ãã¶ã€ã³ãã¿ãŒã³ã䜿ã
pattern | desc |
---|---|
Abstract Factory | ïŒ |
Adapter | ã¯ã©ã¹ã®ã€ã³ã¿ãŒãã§ãŒã¹ãå¥ã®ã€ã³ã¿ãŒãã§ãŒã¹ã«å€æãã |
Bridge | ã€ã³ã¿ãŒãã§ãŒã¹ãšå®è£ ãå¥åã«å€æŽã§ããããã«ãã |
Composite | ãªããžã§ã¯ãã«ãªããžã§ã¯ããå å«ããã |
Decorator | åçã«æ©èœãè¿œå ãããæ©èœããšã«ãµãã¯ã©ã¹ãäœããªãã |
Facade | äžè²«ããã€ã³ã¿ãŒãã§ãŒã¹ãæäŸãã |
Factory Method | ãµãã¯ã©ã¹ã§ã€ã³ã¹ã¿ã³ã¹ãäœã |
Iterator | èŠçŽ ã«é 次ã¢ã¯ã»ã¹ããæ¹æ³ãæäŸãã |
Observer | è€æ°ã®ãªããžã§ã¯ãã«å€æŽãç¥ããã |
Singleton | ã€ã³ã¹ã¿ã³ã¹ã 1 ã€ããæããªã |
Strategy | ã¢ã«ãŽãªãºã ãããã€ãçšæãã |
Template Method | ïŒ |
ã«ã¹ã¿ã ãªããæ¹ããããå¯èœãªéããã¶ã€ã³ãã¿ãŒã³ãã€ããããšã
- ãã¶ã€ã³ãã¿ãŒã³ã䜿ãã°ç°¡åã«æå³ãä»è
ãšå
±æã§ãã
- ããäžäœã¬ãã«ã®è©±ã«å°å¿µã§ãã
- è»èŒªã®åçºæãé²ãã
- åé¡ã«ã¯ãåé¡ãè€æ°å解決ããŠã¿ãªããšããããªãéšåããã
- æ¢åã®ãœãªã¥ãŒã·ã§ã³ã»ã©ã€ãããã¯ããããçµéšããå æããŠãã
泚æç¹
- ãã¿ãŒã³ã¯çµ¶å¯Ÿã§ã¯ãªããæšæºãã¿ãŒã³ã« 100ïŒ ç¡çã«åãããªããŠãããã
- ãããŸã§æ段ã§ããããã¿ãŒã³ãè©ŠããŠã¿ãããšããçç±ã ãã§äœ¿ããªã
# ãã®ä»ã®ãã¥ãŒãªã¹ãã£ã¯ã¹
- åé床ã匷ããã
- éå±€åãã
- ã¯ã©ã¹èŠçŽïŒäºåæ¡ä»¶ã»äºåŸæ¡ä»¶ãªã©ïŒã決ããŠãã
- 責任ãå²ãåœãŠã
- ãã¹ãããããèšèšã«ãã
- ãã€ã³ãã£ã³ã°ã¿ã€ã ãæèçã«éžæãã
- å¶åŸ¡ãäžå åããïŒå¯èœãªéã 1 ç®æã«éããïŒ
- ç·åœããæ³ããã«ã«ãããªãå Žåã«ãã£ãŠã¯æé©ã§ãã
- å³ãæžããŠã¿ã
- ã«ãŒãã³ãã¯ã©ã¹ãããã©ãã¯ããã¯ã¹ãã«ä»ç«ãŠãèšèšãã¢ãžã¥ãŒã«åãããç°¡åã«ãã
# èšèšã®ãã©ã¯ãã£ã¹
èšèšã§å¿ãããã»ããè¯ãæé
# å埩
- äœåºŠãèšèšããŠã¿ããã»ãŒå¿ ãã2 åç®ä»¥éã®ã»ããããŸãããã
- äžæµã»äžæµãè¡ã£ããæ¥ããããããšã§ã倧ããªæ¹åãåŸãããïŒé ãåãæ¿ããã®ãèŸããã©é 匵ãïŒ
# åå²æ»ç¥
- 人éã®é è³ã¯å€§ãããªããè€éãªåé¡ã¯ãæ§ã ãªåéã«åãã1 ã€ãã€è§£æ±ºããããšã
- è¡ãè©°ãŸã£ããããã®åéã§ãå埩ãããããš
# ãããããŠã³
- æ±çšçãªåé¡ïŒå€§ããªã¯ã©ã¹ïŒããå§ããŠããããæ±ãããã倧ããã«å解ããŠãããåå²æŠè¡ã§ãã
- é è³ãåŠçã§ããæ å ±ã«ã¯éãããããšããåæã«ãã£ãŠããã
- å解ãããããã³ãŒãã£ã³ã°ããã»ããç°¡åã«æãããŸã§ãå解ãç¶ãã
- é·æ
- 人ã¯å€§ããªãã®ãå°ããå解ããã®ãåŸæãªã®ã§ãç°¡å
- ã³ã³ã¹ãã©ã¯ã·ã§ã³ã®è©³çŽ°ãå éãã«ã§ãããé èœã§ãã
- çæ
- äžäœã¬ãã«ã«ç§»ãã«ã€ããŠè€éããå¢å€§ããŠè¡ãè©°ãŸãããšããã
# ããã ã¢ãã
- æ±ãããã倧ããããåããŠãå šäœçãªãœãªã¥ãŒã·ã§ã³ãçµã¿ç«ãŠãŠãããçµã¿ç«ãŠæŠè¡ã§ãã
- å šäœãæŒ ç¶ãšããŠããŠãã©ãããæãä»ããŠããã®ãããããªãæã«æé©
- æ¹æ³
- ã·ã¹ãã ãäœãããã®ããèãã
- å ·è±¡(concrete)ã¯ã©ã¹ãšæ©èœãæŽãåºãã
- ã°ã«ãŒãåïŒãµãã·ã¹ãã ã»ããã±ãŒãžã«ããããªããžã§ã¯ãã«ãããç¶æ¿ãããªã©ïŒããŠã
- 1 ã€äžã®ã¬ãã«ã«é²ã
- é·æ
- æ©ã段éã§å¿ èŠãªæ©èœãåããã®ã§ãã³ã³ãã¯ãã§å ç¢ãªã³ãŒãã«ãªã
- çæ
- å°ãããã®ãã倧ããªãã®ãçµã¿ç«ãŠãŠããã®ã¯ãé£ãã
- äžäœã¬ãã«ã«ç§»ã£ããšãã«ããæ°ã¥ããªãééãããã
# å®éšçãããã¿ã€ã
ããã£ãŠã¿ãªããšããããªããåé¡ã解æ¶ããããã«è¡ãã äžèšã®æ¡ä»¶ã®ããšã§è¡ãã
- ãšã³ãžãã¢ããå¿ èŠæå°éã®ã³ãŒããæžãèšç·ŽãåããŠãã
- èšèšã®åé¡ãååã«æ確ã§ãã
- ã³ãŒãã¯å¿ ã䜿ãæšãŠã«ããã補åã³ãŒãã«æµçšããªãã
# ã³ã©ããã
- 2 人ã§èãã
- 1 人ããããªãå Žåã¯ãäžé±éæŸçœ®ããŠããèãã
- 第äžè ã«æèŠãèããŠã¿ã
# ã©ãã ãèšèšããã°ååã
å Žåã«ãããè¿·ã£ãããå°ãå€ãã«èšèšã«æéã䜿ãã
- é£ãããšæããŠããã®ã§èšèšãé 匵ã£ãåéã§ãåé¡ã¯èµ·ãããªãäºãå€ãã
- ç°¡åã ãšæããŠããã®ã§èšèšã軜èŠããåéã§ãåé¡ãèŠã€ããäºãå€ãã
# èšèšäœæ¥ã®ææžå
å ¬åŒãªææžã«ãã以å€ã®æ¹æ³
- ã³ãŒãã«çŽæ¥æ¿å ¥ãã
- wiki ã«ãã
- ã¡ãŒã«ãã
- ããžã«ã¡ã§ãã¯ã€ãããŒããæ®ã
- ããªãããã£ãŒãã«ãã
- CRC ã«ãŒãã䜿ã
- UML å³ãäœã
# ãŸãšã
äžèšã¯æããã«ééãã§ãã
- å šãŠã®è©³çŽ°ãã²ãšã€æ®ããèšèšããããšïŒããããïŒ
- äœãèšèšããªãããšïŒãããªãããïŒ
以äžã®æ°æã¡ãå¿ããã«
- èšèšãèŠåŸããè¡çºã ãšæããªïŒçŽç²äž»çŸ©è ã¯ç¡èŠããŠããïŒ
- èšèšã¯ããã£ããã§ãã«ãŒãºã§ããã¥ãŒãªã¹ãã£ãã¯ãªãã®ã§ãããšèªèãã
- æåã«æãã€ããèšèšã§æºè¶³ãããª
- 第äžè ãšååãã
- åçŽãã«ãã ãã
- å¿ èŠãããã°ãããã¿ã€ããäœã
- å埩ãå埩ãå埩
# ã¯ã©ã¹ã®äœæ
# Abstract Data Types: ADT
- ADT=ããŒã¿ãšãã®ããŒã¿ã«äœçšããæäœããŸãšãããã®ã
- ã¯ã©ã¹=ADT+ç¶æ¿+ããªã¢ãŒãã£ãºã
# ADT ã䜿ãã¡ãªãã
- è€éãªç§å¯ïŒã¡ã³ãããŒã¿ãå®è£ ã®è©³çŽ°ïŒãæã¡ãããããæœè±¡åãããã€ã³ã¿ãŒãã§ãŒã¹ããã®ã¿æäœãã
- æœè±¡åãããŠããã®ã§ãããããããã²ãšç®ã§ããã
currentFont.attribute = 0x02
ãããcurrentFont.setBoldOn()
- å€æŽã«ãã圱é¿ãåã¶ç¯å²ãå°ãããªã
# ADT ã䜿ãæã®ã¬ã€ãã©ã€ã³
- äžäœã¬ãã«ã®ããŒã¿åããäžäœã¬ãã«ã«æœè±¡åããïŒçŸå®äžçã®åé¡ãšããŠæ±ãïŒ
- à ãã¹ã¿ãã¯ããªã¹ãããã¥ãŒ
- â ã瀟å¡ãè«æ±æžæ§ã
- åçŽãªé
ç®ã§ã ADT ãšããŠæ±ãã°èªã¿ããããªã
light.on()
,light.off()
# è¯ãã€ã³ã¿ãŒãã§ãŒã¹
è¯ãã€ã³ã¿ãŒãã§ãŒã¹ã¯ãè¯ãæœè±¡åãšãè¯ãã«ãã»ã«åããæãã
# è¯ãæœè±¡å
- æœè±¡åã®ã¬ãã«ãæãã
- äŸïŒç€Ÿå¡ãšãããã€ã¬ãã«ãªæœè±¡åãšããªã¹ããšããäžäœã¬ãã«ã®æœè±¡åãæ··åš
addEmployee()
RemoveEmployee()
firstItem()
->firstEmployee()
ã§ããã¹ãlastItem()
->lastEmployee()
ã§ããã¹ã
- ã€ã³ã¿ãŒãã§ãŒã¹ã¯å¯Ÿã§æäŸããããšãå€ã
- on - off
- add - remove ãªã©
- é¢ä¿ã®ãªãæ å ±ã¯å¥ã®ã¯ã©ã¹ãžåé¢ãã
- ã€ã³ã¿ãŒãã§ãŒã¹ã®å€æŽã»è¿œå æã«ã«ãŒã«ãéžè±ããªããã泚æãã
# è¯ãã«ãã»ã«å
- ã«ãã»ã«å
- ãå®è£ ã®è©³çŽ°ãé ããŠããŸãããšã
- å ·äœçã«ã¯ãå€éšããã®ã¡ã³ãã«ãŒãã³ãžã®ã¢ã¯ã»ã¹ãæå°éã«ããããã¡ããã¡ã³ãããŒã¿ã¯éå ¬éã«ããã
- ã«ãã»ã«åã®ãæå³çãªéåãã«æ³šæãã
- ãã©ã€ããŒããªå®è£ ãæèããŠã¯ãªããªãããããŸã§ãããªãã¯ãªã€ã³ã¿ãŒãã§ãŒã¹ã®ã¿ã«äŸåããããšã
- ã¯ã©ã¹ã䜿ãæã«å éšå®è£ ã調ã¹ãªããã°ãªããªããšããããããã¯æœè±¡åã«å€±æãããã¡ã¯ã©ã¹ã§ãã
# èšèšãšå®è£ ã®åé¡
# å å«(has a)
- ã¯ã©ã¹ãã¡ã³ãããŒã¿ãä¿æããŠããããšããããšã
- 瀟å¡ïŒclassïŒ has a:
- åå
- é»è©±çªå·
- 瀟äŒä¿éºçªå·
- 瀟å¡ïŒclassïŒ has a:
- ã¯ã©ã¹ã®ã¡ã³ãããŒã¿ã 7 åãè¶ ããããããããã¯ã©ã¹ãå解ããããšãæ€èšãããšãã
- ãã©ã€ããŒãç¶æ¿ã䜿ã£ãŠ'has a'ãå®çŸãããªã芪ãšåã®çµå床ãé«ããªããããã«ãã»ã«åã«éåããããã
- ãã©ã€ããŒãç¶æ¿ãšã¯ã芪㮠protected ãªã¡ã³ãããŒã¿ãåã«ç¶æ¿ããããšã§ã
has a
ãå®çŸããããšã is a
ã®é¢ä¿ã§ã¢ããªã³ã°ãããå Žåãé€ããéåžžã¯ç¶æ¿ãããå å«ã®ã»ããæãŸããã
# ç¶æ¿(is a)
- åãã芪ã®ãç¹åãããããŒãžã§ã³ã§ã¯ãããã®ã®ãåºæ¬çã«åäžã§ããããšããããšã
- åã¯ã芪ã®ã€ã³ã¿ãŒãã§ãŒã¹ã« å®å šã« åŸããåŸããªããšããããå®è£ ãæ£ãããªãã
- ç¶æ¿ã¯å±éºãªãã¯ããã¯ã§ãããç¶æ¿ãããªãããã¡ããšèšèšãšããã¥ã¡ã³ãã£ã³ã°ãè¡ããã§ããªããªããã®ã¯ã©ã¹ã®ç¶æ¿èªäœãçŠæ¢ããããšã
- Liskov substitution principle(LSP)ã«åŸã
- 芪ã§å®çŸ©ãããå šãŠã®ã«ãŒãã³ã¯ãåã§ãå šãåãæå³ãæã€ããš
- åã®çš®é¡ã«ãã£ãŠæå³ãç°ãªããšããããè€éããå¢ãã ãã§å®³ããç¡ããã
- 芪ã®ãªãŒããŒã©ã€ãäžå¯èœ(private)ãªã«ãŒãã³ãšåãååãåã§äœ¿ããª
- å ±éã®ã€ã³ã¿ãŒãã§ãŒã¹ãããŒã¿ãæ¯ãèãã¯ãå¯èœãªéãç¶æ¿ã®äžäœã«ç§»åãã
- ã€ã³ã¹ã¿ã³ã¹ã 1 ã€ãããªãã¯ã©ã¹ã¯æ¶ã(ããã)
- 掟çã¯ã©ã¹ã 1 ã€ããç¡ãåºåºã¯ã©ã¹ã¯æ¶ã
- ã«ãŒãã³ããªãŒããŒã©ã€ãããŠããã®ã«äžèº«ã空ã®ã«ãŒãã³ãèŠããã芪ã®èšèšãèŠçŽã
- åã®çš®é¡ã¯ 7 ã€ãŸã§ãé局㯠3 ã€ãŸã§ã«ãšã©ãã
- ããããã®æ¡ä»¶åå²ãåºçŸããããããªã¢ãŒãã£ãºã ã®æŽ»çšãæ€èšãã
- å€éç¶æ¿ã¯ãmixin ã®ããã«äœ¿ããšããæèã§ãäŸãã°ã
Displayable
ãšSortable
ãšããã€ã³ã¿ãŒãã§ãŒã¹ãå®è£ ãããªã©ã
# å å«ãšç¶æ¿ã®äœ¿ãåã
- è€æ°ã®ã¯ã©ã¹ã§ããŒã¿ã®ã¿å ±é â ã¯ã©ã¹ãäœæããè€æ°ã®ã¯ã©ã¹ã§å å«ãã
- è€æ°ã®ã¯ã©ã¹ã§ã«ãŒãã³ã®ã¿å ±é â å ±éã®ã«ãŒãã³ãæã€åºåºã¯ã©ã¹ãäœæããè€æ°ã®ã¯ã©ã¹ã§ç¶æ¿ãã
- è€æ°ã®ã¯ã©ã¹ã§ããŒã¿ã»ã«ãŒãã³ãšãå ±é â å ±éã®ããŒã¿ã»ã«ãŒãã³ãæã€åºåºã¯ã©ã¹ãäœæããè€æ°ã®ã¯ã©ã¹ã§ç¶æ¿ãã
# ã¡ã³ãã«ãŒãã³ãšã¡ã³ãããŒã¿
- ã«ãŒãã³ã®æ°ã¯æå°éã«
# ã³ã³ã¹ãã©ã¯ã¿
- å šãŠã®ã¡ã³ãããŒã¿ãåæåãã
- ã·ã£ããŒã³ããŒããã¯ãã£ãŒãã³ããŒãåªå ããŠäœ¿ã
# ã¯ã©ã¹ãäœæããçç±
- çŸå®ãªããžã§ã¯ãïŒè»ãªã©ïŒãã¢ããªã³ã°ãã
- æœè±¡ãªããžã§ã¯ãïŒåè§åœ¢ãªã©ïŒãã¢ããªã³ã°ãã
- æœè±¡åã®åã«ããè€éããç·©åãã
- è€éããåé¢ãããäžç®æçŽãã°ããã
- å®è£ ã®è©³çŽ°ãé èœãã
- å€æŽã«ãã圱é¿ãéå®ãã
- åŒæ°ã®åãæž¡ããæžãã
- è€æ°ã®ã«ãŒãã³éã§åŒæ°ãããåãããŠããå Žåããã®åŒæ°ãã¡ã³ãããŒã¿ã«ãã€ã¯ã©ã¹ãäœãããšãæ€èšãã
- å¶åŸ¡ãäžå åããïŒDB æäœããã¡ã€ã«æäœãããªã³ã¿æäœãªã©ïŒ
- ã³ãŒãã®åå©çšãä¿é²ãã
- é¢é£ããæäœãããã±ãŒãžã«ãŸãšããïŒäžè§é¢æ°ãæååæäœããããæŒç®ãªã©ïŒ
# æãŸãããªãã¯ã©ã¹
- ãŽããã¯ã©ã¹
- ã¡ã³ãããŒã¿ããæããªãã¯ã©ã¹
- ä»ã®ã¯ã©ã¹ã«ç§»è²ã§ããªããæ€èšãã
- ã¡ã³ãã«ãŒãã³ããæããªãã¯ã©ã¹
- ã¯ã©ã¹åãåè©ã«ãªã£ããèŠæ³šæ
- DatabaseInitialization ã StringBuilder ãšãã£ãã¯ã©ã¹ã¯ãä»ã®ã¯ã©ã¹ã®ã¡ã³ããŒã«ãŒãã³ã§ããã¹ã
# é«å質ãªã«ãŒãã³
ã«ãŒãã³ïŒé¢æ°ãã¡ãœãããªã©
# ã«ãŒãã³ãäœæããçç±
- 詳现ã«ã€ããŠèããå¿ èŠããªããããšã§ãè€éããäœæžãã
- äžééšåãããããããæœè±¡åããïŒ
getConvertedName()
ã¿ãããªïŒ - éè€ãæé€ãã
- ã«ãŒãã³(ã¡ãœãã)ãååã«å解ãçãä¿ã€ããšã§ããµãã¯ã©ã¹ã®äœæã楜ã«ãã
- è€éã«ãªããã¡ãªããã€ã³ã¿é¢é£åŠçãå²ãã ããé èœãã
- 移æ€æ§ã®ãªãæ©èœãå²ã ãã移æ€æ§ãåäžããã
- è€éãªè«çè©äŸ¡ïŒtrue or falseïŒãå²ãã ããåçŽã«ãã
- å²ãã ããã³ãŒãã 1 ç®ææ¹åããããšã§ãå šäœã«å¹æãæ³¢åãã
# ãšãŠãçãã«ãŒãã³ã®æ±ã
1 è¡ã ãã®åçŽãªã³ãŒãã§ããå Žåã«ãã£ãŠã¯ã«ãŒãã³ã«ããã»ããè¯ãå Žåãããã
# ã«ãŒãã³ã¬ãã«ã§ã®èšèš
cohesion: åé床ã匷床ãã«ãŒãã³å ã®åŠçãã©ãã ãå¯ã«é¢é£ããŠããããè¡šãã
äžèšã®åé床ããããå ã«èšè¿°ãããã®ã»ã©çæ³çã§ãããååã¯èŠããªããŠããã®ã§å 容ãèŠããããšã
# æ©èœçåé床
æãé«ããçæ³çãªåé床ãã«ãŒãã³ãäžã€ã®æ©èœã ããæäŸããå ŽåãidïŒå
¥åããŒã¿ïŒããååãååŸããgetCustomerName()
ãªã©ã
# æ å ±çïŒé åºçïŒåé床
ã«ãŒãã³ã決ãŸã£ãé åºã§å®è¡ããåŠçã§æ§æãããå Žåãç幎ææ¥ïŒå ¥åããŒã¿ïŒãã幎霢ãèšç®ãããã®å¹Žéœ¢ãããšã«å®å¹ŽãŸã§ã®æéãèšç®ããããªã©ã
ãã®åé床ãèŠã€ãããšãã¯ã2 ã€ã®ã«ãŒãã³ã«åé¢ããããšã
# é£çµ¡çåé床
åãå ¥åããŒã¿ã䜿çšãããã®ã®ãå šãå¥ã®åŠçãè¡ãå Žåãå ±åæžïŒå ¥åããŒã¿ïŒãå°å·ãããã®åŸå ¥åããŒã¿ãåæåããããªã©ã
ãã®åé床ãèŠã€ãããšãã¯ã2 ã€ã®ã«ãŒãã³ã«åé¢ããããšã
# æéçåé床
ã«ãŒãã³ããåãææã«å®è¡ãããã¹ããšããç¹ã§ã®ã¿å
±éããæ©èœãæäŸããå Žåãstartup()
,shutdown()
ãªã©ã
ãããŸã§ãä»ã®ã«ãŒãã³ãåŒã³åºãææ®åœ¹ãšããŠäœ¿ãå Žåã®ã¿äœ¿çšã容èªãããã
# æé çåé床(䜿ããª)
ç»é¢ã«å ¥åããé çªãšäžèŽããããããšãããããªçç±ã§ãäžé£ã®ãŸãšããããæ©èœãæäŸããå Žåã
# è«ççåé床ïŒäœ¿ããªïŒ
åŒæ°ã®ãã©ã°ã«ããåŠçãåå²ãããå Žåãåå²ããããšããç®çã®ããã«ãç¹ã«é¢é£ã®ç¡ãã³ãŒããåéããŠããç¶æ ã
ãã©ã°ã«å¿ã㊠3 çš®é¡ã®åŠçã®ãããããå®è¡ããã®ã§ã¯ãªãã1 ã€ã®åŠçãå®è¡ãã 3 çš®é¡ã®ã«ãŒãã³ãäœãã
# æå·çåé床ïŒäœ¿ããªïŒ
ãã¯ãã«ãªã¹ãå éšã®æ©èœã«é¢ä¿æ§ããŸãã§ãªãã«ãŒãã³ã®ããšã
# è¯ãã«ãŒãã³å
ååãã€ãèŸããšæããå Žåã¯ãã«ãŒãã³ã®åé床ãäœããªããçãããšã
- å šãŠã® åºåãšå¯æ¬¡å¹æ ãååã«å«ãã
- perform, output, process, deal ãªã©ãæå³ããªã or ãããŸããªåè©ã䜿ããªãã
- åãªãæ°åã䜿ããªã
outputUser1
outputUser2
ãªã©
- å€å°é·ããŠãæå³ãç解ããã®ã«å¿ èŠãªé·ãã«ãããå€æ°åããã¯é·ããªããã¡ã
- æ»ãå€ãè¡šã
printer.isReady()
customerId.Next()
pen.CurrentColor()
ãªã©
- æ©èœçåé床ã§ããã°ããªããžã§ã¯ããæäœããããšãå€ãã®ã§ã åè©ïŒãªããžã§ã¯ãå ã®åœ¢ã«ãã
PrintDocument()
checkOrderInfo()
ãªã©- ãã ããªããžã§ã¯ãæåã®å Žåã¯ãªããžã§ã¯ãåã¯å«ããã
document.Print()
,orderInfo.Check()
ãªã©ã«ãã
- æ£ç¢ºãªåæèªã䜿ã
- add/remove
- increment/decrement
- open/close
- begin/end
- insert/delete
- show/hide
- create/destroy
- lock/unlock
- source/target
- first/last
- min/max
- start/stop
- get/put
- next/prev
- up/down
- get/set
- old/new
# ã«ãŒãã³ã®é·ã
é·ããšãšã©ãŒãå€ããªãããã§ã¯ãªããã®ã®ãç®å®ã¯ 200 è¡ãŸã§
# ã«ãŒãã³ã®åŒæ°ã®äœ¿çš
ã«ãŒãã³éã®å€ã®ããåãã®ãšã©ãŒã¯ããšã©ãŒå šäœã® 4 å²ãå ãã
- åŒæ°ã®é åºã¯ããå
¥åãããã®ãå€æŽãããã®ãåºåãããã®ãã®é ã«äžŠã¹ã
- ããããåºå¥ã§ãããããªååãã€ãããšãªãè¯ã
- ç¹ã«ãç¶æ ãåŒã³åºãå ã«äŒããããåŒã³åºãå ã«ãšã©ãŒãéç¥ãããããªåŒæ°ã¯ãäžçªæåŸã«ããããš
- è€æ°ã®ã«ãŒãã³ã§äŒŒããããªåŒæ°ã䜿ããšãã¯ããªãã¹ãé åºãçµ±äžãã
- 䜿çšããªãåŒæ°ã¯åé€ãã
- åŒæ°ãå€æŽããªãããšãããŒã«ã«å€æ°ã䜿ãã
- åŒæ°ã«èŠä»¶ãããå Žåã¯æèšãã
- åŒæ°ããå ¥åãããã®ãå€æŽãããã®ãåºåãããã®ãã®ã©ãã«è©²åœããã
- æ°å€ã®åäœ
- æåŸ ãããå€ã®ç¯å²
- æåŸ ããŠããªãå€ããªã©
- åŒæ°ã¯æ倧 7 åãŸã§
# é¢æ°ãšããã·ãŒãžã£
# 䜿ãåã
é¢æ°ãšã¯ãå€ãè¿ãã«ãŒãã³ã®ããš
id := customerID()
ããã·ãŒãžã£ãšã¯ãå€ãè¿ããªãã«ãŒãã³ã®ããš
var report MyReport
var success boolean
formatReport(&report, &success)
if success == true { doSomething() }
- ã«ãŒãã³ã®äž»ãªç®çããé¢æ°åã瀺ãå€ãè¿ãããšã§ãããªããé¢æ°ã䜿ãããš
- ãã以å€ã®å Žåã¯ãããã·ãŒãžã£ã䜿ãããš
# æ»ãå€ã®èšå®
- èããããå
šãŠã®
return
ã®ãã¹ãæèããŠããããšãæ»ãå€ãé¢æ°ã®å é ã§èŠå®å€ã«åæåããŠãããšããã
# é²åŸ¡çããã°ã©ãã³ã°
- Defensive Programming = åé¡ãèµ·ããããšãåæãšããäºã察çããŠããããš
- å€ãããŠããã¡ã ããå°ãªãããŠããã¡
# ç¡å¹ãªå ¥åãžã®é²åŸ¡
- å€éšãœãŒã¹ããã®ããŒã¿ã®å€ã確èªãã
- å ¥ååŒæ°ã®å€ã確èªãã
- äžæ£ãªå ¥åãåŠçããæ¹éã決å®ãã
# ã¢ãµãŒã·ã§ã³
äžæ£ãªå€ããªããã確èªãããšã©ãŒãããã°å€§å£°ã§ã¢ãµãŒãïŒäž»åŒµïŒããããšã
- å ¥ååŒæ°ã®å€ãæåŸ ç¯å²å ã
- ãã¡ã€ã«ããã¡ããšéãããããã¡ã€ã«ã®äœçœ®ãå é ã«ããã
- ãã€ã³ã¿ã null ã§ãªããããªã©
# ã¢ãµãŒã·ã§ã³äœ¿çšã®ã¬ã€ãã©ã€ã³
- ãšã©ãŒãšã¢ãµãŒã·ã§ã³ã®äœ¿ãåã
- çºçãããééãã«ã¯ãšã©ãŒã䜿ã
- çºçããŠã¯ãªããªãç¶æ³ã«ã¯ã¢ãµãŒã·ã§ã³ã䜿ã
- äºåæ¡ä»¶ãšäºåŸæ¡ä»¶ã®ææžåãšæ€èšŒã«äœ¿ã
# ãšã©ãŒåŠçãã¯ããã¯
çºçãããééãïŒãšã©ãŒïŒãçºçããå Žåã«ãã©ã®ããã«å¯ŸåŠããŠç¶è¡ããã
- å€ãä¿®æ£ããŠåŠçãç¶è¡ãã
- åœããéãã®ãªãå€ã䜿ãããŒãå€ãããã©ã«ãå€ãªã©ã
- 次ã®æå¹ãªããŒã¿ã§ä»£çšãããããäžåããŒã¿ãååŸããŠã¿ããªã©ã
- ååãšåãå€ã䜿ã
- æãè¿ãæå¹ãªå€ã䜿ã
- ãã°ã«èŠåãæ®ããŠãåŠçãç¶ç¶ããïŒå¿ èŠã«å¿ããŠä»ã®æ¡ãšçµã¿åãããïŒ
- ãšã©ãŒãã¹ããŒããŠã芪ã察åŠããŠãããã®ãæåŸ ãã
- ã°ããŒãã«ãªãšã©ãŒåŠçã®ä»çµã¿ãäœããããã«ä»»ãã
- ãšã©ãŒãçºçããå Žæã§ãšã©ãŒã衚瀺ãã
- ããŒã«ã«ãªç¯å²ã§ãäžçªè¯ããšæãããæ¹æ³ã§åŠçããŠããŸã
- åŠçãäžæ¢ãã
# æ£åœæ§ãšå ç¢æ§
- æ£åœæ§ïŒããŒã¿ãæ£ç¢ºã§ããããš
- å ç¢æ§ïŒãœãããŠã§ã¢ã®å®è¡ãæ¢ãŸããªãããš
- æ£åœæ§ãšå ç¢æ§ã¯èåãããã³ã³ã·ã¥ãŒãã¢ããªã§ã¯å ç¢æ§ãéèŠãããäºãå€ãã
# äŸå€
äŸå€ã®ã¹ããŒïŒéåºïŒã¯ããã©ã察åŠããããããããããªãã誰ã察åŠæ¹æ³ãç¥ããªãïŒããšå«ã¶ãããªãã®ãäžäœã®ã«ãŒãã³ãäŸå€ãè£è¶³ããŠå¯ŸåŠããã®ãåºæ¬ã®æµãã§ããã
- äŸå€ã¯ãç¡èŠãã¹ãã§ãªããšã©ãŒã«äœ¿ãã
- äŸå€ã¯ãä»ã®ïŒå€ãã®å Žåãäžäœã®ïŒããã°ã©ã ã«äŒéããããã«ã€ããã
- 絶察ã«çºçããŠã¯ãªããªãã€ãã³ãã§äœ¿çšããïŒã¢ãµãŒã·ã§ã³ãšåãïŒ
- ããŒã«ã«ã§åŠçã§ãããšã©ãŒãäŸå€ã«ãããª
- ã³ã³ã¹ãã©ã¯ã¿ã»ãã¹ãã©ã¯ã¿å ã«äŸå€ãæžããªïŒãªãœãŒã¹ãªãŒã¯ã®åå ã«ãªãïŒ
- æœè±¡åã¬ãã«ãæããïŒEmployee ã¯ã©ã¹ãªããEOFException ã§ã¯ãªããEnployeeDataNotFound ã«ããããªã©ïŒ
- äŸå€ã¡ãã»ãŒãžã«ã¯å¿ èŠãªæ å ±ãå šãŠçã蟌ã
- 空ã®ãã£ãããããã¯ã¯æžããªã
- 䜿çšããã©ã€ãã©ãªãã¹ããŒããäŸå€ãç¥ã£ãŠãã
- ãã°ã®èšé²ãäŸå€ã®å ±åãäžå 管çããä»çµã¿ãäœãã®ããã
# ããªã±ãŒãã«ãããšã©ãŒè¢«å®³ã®å²ã蟌ã¿
- å€éšããŒã¿ã¯æ±ããŠããã®ã§ãããªã±ãŒãã§æ¶æ¯ããå éšããŒã¿ãå®å šã«ä¿ã€ããšããèãæ¹
- å ¥åããŒã¿ã¯ãå¯èœãªéãæ©ã段éã§æ£ããåã«å€æãã
- ããªã±ãŒãã®å€åŽã«ã¯ããšã©ãŒåŠçã䜿çšããïŒããŒã¿ã®ãšã©ãŒãèµ·ããããïŒ
- ããªã±ãŒãã®å åŽã«ã¯ãã¢ãµãŒã·ã§ã³ã䜿çšããïŒããã°ã©ã ã®ãšã©ãŒããããããªãïŒ
# ãããã°ãšã€ã
ãããã¯ãè£å©ããã³ãŒããä»çµã¿ã®ããšã
# ãããã¯ã·ã§ã³ç°å¢ã®å¶çŽãéçºæã«ã¯ç¡èŠãã
éçºãã¹ã ãŒãºã«é²ããããã«ãéçºç°å¢ã«éã£ãŠããªãœãŒã¹ã倧éã«äœ¿ããå®è¡ãé ããªãåŠçãå ¥ãããã»ãã¥ãªãã£ãç¡èŠãããããªã©ãè¡ãããšãæ€èšããã
# æ©æå°å ¥
ãããã°ãšã€ãã®å°å ¥ã¯æ©ããã°æ©ãã»ã©ãã
# æ»æçããã°ã©ãã³ã°ã®äœ¿çš
éçºæ®µéã§ç©æ¥µçã«å€±æãåŒãèµ·ãããããã°ã©ã ãäžæããŠããŸãããšã§ãåé¡ãæŽãåºããšä¿®æ£ãä¿ãããšã
- ã¢ãµãŒã·ã§ã³ã§ããã°ã©ã ãäžæ¢ããŠèŠçã䌎ãããåé¡ãä¿®æ£ããã
- case æã® default å¥ã§ç倧ã«èŠåãåºããŠå€±æããããªã©
# ãããã°ãšã€ãã®åé€æ¹æ³
make
ãªã©ãããŒãžã§ã³ç®¡çããŒã«ã§è¡ãdefine
ãªã©ãçµã¿èŸŒã¿ã®ããªããã»ããµãå©çšãã- ç¬èªã®ããªããã»ããµãäœæãã
- ãããã°ãšã€ãïŒã«ãŒãã³ïŒãã補åçã§ã¯ã¹ã¿ãã«å·®ãæ¿ããããªã©
# 補åã³ãŒãã«é²åŸ¡çããã°ã©ãã³ã°ãã©ããããæ®ãã
- éèŠãªãšã©ãŒãæ€æ»ããã³ãŒãã¯æ®ã
- éèŠãªãšã©ãŒãçºçãããšãã¯ãããã°ã©ã ãäžåã«ã¯ã©ãã·ã¥ããã
- äºçŽ°ãªãšã©ãŒãæ€æ»ããã³ãŒãã¯åé€ããããŸãã¯ããšã©ãŒãèšé²ããã«çãããªã©ããç®ç«ããªãããã
- å¯èœãªéããããã°ã©ã ãäžæãããããªã³ãŒãã¯æ§ããïŒãŠãŒã¶ããŒã¿ã倱ããªãããã«ïŒ
- ãšã©ãŒã¡ãã»ãŒãžãåºãå Žåã¯ããŠãŒã¶ã«ããããããèšèã«ããããš
# å€æ°ã®äœ¿çš
# å€æ°å®£èšã»åæåã®ãã¹ããã©ã¯ãã£ã¹
- æé»ã®å®£èšã¯ç¡å¹ã«ãããã¹ãŠã®å€æ°ãæ瀺çã«å®£èšãã
- 宣èšã¯äœ¿çšå Žæã®è¿ãã§è¡ã
- 宣èšæã«åæåãè¡ããé£ããå Žåã¯ãªãã¹ã䜿çšå Žæã®è¿ãã§è¡ã
- ã§ããã ã final / const ã䜿ã
- ã«ãŠã³ã¿çãååæåã®å¿ èŠããªãã確èªãã
# ã¹ã³ãŒã
- ã¹ã³ãŒã = å€æ°ã®ç¥å床
- æç¶éé = å€æ°ãå©çšããç®æã®éé
- å¯¿åœ = å€æ°ã宣èšããå ŽæãããæåŸã«å©çšããå ŽæãŸã§ã®è·é¢
ã¹ã³ãŒããæå°éã«ããããšã§äžèšã®å¹æããã
- äžåºŠã«èŠããå¿ èŠã®ããæ å ±ãæžããèªã¿ããããªã
- ãšã©ãŒãå ¥ãããäœå°ãæžã
- ãªãã¡ã¯ã¿ãªã³ã°ãããããªã
# ã¹ã³ãŒããå°ããããæ¹æ³
- é¢é£ããã¹ããŒãã¡ã³ãããŸãšããããããã¯å¥ã«ãŒãã³ã«åãåºã
// Bad
show(OldData);
show(newData);
delete oldData;
delete newData;
// Good
show(OldData);
delete oldData;
show(newData);
delete newData;
- ã¯ããã¯æãçãã¹ã³ãŒãïŒprivate ãªã©ïŒã«ããŠãã
# æ°žç¶æ§
å€æ°ã®æ°žç¶æ§ïŒè³å³æéïŒãåéããããšäºæ ãèµ·ããã察çã¯æ¬¡ã®éãã
- éèŠãªå€æ°ã«æ£ããå€ãã»ãããããŠãããå®æçã«ç¢ºèªããŠãäžæ£ãªãèŠåãåºã
- 䜿ãçµããå€æ°ã«æå³ã®ãªãå€ãèšå®ããŠãã
- ããŒã¿ãæ°žç¶çã§ãªãããšãåæã«ã³ãŒããæžãïŒå€æ°ã¯ãã¹ãŠäœ¿çšçŽåã«å®£èšãããããã§ãªãå€æ°ã«ã¯èŠæããããªã©ïŒ
# ãã€ã³ãã£ã³ã°ã¿ã€ã
å€æ°ã«å€ãèšå®ããææã®ããšãæ°åã倧ããã»ã©æè»æ§ãé«ãããè€éã§ãšã©ãŒãèµ·ããããããªãçžåé¢ä¿ã«ãããããé©åœãªãšããã§æãåããã€ããã
- ããŒãã³ãŒãã£ã³ã°
- å®æ°ã§ã³ãŒãã£ã³ã°(ããŒãã³ãŒãã£ã³ã°ããã¯åžžã«ãã·)
- ããã°ã©ã ã®ããŒãæã«ç°å¢å€æ°ãªã©ããèªã¿èŸŒã
- ã€ã³ã¹ã¿ã³ã¹çææïŒãŠã£ã³ããŠäœææãªã©ïŒ
- ãžã£ã¹ãã€ã³ã¿ã€ã ïŒãŠã£ã³ããŠç§»åæãªã©ïŒ
# 1 ã€ã®ç®çã« 1 ã€ã®å€æ°
- å€æ°ãåå©çšããªã
- äŸãã°
temp
ãåãã¹ã³ãŒãã§ãéãç®çã§å䜿ããªãããšããããªã£ãå Žåã¯ãããå ·äœç㪠2 ã€ã®ååã«ã€ãçŽãããšã
- äŸãã°
- å€æ°ã« 2 ã€ã®æå³ãé ããæå³ãæãããªãïŒãã€ããªããçµåããªãïŒ
- äŸãã°ãéåžžã¯äººå£ïŒIntegerïŒãè¡šããã-1 ã®å Žåã¯ãšã©ãŒ(Boolean)ã瀺ãå€æ°ãªã©ã
# å€æ°åã®å
å€æ°å以å€ã«ããã¯ã©ã¹ãããã±ãŒãžããã¡ã€ã«ãªã©ã«ãé©çšå¯èœã
# è¯ãååã«ããããã® Tips
# ååã¯ãªãã¹ãå ·äœçã«ãã
ãªã«ãè¡šãå€æ°ãªã®ãèããå¿ èŠããªãçšåºŠã®å ·äœçãªååã«ããã
- Good
- runningTotal
- trainVelocity
- currentDate
- linesPerPage
- Bad
- ct
- velt
- x
- lpp
- lines
- date
# åé¡ãè¡šãååã«ãã
- Good
- employeeData
- printerReady
- Bad
- inputRecord
- bitFlag
# æé©ãªé·ãã«ãã
8 æåïœ 20 æåããããæããããã°ãããããšããç 究ããã
- é·ãã =>
numberOfPeopleOnTheUsOlympicTeam
- çãã =>
n
- ã¡ããã©ãã =>
numTeamMembers
# åèšã»å¹³åã»æ倧ãªã©ãè¡šãååã¯å€æ°åã®æåŸã«ã€ãã
Total
, Sum
, Average
, Max
, Min
, Record
, String
, Pointer
ãªã©ãèšç®ããå€ãä¿æããå€æ°ã«ã¯ããã®ä¿®é£ŸåãæåŸã«ã€ããã
äŸïŒ
- revenueTotal
- expenceAverage
- expenceMax
ãã ããnum
ã¯äŸå€ãªã®ã§èŠæ³šæ
numCustomers
=> 顧客ç·æ°ïŒ's'ã«æ³šç®ïŒcustomerNum
=> 顧客çªå·
å¯èœã§ããã°num
ã¯äœ¿ããã«äžèšã®ããã«ããã»ããè¯ãã
customerTotal
=> 顧客ç·æ°customerIndex
=> 顧客çªå·
# ããããããåæèªã䜿ã
- begin / end
- first / last
- locked / unlocked
- min / max
- next / previous
- old / new
- opened / closed
- visible / invisible
- source / target
- source / destination
- up / down
# ç¹æ®ãªããŒã¿ã®åœå
# ã«ãŒãå€æ°
ããåçŽã§ããã¹ãããããã«ãŒãã 3 è¡ä»¥å
ã§ãã«ãŒãã®å
éšã§ã®ã¿äœ¿çšãããã€ã³ããã¯ã¹ã«ã¯ãi
,j
,k
ãšãã£ãååã䜿ã£ãŠãè¯ãããã以å€ã®å Žåã¯ãéåžžãšåãããããå
·äœçãªååãã€ããã
# ç¶æ å€æ°
ããããããã©ã°ãã®ããšãæå³ã®ããååãã€ãããå¿ èŠã«å¿ããŠå®æ°ã䜿ãã
# BAD
flag = 0x1;
statusFlag = 0x80;
pringFlag = 16;
# GOOD
dataReady = true;
reportType = REPORT_TYPE_ANNUAL;
recalcNeeded = false;
# äžæå€æ°
temp
ãx
ãªã©ã®ããšãããããå
šãŠã®å€æ°ã¯äžæçãªãã®ã§ãããtemp
ãšããååãã€ããããªã£ããšãã¯ãããã°ã©ããåé¡ãç解ã§ããŠããªãå¯èœæ§ããããããå
·äœçãªååãã€ããããªãããããæ€èšããããšã
# ããŒã«å€æ°
- æåã©ããã䜿ã
- done
- error
- found
- success / ok
- true or false ã«ãªãååãã€ãã
- status => statusOK
- sourceFile => sourceFileAvailable / sourceFileFound
- é ã«
is
ãã€ãããšæ£ããååãç¯æ£ãããããããèªã¿ã«ãã - è¯å®çãªååã䜿ã
- notFound => found
- notDone => done
- notSuccessful => successful
# åæå
Color_Red
, Color_Blue
ã®ããã«ãã«ããŽãªãè¡šããã¬ãã£ãã¯ã¹ãä»ãã
# åœåèŠåã®å
# åœåèŠåãäœãçç±
ã©ã®ãããªèŠçŽã§ãç¡ãããã¯ãŸã
- èããªããŠæžã
- èŠããã«ãŒã«ãä»ã§æŽ»ããã
- æ©ãç解ã§ãã
- ååã®å¢æ®ãé²ã
- ããã°ã©ãã³ã°èšèªã®åŒ±ç¹ãè£ã
# ãã€åœåèŠåãå¿ èŠã
- è€æ°ã®ããã°ã©ãããã
- 誰ãã«åŒãç¶ãããšããã
- ãããžã§ã¯ãã倧ãã
- ãããžã§ã¯ããé·ãããªã©ã®å Žå
# ã©ããããæ£åŒã«ããã
çå°ãããžã§ã¯ãã§ã¯ããããé·å€§ãããžã§ã¯ãã§ã¯ãã€ã
# çããŠèªã¿ãããåå
ç¡çã«çç¥ããã®ã¯æã®ãªããã§ãããããã§ãçç¥ããããªããã¬ã€ãã©ã€ã³ããŸãšããŠãããžã§ã¯ãå ã«åšç¥ããŠããããšã
# ã¬ã€ãã©ã€ã³
å€æ°ã 8 æåïœ 20 æåçšåºŠã«ãªããŸã§äžèšã®äœæ¥ãç¹°ãè¿ã
- æšæºçãªç¥èšã䜿ã
- æ¯é³ãåé€ãã
- computer => cmpter
- screen => scrn
- and, or, the ãªã©ãåé€ãã
- '-ing', '-ed'ãªã©ãåé€ãã
- ååã®äžã§éèŠãªåèªãæ倧㧠3 ã€äœ¿çšãã
- çç¥ãããªã 2 æå以äžçç¥ãã
- å€æ°ã®æå³ãå€ããªãããã«æ³šæãã
# çç¥ãããšãã®æ³šæ
- çç¥æ³ã¯äžè²«ãã
- çºé³ã§ããååã«ãã(xPos -> good, xPstn -> bad)
- èªã¿ééããªã©ãæãååãé¿ãã(bEnd -> good, bend -> bad)
- æžãæãããèªã¿æã倧äºã«ãããèªã¿æã«åªãããªãçç¥æ³ã¯äœ¿ããªã
# ãã¡ãªåå
- æå³ã䌌ãååãããã€ã䜿ããª
input
/inputValue
recordNum
/numRecord
- èŠåãã«ããååã䜿ããª
- bad =>
clientRecs
/clientReps
- good =>
clientRecords
/clientReports
- bad =>
- ååã«æ°åã䜿ããª
- 綎ããåæã«å€ããªã
- bad =>
hilite
- good =>
highlight
- bad =>
- 綎ããééããããåèªã䜿ããªã
absence
accumulate
receipt
# åºæ¬çãªããŒã¿å
# æ°å€å šè¬
- 0 ãš 1 ã ãã¯å¿ èŠã«å¿ããŠããŒãã³ãŒãã£ã³ã°ããŠããã0 ã¯ã«ãŠã³ã¿ã®åæå€ã1 ã¯ã€ã³ã¯ãªã¡ã³ããªã©ã«äœ¿ãã
- ãã以å€ã®æ°å€ïŒããžãã¯ãã³ããŒïŒã¯äœ¿ããªãååä»ãå®æ°ã䜿ã
- 0 é€ç®ãèµ·ããªããã泚æãã
- åå€æã¯æ瀺çã«è¡ã
- ç°ãªãåãïŒæé»çå€æã§ïŒæ¯èŒããªãããš
# æŽæ°
- é€ç®ã«æ³šæãããçµæã¯èšèªã«ããç°ãªã(7/10===0 ãªã©)
- æ¡ããµãã«æ³šæããïŒäžéçµæãæçµçµæã©ã¡ããïŒ
# æµ®åå°æ°ç¹
- 倧ããã極端ã«ç°ãªãæ°ã®å æžç®ã¯ãããª
- æ¡ã足ããªããªããçµæãäžæ£ç¢ºã«ãªããã
- ããè¡ãå Žåã¯ãæ°ããœãŒãããŠãã絶察å€ã®å°ããé ã«è¶³ããŠãããšãæã誀差ã¯å°ãããªã
- ç䟡ãæ¯èŒããªã
- åãå€ã«ãªãã¯ãã® 2 ã€ã®èšç®çµæããéãå€ã«ãªãããšã¯ãã°ãã°çºçãããã
- ããæ¯èŒãããå Žåã¯ãããçšåºŠã®èª€å·®ã蚱容ãããæ¯èŒã®ããã®ã«ãŒãã³ãäœæããããš
- äžžã誀差ã«å¯ŸåŠããã«ã¯
- 粟床ã®é«ãæ¹ã«å€æããïŒå粟床 â å粟床ïŒ
- BCD(Binary Coded Decimal)ã«å€æãã
- æŽæ°ã«å€æããïŒãã«ãªãã105 ã 1 ãã« 5 ã»ã³ããšããŠç®¡çãããªã©ïŒ
- äžžã誀差ã«ææãªãå°çšã®åã䜿ã£ãŠããèšèªã«çšæãããŠããªãã確èªãã
# æåãšæåå
- ããžãã¯ãã£ã©ã¯ã¿(
'a'
ãªã©)ã»ããžãã¯ã¹ããªã³ã°ïŒ"Great Title"
ãªã©ïŒã䜿ããªãååä»ãå®æ°ã䜿ã - off-by-one ãšã©ãŒã«æ³šæããïŒæååæ°ãè¶ ããèªã¿åããªã©ïŒ
- Unicode ã䜿ã
- éçºåœåãã i18n ã®æŠç¥ãç·Žã
- C èšèªã«ããã諞泚æã¯çç¥ãæ¬æžåç §
# ããŒã«å€æ°
- 説æå€æ°ãšããŠäœ¿ãããšã§ãè©äŸ¡ãåçŽã«ããããŸããããã°ã©ã ã ã³ãŒãã§ææžå ãã
reachedToLastLevel = level === maxLevel
# åæå
- ã³ãŒããèªã¿ãããããããã«äœ¿ã
// bad
result = getData(data, true, false, false);
// good
result = getData(
data,
EmploymentStatus_CurrentEmployee,
PayrollType_Salaried,
SavingsPlan_NoDeduction,
);
- ä¿¡é Œæ§ãé«ããããã«äœ¿ãïŒããããªãå€ãã³ã³ãã€ã«æã«ãã§ãã¯ïŒ
- ä¿å®æ§ãé«ããããã«äœ¿ãïŒå®éã®å€ãå€æŽãããšã㯠1 ç®æãç·šéããã° OKïŒ
- ããŒã«å€ã®ä»£ããã«äœ¿ãïŒtrue ïŒ 2 çš®é¡ã® false ãªã©ïŒ
- if/case ã§äœ¿ãå Žåã¯ãæåŸã«ç¡å¹ãªå€ãæ€æ»ããã®ãå¿ããã«
- å®éã«äœ¿çšããèŠçŽ 以å€ã®ãå¶åŸ¡çšèŠçŽ ã䜿ã
- åæã®æåãšæåŸã®èŠçŽ ãã«ãŒãæã«äœ¿çšãã
- æåã®èŠçŽ ã«ç¡å¹ãªå€ãèšå®ããããšã§ãæªåæåã®å€ãæ€åºãã
enum Color {
Color_InvalidFirst = 0, // æªåæåãæ€åº
Color_First = 1, // ã«ãŒãã®æåã®èŠçŽ ãšããŠäœ¿çš
Color_Red = 1,
Color_Green = 2,
Color_Blue = 3,
Color_Last = 3, // ã«ãŒãã®æåŸã®èŠçŽ ãšããŠäœ¿çš
}
- èšèªã« enum ãååšããªãå Žåã¯ãèªåã§äœãããš
# ååä»ãå®æ°
- åºå®çãªå€ãäžå 管çããŠãå€æ°å®£èšæãã«ãŒãæãªã©ã«äœ¿ãããšã§ãä¿å®æ§ã»å¯èªæ§ãé«ãã
- ããšãå®å
šãããªå Žåã§ãããªãã©ã«ã¯å©çšããªãããšãäŸãã°
12
ã§ã¯ãªãMONTH_IN_YEAR
ã«ãããªã©ã - èšèªã«ååä»ãå®æ°ãååšããªãå Žåã¯ãèªåã§ã€ããããšã
- å¿ ãååä»ãå®æ°ã䜿ãããªãã©ã«ãšæ··åšãããªãããšããŸãããšå±éºã
# é å
- é åã®ç¯å²å€ã«ã¢ã¯ã»ã¹ããªããã泚æãã
- ãªãã¹ããé åããããã»ãããã¹ã¿ãã¯ããã¥ãŒãã䜿ãããš
- é åã®ç«¯ã£ãïŒå é ãæ«ç«¯ïŒã§ã¯ off-by-one ãšã©ãŒã«æ³šæ
- ã€ã³ããã¯ã¹ã«ã¯æå³ã®ããååãã€ããããšã§ã以äžã®åé¡ãžã®å¯ŸåŠã«ãªãã
- å€æ¬¡å
é
åã§ã¯ã€ã³ããã¯ã¹é ã«æ³šæãã
arr[i][j]
ãšarr[j][i]
ãªã© - ãã¹ãããã«ãŒãã§ã¯ã¯ãã¹ããŒã¯ã«æ³šæ
arr[i]
ã®ã€ããã§arr[j]
ãªã©
- å€æ¬¡å
é
åã§ã¯ã€ã³ããã¯ã¹é ã«æ³šæãã
# ãŠãŒã¶ãŒå®çŸ©åïŒåã®ãšã€ãªã¢ã¹ïŒã®äœæ
åãäžå 管çããŠãä¿å®æ§ã»å¯èªæ§ãé«ããïŒååä»ãå®æ°ã®ãåããŒãžã§ã³ïŒ
type Coordinate float64 // ãããå€ããã°å
šäœãå€ãããã
var coord1 Coordinate
var coord2 Coordinate
- çŸå®äžçã®åé¡ãè¡šãååã«ãã
TinyInt
ã§ã¯ãªãAge
ãªã© - åãå€æŽãããå¯èœæ§ãããå Žåã¯å¿ ããŠãŒã¶å®çŸ©åã䜿ãããš
- çµã¿èŸŒã¿åãåå®çŸ©ããªããæ··ä¹±ã®ããšã
# ç¹æ®ãªããŒã¿å
# æ§é äœ
ä»ã®åãåºã«ããŠäœæãããããŒã¿ã®ããšã äžè¬çã«ã¯æ§é äœãããã¯ã©ã¹ã䜿ã£ãã»ãããããã以äžã®ãããªå Žåã§äœ¿ãããã
# ããŒã¿ã®é¢ä¿ãæ確ã«ãã
// bad
age := 18
name := "John"
sarary := 500
height := 180
// good
husband.age := 18
husband.name := "John"
wife.sarary := 500
wife.height := 180
# ããŒã¿ã®åŠçãåçŽåã«ãã
man.name = "John"
man.age = 18
man.sarary = 180
man2 := man // ããããã£ãäžæ¬ããŠè€è£œã§ãã
# åŒæ°ãªã¹ããåçŽåãã
ããããã®åŒæ°ãäžã€ã®æ§é äœã«ãŸãšããããšãã§ããããã ããä¹±çšã«æ³šæããã
# ä¿å®äœæ¥ã軜æžãã
äžç®æãå€æŽããã ãã§å šäœãå€æŽã§ããã
# ãã€ã³ã¿
# ãã€ã³ã¿ãæ§æãããã®
- ã¡ã¢ãªã¢ãã¬ã¹
- å
容ã解éããããã®æ
å ±
- 解éã®æ¹æ³ã¯ãã€ã³ã¿ã®åºåºåã§æ±ºãŸã
- æŽæ°ãã€ã³ã¿ãªãæŽæ°ãšããŠãæååãã€ã³ã¿ãªãæååãšããŠè§£éãã
- ã¡ã¢ãªã¢ãã¬ã¹ãã¹ã¿ãŒãå°ç¹ãšããåºåºåãå¿ èŠãšããé·ãã ãããŒã¿ãèªã¿èŸŒã
# ãã€ã³ã¿ã«é¢ãã泚æç¹
- éåžžã®ãšã©ãŒã¯ãåå ç®æãç¹å®ããã®ã¯ç°¡åã§ãä¿®æ£ãé£ãã
- ãã€ã³ã¿ã®ãšã©ãŒã¯ãåå ç®æãç¹å®ããããšèªäœãé£ãã
ãã®ãããäžèšã®ç¹ã«æ³šæãã
- ãã€ã³ã¿æäœïŒä»¥äžã®ãã¹ãŠã®äœæ¥ïŒã¯ã«ãŒãã³ãã¯ã©ã¹ã«åé¢ãã
- ãã€ã³ã¿ã宣èšããããå¿ ãåæå€ãèšå®ãã
- ãã€ã³ã¿ã®å²åœãŠãšåé€ã¯åãã¹ã³ãŒãã§è¡ã
- ã¯ã©ã¹ã®ã³ã³ã¹ãã©ã¯ã¿ã§å²åœãŠãã¯ã©ã¹ã®ãã¹ãã©ã¯ã¿ã§åé€
- ã«ãŒãã³ã§å²åœãŠãå åŒã«ãŒãã³ã§åé€
- 䜿çšåã«ã¢ãã¬ã¹ãæ€æ»ãããã¢ãã¬ã¹ãæ³å®ç¯å²ãéžè±ããŠããªãã
- 䜿çšåã«å€ãæ€æ»ãããå€ãæ³å®ç¯å²ãéžè±ããŠããªãã
- ããã°ã¿ã°ã䜿ãïŒè©³çŽ°çç¥ïŒ
- ãã€ã³ã¿ã¯ã±ããã䜿ã£ãŠèªã¿ãããã³ãŒããæžã
- å³ãæžããšãããããããªã
- åŸå§æ«ã«æ°ãã€ããïŒè©³çŽ°çç¥ïŒ
- ãªãã¹ããã€ã³ã¿ã䜿ããªããä»ã®æè¡ã䜿ã
# C ã®ãã€ã³ã¿ãC++ã®ãã€ã³ã¿
çç¥
# ã°ããŒãã«ããŒã¿
# åé¡ç¹
- æå³ã«åããŠå€æŽãããŠããäºããã
- ã³ãŒãåå©çšã®åŠšãã«ãªã
- å
šãŠã®ã°ããŒãã«ããŒã¿ãé ã«å
¥ããŠçœ®ããªããã°ãã³ãŒããç解ã§ããªã
- 人éã¯å€§ããªããã°ã©ã ãç解ã§ããªã
- éšåã«åããŠãããããããšã«èããã°æžãããã«ãããããªã
# 䜿ãã¹ãå Žæ
- ã°ããŒãã«ãªå€ã®ä¿åïŒã³ã³ãã£ã°ãªã©ïŒ
- ååä»ãå®æ°ã®ä»£ããã«äœ¿ã
- åæåã®ä»£ããã«äœ¿ã
- ãã©ã³ãããŒã¿ã®åé€ïŒããŒã¿ãã«ãŒãã³ã«æž¡ãç®çããæŽã«å¥ã®ã«ãŒãã³ã«æž¡ãããšã«éããªãããšïŒ
# ãããŸã§æåŸã®æ段
ããã©ãããŠã䜿ãããå Žåã¯ãã¢ã¯ã»ã¹ã«ãŒãã³ã䜿çšããããšïŒè©³çŽ°çç¥ïŒ
# ã¹ãã¬ãŒããªã³ãŒãã®æ§æ
# é åºãéèŠãªã¹ããŒãã¡ã³ã
é åºïŒäŸåæ§ïŒããããæžãæ¹ãããããšã
- ã³ãŒãæ§æãã«ãŒãã³åã§è¡šã
- äŸãã°ãåæåãè¡ãã«ãŒãã³ãªãã
ComputeMarketingExpense
ã§ã¯ãªãInitializeExpenceData
ãªã©
- äŸãã°ãåæåãè¡ãã«ãŒãã³ãªãã
- ã«ãŒãã³ã®åŒæ°ã䜿ã£ãŠè¡šã
# goodïŒé åºã倧äºã§ããããšããããïŒ
data = initialize(data)
data = compute(data)
data = finalize(data)
# bad(é åºã倧äºã§ããããšãããããªã)
computeMarketingExpence()
computeSales()
computeExpence()
- ã³ã¡ã³ãã§èª¬æããïŒæåŸã®æ段ïŒ
# é åºãéèŠã§ãªãã¹ããŒãã¡ã³ã
ã³ãŒããå®è¡é åºã«äŸåããªãå Žåã¯ãé¢é£ããäœæ¥ãã§ããã ãè¿ãã«é 眮ããããšã
# äžããäžãžèªããã³ãŒã
èªãã¹ãå Žæãæ£åšããŠããã³ãŒãã¯æªãã³ãŒãã§ããããªãã¹ãé¢é£ãããã®ãäžç®æã«ãŸãšããããšãå€æ°ã®å¯¿åœãçãããã®ã¯å¹æçã
# é¢é£ããã¹ããŒãã¡ã³ãã®ã°ã«ãŒãå
é¢é£ããã¹ããŒãã¡ã³ããåè§ã§å²ã£ãŠã¿ãŠãåè§åœ¢ã亀é¯ãããªããããŸããŸãšãŸã£ãŠããªããšãããã
# æ¡ä»¶æã®äœ¿çš
# if
# if-then ãæžãå Žåã®æ³šæ
- æ£åžžç³»ã®å®è¡ãã¹ããèªã¿ãããããã«æåã«æžããç°åžžç³»ã®åŠçã«ãã£ãŠèªã¿ã«ãããªãããšããªãããã«ããã
- ç°åžžç³»ã¯ååãšã㊠else æã«æžãã
- else å¥ã¯äžèŠãªå Žåãå€ãã®ã§çã£ãŠãããããš
- off-by-one ãšã©ãŒã«æ³šæããã
<
ãš<=
ã®æžãééããªã©ã
# if-then-else ã®é£éãæžãå Žåã®æ³šæ
- è€éãªæ¡ä»¶åŒã¯ã«ãŒãã³ã«åãåºããŠã«ãã»ã«åããïŒ
isAlphabet()
ãªã©ïŒ - ãã£ãšãäžè¬çãªã±ãŒã¹ãããäžäœã«æžã
- case æã§ä»£çšã§ããªããæ€èšãã
# case
# é çª
äžèšã®äžããäžçªé©åãªãã®ãéžæãã
- ã¢ã«ãã¡ãããé ã»æ°å€é
- æ£åžžç³»ãšç°åžžç³»ã® 2 ã€ãããªãå Žåã¯ãæ£åžžç³»ãå é ã«ãã
- åºçŸé »åºŠé
# ãã®ä»
- åã±ãŒã¹ã®åŠçã¯çãæžããé·ããªããªãã«ãŒãã³ã«åãåºãã
- ç°¡åã«åé¡ã§ããåçŽãªããŒã¿ã«ã®ã¿äœ¿çšãããåé¡äœæ¥ãè€éã«ãªããªã if æã䜿ãã
- default å¥ã§ã¯ããã®ä»ãæ±ãã®ãã®ã ããæ±ãããŸãã¯ããšã©ãŒåŠçãã«äœ¿ã
- fallthrough ã¯äœ¿ããªã䜿ããªããå¿ ãã³ã¡ã³ããæ®ãã
# ã«ãŒã
- ã«ãŒãã¯è€éã§ãããåçŽã«ä¿ã€ããåªåããã
- å€ãã£ãã«ãŒããäœããªã
- ãã¹ããã§ããã ãå°ãªããã
- å ¥å£ã»åºå£ãæ確ã«ãã
- ååŠçã»åŸåŠçãäžç®æã«ãŸãšãã
- ã«ãŒãå€æ°ã«ã¯è¯ãååãã€ãã1 ã€ã®ç®çã§äœ¿ã
- å šãŠã®ã±ãŒã¹ã§æ£åžžã«å®è¡ãããã©ããªæ¡ä»¶ã§ãçµäºããããšãæ€èšŒãã
# ã«ãŒãã®çš®é¡
- ã«ãŠã³ãïŒæ±ºããããæ°ã ã
- é£ç¶è©äŸ¡ïŒã«ãŒãæ¯ã«ã©ããããå€å®
- ãšã³ãã¬ã¹ïŒæ°žé ã«
- ã€ãã¬ãŒã¿ïŒã€ãã¬ãŒã·ã§ã³ãçµãããŸã§
# while-break
while-break
ã䜿ããšãã«ãŒãã®æåãæåŸã§ã¯ãªã éäž ã«åºå£ãããã«ãŒããäœãããšãã§ããã- ãã ããã«ãŒãå éšã®ã³ãŒããèŠãªããšçµäºæ¡ä»¶ãããããªããšãããã¡ãªãããããã
- äžèšã®ããã«ãéè€åŠçãé¿ããããã«äœ¿ããšããã
// bad
doSomething1();
doSomething2();
while (score < 10) {
other();
doSomething1();
doSomething2();
}
// good
while (true) {
doSomething1();
doSomething2();
if (score < 10) break;
other();
}
# for
- åçŽãªåŠçã«ã®ã¿äœ¿çšãã
- ã«ãŒããéäžã§æããããªã©ãå¶åŸ¡ãè€éãªã«ãŒãã«ã¯
while
ã䜿çšãã - ã«ãŒããéäžã§æããããããã«ãã«ãŒãå€æ°ãå€æŽããŠã¯ãªããªã
# foreach
- ã«ãŒããç¹°ãè¿ãããã®èšç®ãäžèŠã§ããããããšã©ãŒã®åå ãæžããã
# ã«ãŒãã®å¶åŸ¡
ã«ãŒãã«é¢ããåé¡ãé²ãããã®ãã¹ãã»ãã©ã¯ãã£ã¹
- ã«ãŒãã«åœ±é¿ããèŠå ãæå°éã«ããïŒåçŽã«ããïŒ
- ã«ãŒãã®å
éšããã©ãã¯ããã¯ã¹ã«ãã
- ã«ãŒãã®å éšãã«ãŒãã³ãšããŠèãã
- å¶åŸ¡ã«é¢ããå€æ°ãªã©ãããªãã¹ãã«ãŒãã®å€ã«åºã
# ã«ãŒãã®éå§
- å ¥ãå£ã¯ 1 ç®æã«ãã
- åæåã³ãŒããã¯ã«ãŒãã®çŽåã«æžãïŒè¿æ¥ã®æ³åïŒ
- for ã®ãããã«ã«ãŒãå¶åŸ¡ã«é¢ä¿ãªãã³ãŒããè©°ã蟌ãŸãªã
# ã«ãŒãæ¬äœ
- æ¬äœã空ã®ã«ãŒãã¯äœããªãæžãçŽã
- ååŠçã»åŸåŠç(
i++
ãªã©)ã¯ãã«ãŒãã®å é ãæ«å°Ÿã«ãŸãšãã - ã«ãŒãå
ã®åŠç㯠1 ã€ã®æ©èœã«çµã
- åäžè²¬ä»»ã®æ³åãã«ãŒãã³ãšåããšèããã
- ãšããããåããŠäœæããããã©ãŒãã³ã¹ã®åé¡ãåºãŠãããŸãšããã㧠OK
# ã«ãŒãã®çµäº
- ã©ããªå Žåã§ãã«ãŒããçµäºããããšã確èªãã
- çµäºæ¡ä»¶ãæ確ã«èšèŒãã
- for ã«ãããŠãã«ãŒãå€æ°ãæžãæããªã
- ã«ãŒãå€æ°ã®æçµå€ã䜿çšãããªãå¿ èŠãªãã«ãŒãå€ã®å€æ°ã«æ瀺çã«å€ãä¿åããŠããã
- å®å šã«ãŠã³ã¿ïŒäžéïŒãé©å®äœ¿çšãã
- while ã«ãŒãã§ã¯ããã©ã°ããã break ã䜿ããšãããã«ãªããããããã ããè€æ°ã® break ã«ã¯èŠæ³šæã
- continue ã¯å é ã§äœ¿ããäžç€ä»¥éã§äœ¿ãå Žåã¯æ¿ããã« if æã䜿ãããšã
- continue, break ã¯æ³šæããŠäœ¿ãïŒçµäºæ¡ä»¶ãç¥ãã«ã¯å éšãèŠãå¿ èŠãããããã©ãã¯ããã¯ã¹ã§ã¯ãªããªã£ãŠããŸãããïŒ
# ã«ãŒãå€æ°ã®äœ¿çš
- ããåçŽãªã«ãŒããé€ããã«ãŒãå€æ°ã«ã¯
i
ãªã©ã®æå³ã®ãªãååã§ã¯ãªããcarNumber
ãªã©æå³ã®ããååãã€ãããç¹ã«ãã¹ãããå Žåã¯ã - ã«ãŒãå€æ°ã¯ãã«ãŒãå ã®ã¿ãã¹ã³ãŒãã«ããïŒã³ã³ãã€ã©ã«é ŒããªãããšïŒ
# ã«ãŒãã®é©åãªé·ã
- æé·ã§ã 1 ç»é¢ã§ç¢ºèªã§ããçšåºŠã®çãã«ãã
- ãã¹ãã¯æ倧ã§ã 3 段éãŸã§
- é·ããªããããå Žåã¯ã«ãŒãã³ã«åãåºã
- é·ãã«ãŒãã§ã¯ãåºå£ãçµäºæ¡ä»¶ãç¹ã«ã·ã³ãã«ã«ããããš
# ã«ãŒãã®äœæ
ã«ãŒãå éšãããå€åŽã«åããŠäœæããŠãããšè¯ã
# ã«ãŒããšé å
é
åãã«ãŒãåŠçããå Žåã¯ãforeach
ãmap
ãç©æ¥µçã«äœ¿çšãããããã«ãããã«ãŒãã«ãŸã€ããæ§ã
ãªåé¡ãæžããããšãã§ããã
# ç¹æ®ãªå¶åŸ¡æ§é
# ã«ãŒãã³ããã®è€æ°ã® return
èªã¿ããããªãå Žåãé€ããreturn ã®äœ¿çšã¯æå°éã«æããã
- ã³ãŒããèªã¿ãããããããã«äœ¿ã
- çããããã£ãæç¹ã§å¶åŸ¡ãåŒã³åºãå ã«æ»ãããšã§ãèªã¿ããããªãå Žåããã
- ã¬ãŒãå¥ã䜿ã£ãŠè€éãªãšã©ãŒåŠçãåçŽåããããã«äœ¿ã
- åææ¡ä»¶ãæºãããŠããªãå Žåãªã©ã¯ãã«ãŒãã³ã®é 㧠return ããããšã§æ·±ããã¹ããé¿ããããšãã§ãã
# ååž°
- åé¡ã®ç¯å²ãçãæã«äœ¿ãã®ãæé©ã§ããã
- å€ãã®å ŽåãåçŽã«ã¹ã¿ãã¯ãšç¹°ãè¿ãæ§é ã䜿ã£ãã»ããç解ããããã
# ãã³ã
- Base Case ãå¿ ãäœã
- å®å šã«ãŠã³ã¿ãäœã£ãŠç¡éååž°ãé²ã
- ååž°ã®äžããå¥ã®çš®é¡ã®ååž°ãåŒã°ãªãïŒã«ãŒãã³ã¯ 1 ã€ã«éå®ããïŒ
- ååž°ã䜿ãå¿ èŠã®ãªããã®ã«äœ¿ããªãïŒéä¹ããã£ããããæ°åãªã©ïŒ
# goto
ã»ãŒãã¹ãŠã® goto ã¯ä»ã®å¶åŸ¡æ§é ã«æžãæããããããã»ã©ã®çç±ããªãéã䜿ããªãããšã
# ããŒãã«é§åæ¹åŒ
- è€éãªããžãã¯ïŒif|caseïŒããè€éãªç¶æ¿æ§é ãåçã«ã·ã³ãã«ã«ã§ãã
- ããããŒãã«ããŒã¿ãå€éšã«ä¿åããã°ãã³ãŒããå€æŽããã«ããŒã¿ãä¿®æ£ã§ãã
äŸãã°inputChar
ãšããå€æ°ã®çš®é¡ãå€å®ãããå ŽåãããŒãã«ã䜿ããšãè€éãªif
æã䜿ããã«ããã
charType = charTypeTable[inputChar];
# æ€èšãã¹ãäºé
- åç
§æ¹æ³ãã©ãããã
- çŽæ¥ã¢ã¯ã»ã¹
- ã€ã³ããã¯ã¹ã¢ã¯ã»ã¹
- 段éåã¢ã¯ã»ã¹
- äœãæ ŒçŽããã
- ããŒã¿
- ã«ãŒãã³
# çŽæ¥ã¢ã¯ã»ã¹æ¹åŒ
ç¹å®ã®å€ãããŒãšããŠããŒãã«ã«ã¢ã¯ã»ã¹ããæ¹æ³ãç®çã®èŠçŽ ã«äžçºã§ã¢ã¯ã»ã¹ã§ããã
// æå®ããæã®æ¥æ°ãæ±ãã
daysOfMonth = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
days = getDaysOfMonth(someMonth - 1); // é¢æ°ã§ã¯ãªãåçŽã«Arrayã§å®è£
ããŠãOK
// ä¿éºæçãäºãçšæããè¡šããååŸãã
rate = rateTable(smokingStatus, gender, maritalStatus, age);
# åç §ããŒã®è£æ£
äŸãã°ã幎霢ããããŒã«ãããã®ã®ã18 æ³ä»¥äžã¯å šãŠåãããŒã¿ãè¿ãããå Žåãªã©ã åç §ã«äœ¿ãããŒã¿ããã®ãŸãŸããŒãšããŠäœ¿ããªãããã®ãããªå Žåã¯ã以äžã®æ¹æ³ã§ããŒã®è£æ£ãå¿ èŠã«ãªãã
- ããŒãã«ãè€è£œããæ¹æ³
- 1 ãã 18 æ³ãŸã§ã®ããŒãã«ã«å šãŠåãããŒã¿ãè€è£œããã
- ããŒãå€æããæ¹æ³
- ã«ãŒãã³ã䜿ã
keyFromAge(age)
㧠18 æ³ä»¥äžã®ããŒã 18 ã«å€æ - ããã·ã¥ã䜿ã
keyFromAge[age]
㧠18 æ³ä»¥äžã®ããŒã 18 ã«å€æ
- ã«ãŒãã³ã䜿ã
# ã€ã³ããã¯ã¹ã¢ã¯ã»ã¹æ¹åŒ
åçŽãªæ°å€å€æã§ã¯ãããŒãã«ã®ããŒãååŸã§ããªãå Žåã«äœ¿ãã ïŒå€ãã®ç©ºèŠçŽ ã容èªããïŒã€ã³ããã¯ã¹ãçæããããšã§ãæ£åšããããŒã¿ãäžæãæ±ãããšãã§ããã
äŸïŒ100 çš®é¡ã®ååã 0 ãã 9999 ãŸã§ã®ã©ã³ãã ãªçªå·ã§ç®¡çããŠããå ŽåïŒ
- ã€ã³ããã¯ã¹ããŒãã«
- 10000 åã®é å
- ã»ãšãã©ã¯ç©ºèŠçŽ
- 詳现ããŒã¿ãžã®åç §ãæã€
- 詳现ããŒã¿ãå«ãããŒãã«
- å®åšããååã®ããŒã¿ã®ã¿ä¿æ
äžèšã®ã¡ãªãããæã
- ã¡ã¢ãªæ¶è²»ãæžããã
- äœã³ã¹ãã«æ€çŽ¢ãå¯èœã奜ããªã ãã€ã³ããã¯ã¹ãäœãã
- ä¿å®æ§ãé«ã
# 段éåã¢ã¯ã»ã¹ããŒãã«
ã€ã³ããã¯ã¹ã¢ã¯ã»ã¹æ¹åŒã§ã¯å¯Ÿå¿ã§ããªããäžèŠåãªããŒã¿ããããã®æªãããŒã¿ã«é©ããŠããã ç¹å®ã®å€ã§ã¯ãªããç¯å²ãããŒãšããŠããŒãã«ã«ã¢ã¯ã»ã¹ããã
// ã¹ã³ã¢ãããŒã«å€æãã
func getLevelByScore(score float64) int {
rangeLimits := []float64{50.0, 65.0, 75.0, 90.0, 100.0}
maxLevel := len(rangeLimits) - 1
for level, limit := range rangeLimits {
scoreInRange := score <= limit
reachedToLastLevel := level == maxLevel
if scoreInRange || reachedToLastLevel {
return level
}
}
panic("this can't be happen")
}
func main() {
gradeNamesByLevel := []string{"E", "D", "C", "B", "A"}
fmt.Println(gradeNamesByLevel[getLevelByScore(85.1)]) // => "B"
}
# 泚æç¹
- çµç«¯ã»å¢çã®åŠçãæ£ããã確èªãã
- å¿ èŠã«å¿ããŠããªãã¢ãµãŒãã§ã¯ãªããã€ããªãµãŒãã䜿ã
- ã€ã³ããã¯ã¹ã¢ã¯ã»ã¹æ¹åŒã®å©çšãæ€èšããïŒç¹ã«ã¹ããŒããéèŠãªå ŽåïŒ
- ããŒã®èšç®ã¯ã«ãŒãã³ãšããŠç¬ç«ãããããš
# å¶åŸ¡æ§é ã®åé¡
# è«çåŒ (boolean expression)
å šãŠã®å¶åŸ¡ã¯è«çåŒã䜿ãã
# true or false ã䜿ã£ãŠèªã¿ããã
- è«çåŒã«ã¯
true
orfalse
ã䜿ãã0 ã 1 ã¯äœ¿ããªã - è«çåŒïŒããŒã«å€ïŒã®æ¯èŒã«ã¯ãæé»ã®ç
§åãç©æ¥µçã«äœ¿ãã
done === false
ãããnot done
(a>b) === true
ãããa>b
# è€éãªåŒã¯åçŽåãã
è€éãªåŒã¯åçŽåããããã€ã³ãã¯ãã³ãŒãã§ææžåããããšã
- äžéå€ããè¯ãååã®èª¬æå€æ°ã«ä»£å ¥ããããšã§èªã¿ããããã
- è¯ãååãã€ããããŒã«é¢æ°ãšããŠç¬ç«ããã
- if ã case ã§ã¯ãªã決å®è¡šïŒããŒãã«é§åæ¹åŒïŒã䜿ã
# è¯å®çãªè«çåŒã«ãã
åŠå®æã®ç¹°ãè¿ãã¯éåžžã«ç解ãã«ããã
- if ã®æ¡ä»¶ãåŠå®æïŒ
!statusOK
ïŒã®å Žåã¯ãif å¥ãš else å¥ã亀æãã - ãã»ã¢ã«ã¬ã³ã®å®çãå©çšããŠãè€æ°ã®åŠå®ãåäžã®åŠå®ã«ãŸãšããã
not A or not B
=>not (A and B)
not A and not B
=>not (A or B)
(ããã¯åŸ®åŠãã)
# ã«ãã³ã䜿ã£ãŠæ確åãã
èšç®ã®åªå é ãææ§ãªå Žåã¯ãã«ãã³ã䜿ã£ãŠèªã¿ããããã
# åŒãè©äŸ¡ãããæ¹æ³ãç¥ã£ãŠãã
è©äŸ¡ã®æ¹æ³ã¯èšèªã«ãã£ãŠç°ãªã
A or B
ã«ãããŠãA
ãçãªãB
ã¯è©äŸ¡ããªããšããèšèªãå€ãã- ãã ãããã§ãªãèšèªããããå Žåã«ãã£ãŠã¯ãšã©ãŒãåŒãèµ·ããåå ã«ãªãã
- èªã¿æãæ··ä¹±ãããå¯èœæ§ãããå Žåã¯ããã¹ããããããšã§æå³ãæ確ã«ããŠããããšã(
if(A){ if(B){} }
)
# æ°å€ãå«ãåŒã¯æ°çŽç·ã®é ã«äžŠã¹ã
i > MIN and i < MAX
=> badMIN < i and i < MAX
=> good
# 0 ãšã®æ¯èŒ
0 ã¯è€æ°ã®ç®çã§äœ¿çšããããããç®çã匷調ããããã«ã³ãŒããæžãããšã
- è«çåŒïŒããŒã«å€ïŒã¯æé»ã«æ¯èŒãã
if (!done)
- æ°å€ã¯ 0 ãšæ¯èŒãã
count != 0
- ãã€ã³ã¿ã¯ null ãšæ¯èŒãã
if(bufferPtr)
=> badif(bufferPter == null)
=> good
# æ·±ããã¹ãã®åé¿
äŸãã°ã3 ã¬ãã«ä»¥äžã® if æãç解ã§ãã人ã¯ã»ãŒããªãã
以äžãif æã®æ·±ããã¹ããåé¿ããæ¹æ³ã
- æ©ãã« return å㯠break ããïŒé¢æ°å ãªã©ã«éãïŒ
- if-then-else ã«çœ®ãæããïŒå¹ççãªé çªã§è©äŸ¡ããè©äŸ¡ãç¡é§ã«ç¹°ãè¿ããªãããšïŒ
if (i > 100) {
} else if (i > 10) {
} else {
}
- case ã«çœ®ãæãã
switch (true) {
case i > 100:
break;
case i > 10:
break;
default:
}
- ãã¹ãããã³ãŒããã«ãŒãã³ã«åãåºã
- èšèšãèŠçŽããå€ãã®å ŽåãåçŽã«ç解ã足ããŠããªãã ãã®å Žåãå€ãã
# æ§é åããã°ã©ãã³ã°
- å ¥å£ãäžã€ãåºå£ãäžã€ã®å¶åŸ¡æ§é ã䜿çšãã¹ãããšããèãæ¹ã
- æ§é åãããããã°ã©ã ã¯ãèŠåçãªæ¹æ³ã§ããã°ã©ã ãé²ããäžããäžã«èªãã§ãããã
- ã³ãŒãã®æã詳现ãªã¬ãã«ã®è©±ã§ãããæ§é åããããããããŠã³åœ¢åŒã®èšèšã®ããšã§ã¯ãªãã
# 3 ã€ã®èŠçŽ
æ§é åããã°ã©ãã³ã°ã§ã¯äžèšã® 3 ã€ã®å¶åŸ¡æ§é ã®ã¿ã䜿çšããã
ãã以å€ã®å¶åŸ¡æ§é ïŒbreak
,continue
,return
,throw-catch
,goto
ãªã©ïŒã䜿ãããŠãããæ¹å€çã«èŠãããšã
- é£ç¶ãé çªã«å®è¡ãããã¹ããŒãã¡ã³ãã®éå
- éžæã if ã case ãªã©
- å埩ã for ã while ãªã©
# å¶åŸ¡æ§é ãšè€éã
- å¶åŸ¡æ§é ã®äœ¿ãæ¹ã¯ãããã°ã©ã å šäœã®è€éãã倧ããå·Šå³ããã
- è€éããšã¯
- ã³ãŒããç解ããã®ã«å¿ èŠãªåŽå
- é ã®äžã«äžåºŠã«æŽçããªããã°ãããªãäºæã®æ°
# ã¬ã€ãã©ã€ã³
- è€éãããå€å®ãã€ã³ããã§å®éåãã
if
,while
,for
,and
,or
ããšã« 1 ãšæ°ããcase
ã®éžæè¢ããšã«ã1 ãšæ°ãã- 6 ãè¶ ãããæ¹å€çã«èŠã