ããã°ã©ãã«ãã£ã¦è²ã ãªããã°ã©ãã³ã°ã¹ã¿ã¤ã«ãããã¨æãããã»ã³ã¹ã»ãªãã»ããã°ã©ãã³ã°! æ½è±¡çã«èãããã¨ã»ãã¼ã¿æ§é ãç解ãããã¨ãèªãã§ãããããªããã°ã©ã ãæ¸ãæ¹æ³ã«ã¤ãã¦ã¯å ±éç¹ãããã¨æã£ãã®ã§ãæ¬æ¸ãåèã«ããããªããã°ã©ãã³ã°ã³ã¼ããæ¸ãæ¹æ³ã«ã¤ãã¦ã¾ã¨ããã
ç®æ¬¡
- ç®çãç解ãã
- æ¸ãæã®ãã¨ããããèªãæã®ãã¨ãèãã
- æç´ã§ãèªã¿ããã
- ã¤ã³ãã³ãã¯çµ±ä¸ãã
- ã³ã¡ã³ãã¯ç¡é§ãªã³ã¡ã³ããæ¸ããã½ã¼ã¹ã®æå³ãæ¸ã
- ä¾å¤ã¯ãæ¬å½ã«ä¾å¤çãªå ´åã ãã«ä½¿ã
- ååã®ã¤ãæ¹ãéè¦
- å½åæ³
- çç¥ããªã
- åããã¨ãæ¸ãã¦ã¯ãããªã
- ã³ãããããã
- é¢æ°ã«åå²ãã
- æºä¸ãããã°ã¯æéã®ç¡é§
- è¯ãã³ã¼ãã¨ã³ã¼ãã£ã³ã°ã¬ãã«
ç®çãç解ãã
ä½ããã®ã³ã¼ãã£ã³ã°è¦ç´ã«å¾ã£ã¦ããã°ã©ã ãæ¸ããªãã常ã«ãã®çç±ãç解ãããã¨ãç²ç®çã«è¦ç´ã«å¾ããã¨ã¯ãè¦ç´ãå ¨ããªããã¨ä»¥ä¸ã«å±éºã
ä¾ãã°ããå³å¤ãç´æ¥æ¸ãã¦ã¯ãããªããã¨ããè¦ç´ãå®ã£ã¦ã
a = 10
ãã
CONST10 = 10 a = CONST10
ã¨æ¸ãã¦ãæå³ã¯ãªãã
ãå³å¤ãç´æ¥æ¸ãã¦ã¯ãããªããã¨ããè¦ç´ã¯ã
- ãæ°åã®æå³ãç解ã§ãããã¨ã
- ãå¤æ´ãããæã«ä¸ãæã ãå¤æ´ããã°å ¨ã¦å¤æ´ã§ããã
ã¨ããã¨ããã«æå³ãããã
LIMIT = 10 a = LIMIT
ã®ããã«ãæå³ããããããã«ããå¿
è¦ãããã
ã³ã¼ãã£ã³ã°è¦ç´ã¯ããã¡ãã¨ãã®æå³ãç解ããä¸ã§å®ããªããã°æå³ããªãã
æ¸ãæã®ãã¨ããããèªãæã®ãã¨ãèãã
å¤æ°åã®é·ããã©ãããããã«ã¤ãã¦ä»¥ä¸ã®ï¼ã¤ã®æè¦ãããã- å¤æ°åããã¾ãé·ãããã¨ãã¿ã¤ãããã®ã大å¤ã ããã¿ã¤ããã¹ãå¢ãããããçãã®ååã«ããã®ããã
- å¤æ°åãçããããã¨ããã¨ããããã«ãããªããããçç¥ããªãã§é·ãååã«ããã®ããã
åè
ã¯æ¸ãæã®å©ä¾¿æ§ãå¾è
ã¯èªãæã®å©ä¾¿æ§ãéè¦ãã¦ããã
ããã°ã©ã ã¯ã常ã«èªãæã®ãã¨ãéè¦ãã¦è¨è¿°ãããã¹ãã§ããã
ãªããªããããã°ã©ã ã¯ãå¿
ãä¿å®ããããã¨ã«ãªãããã ãå¤æ°ã¯ãå°ãé·ããªã£ã¦ããããããããéè¦ãã¹ãã§ããã
æç´ã§ãèªã¿ããã
ãã¤ã¦ã¯ãã¿ã¤ãéãå°ãªãããã°ã©ã ã»ã©ãããããã°ã©ã ã¨ãã説ã横è¡ããããããã°ã©ã ãæ¸ããªããã½ã¼ã¹ãçãããã¨ãããã ããªããã¨ã«å´åãããããããããã¨ã®èªã¿ããããåªå ãããã¹ãã§ããããã ãå®ç³ã¯å®ã£ãæ¹ãããã
ããã°ã©ã ãå¤å°ç¸¦ã«é·ããªã£ã¦ããèªã¿ãããããã°ã©ã ãæ¸ããã
ã¤ã³ãã³ãã¯çµ±ä¸ãã
ã¤ã³ãã³ãã¨ã¯ãã½ã¼ã¹ãæ¸ãæã«ãifããªã©ãããããããããããã«ã¤ããåä¸ãã®ãã¨ã- å¤äººæ°ã§éçºãè¡ã£ã¦ããã®ã§ããã°ããã®ããã¸ã§ã¯ãã®ã³ã¼ãã£ã³ã°è¦ç´ã«åãããã
- å人ã§æ¸ãã¦ãããªããä¸éã«åºã使ããã¦ããã¹ã¿ã¤ã«ãé¸ã³ã以å¾ãã£ã¨ããã使ãã
ã³ã¡ã³ãã¯ç¡é§ãªã³ã¡ã³ããæ¸ããã½ã¼ã¹ã®æå³ãæ¸ã
ã³ã¡ã³ãã«ã¤ãã¦ã以ä¸ã®ï¼ã¤ã®å¯¾ç«ããæè¦ãããã- ã³ã¡ã³ãã¯ããã¨ã§ããã°ã©ã ãèªãã¨ãã®å©ãã«ãªãããã大éã«æ¸ãã¹ãã
- ã³ã¡ã³ãã¯ããã¨ã§ããã°ã©ã ãèªãã¨ããéªéã«ãããªããªããããã§ããã ãæ¸ããªãã
å ¥éæ¸ã§ã¯åè ãæ¯æããã¦ããããä¸ã®ä¸ã«åå¨ãã大åã®ã³ã¡ã³ãã¯ç¡é§ã§ãããæ害ã§ããã
@user_id #ã¦ã¼ã¶ID
ã¨æ¸ãã®ã¯ç¡é§ã§ããããªããªãå¤æ°åãè¦ãã°ãããããã ã
ããã¯ã¹ã³ã¡ã³ãããããã°ã©ã å
¨ä½ã®è¦éããæªãããããæ¸ãã®ãé¢åã§ããããã³ã¡ã³ãã®æ¸ãæãå¿ãã«ããåã®ã³ã¡ã³ãã«ãªããã¨ãå¤ã
ããã®ã§ãå¿
è¦æå°éã«æããã¹ãã§ãããããã°ã©ã ã¯ç´ãããã©ãã³ã¡ã³ãã¯ç´ãå¿ããã¨ããã®ã¯ãããã話ã§ããã
éã«ãã³ã¡ã³ãããªãã¦ãèªããããã°ã©ã ãæ¸ãããã«å¿ãããã¹ãã ã
ã³ã¡ã³ããæ¸ãå ´åã¯ãããªããã®ãããªã½ã¼ã¹ãæ¸ããã®ããã¨ããæå³ãããããããªã³ã¡ã³ãã«ãã¹ããæå³ãæ®ãã¦ãããªãã¨å¾ã§ããã°ã©ã ãä¿å®ãã人ãããããªããªãå ´åã«ã¯æ¸ãã¹ãã§ããã
ã½ã¼ã¹ãè¦ãã°æå³ãä¸ç®çç¶ã¨ããã®ãçæ³ã ããã©ããã¦ããã¾ãæ¸ããªãã¨ããå¿
è¦æªã¨ãã¦è£ããã®ã¨ããèªèãæã£ãæ¹ãè¯ãã
â»ããã¥ã¡ã³ãã«æ¸ãå 容ã¯ä»¥ä¸ã®ãããªå½¹å²ãããã
- ããã°ã©ã ã®æ¦å¿µãèãæ¹ã説æãã
- ããã°ã©ã ãæ¬æ¥ã©ãåãã¹ãããå®ç¾©ãããããããã°ã©ã ã®åãã«ã¤ãã¦ãããããã°ãªã®ãä»æ§ãªã®ãã¯ãããã¥ã¡ã³ãã§å®ç¾©ããã¦ããªããã°ãªããªãã
ä¾å¤ã¯ãæ¬å½ã«ä¾å¤çãªå ´åã ãã«ä½¿ã
ä¾å¤å¦çæ©æ§ã¯ä¾¿å©ã ããä¾å¤ã¯ããã°ã©ã ã®æµããå¼·å¼ã«ããã¾ãããããéãéãæ®ããªãã¨ããé¢ããããä¾ãã°ããã¼ã¿ãæ¤ç´¢ããããã°ã©ã ã®å ´åããã¼ã¿ãè¦ã¤ãããªãã£ãã¨ãï¼ä»¶ãè¿ãä»æ§ã«ãªã£ã¦ããã°ãããã°ã©ã ã§ã¯è¦ã¤ãããªãã£ãå ´åãæèããå¿ è¦ã¯ãªãããä¾å¤ãè¿ãããã«ãã¦ããã¨ããã©ã°ãªã©ãå°å ¥ããããã°ã©ã ãæ¸ããããå¾ãªããªã£ã¦ãã¾ãã
ããã¤ã«ä¾å¤ã使ãã¹ãã§ã¯ãªãã
ååã®ã¤ãæ¹ãéè¦
å¤æ°åãé¢æ°åãã¯ã©ã¹åãã¡ã½ããåãªã©ã¯ããã°ã©ã ã®èªã¿ãããã¨ããç¹ã«ããã¦ã極ãã¦éè¦ãªæå³ããã¤ãã¾ããå¤æ°ã«å¤ãªååãã¤ãã人ã¯ãããããå¤æ°ãä½ã表ç¾ãããã®ã§ããã®ããã¯ã£ããæèã§ãã¦ãªããã¨ãå¤ãããããã¯ã£ããæèã§ãã¦ãããªããé©åãªååãä»ããããã¯ãã
å¤æ°åãé¢æ°åãããã«æãæµ®ãã°ãªãå ´åããã£ããæãæ¢ãã¦èªåãä½ããããã¨ãã¦ããã®ããèãç´ããæ¹ãè¯ãã
å½åæ³
- æå³ã®ããååãã¤ãã
flagã¨ãmodeã¨ãã£ãååãå¹³æ°ã§ã¤ããããã©ã³ããã°ã©ããããããä½ã®flagãªã®ããä½ã®modeãªã®ãããããããã«æ¸ãã¹ãã§ããã
- ã¹ã³ã¼ãã®åºããæèãã
ã¹ã³ã¼ãã¨ã¯ãããååããã£ãã¨ãããã®ååãé©ç¨ãããç¯å²ã®ãã¨ãæå³ããã
ãã¼ã«ã«å¤æ°ãã¤ã³ã¹ã¿ã³ã¹å¤æ°ãã°ãã¼ãã«å¤æ°ãªã©ããããã¹ã³ã¼ãã®åºããã®ã»ã©ãå½åã«ã¯æ°ãé£ãå¿
è¦ãããã
ãã¼ã«ã«å¤æ°ãªããpããªã©ã®1æåã®å¤æ°åã使ã£ã¦ããã»ã©åé¡ãªãã
ããããã¹ã³ã¼ããåºãååãç¹ã«ã°ãã¼ãã«å¤æ°ã¯ãååã«é·ãååãã¤ããªããã°æå³ããããªããªããªã£ã¦ãã¾ãã
ã¾ãååã®è¡çªãé¿ããããã«ã¯ãå½åè¦åãè¨ãã¦ãååã«ãã¬ãã£ã¯ã¹ï¼æ¥é è¾ï¼ãã¤ããã
- ä¸è²«æ§ãæããã
ä¾ãã°ä½ããçæããé¢æ°ã®ååã¨ãã¦ã¯ãcreate_xxxãmake_xxxãæ¶ãå ´åã¯destroy_xxxãdelete_xxxãªã©ãèããããããããã°ã©ã å
¨ä½ã§çµ±ä¸ããå¿
è¦ãããã
makeãcreateãæ··ãã£ã¦ããã¨èªã¿ã«ããã
çç¥ããªã
çç¥è¨æ³ãçµ±ä¸çã«éç¨ããã®ã¯æ¥µãã¦é£ãããåºæ¥ãã ãçç¥ããªãããã«ããããã ãããã¼ã«ã«å¤æ°ãªã©ã¹ã³ã¼ãã®ç¯å²ãçããã®ã¯ãååãçãã¦ãå°ããªãã®ã§çç¥è¨æ³ã使ã£ã¦ããã»ã©åé¡ã¯åºãªãã
åããã¨ãæ¸ãã¦ã¯ãããªã
åããã¨ãè¤æ°åæã§æ¸ãã¨ãå¿ ããã¨ã§ã¯ã¾ããçç±ã¯ä»¥ä¸ã®éãã§ããã
- ä¿®æ£ããæã«ã¯ãã¹ã¦ã®åæãç´ããªããã°ãªããªã
ä¿®æ£æ¼ãã§ãã°ãåºãã¦ãã¾ããããã¹ãããªããã°ãªããªãé ç®ãççºçã«å¢ããã
- æåãããã¦ãã¾ãã¨ãæã«è² ããªã
ã³ããããã¦ãã¾ã£ãããã°ã©ã ã¯ããããå¥ã ã«æãå ¥ãããã¦ããããç°ãªã姿ã«ãªã£ã¦ãããããã¨ããã¯ãä¿®æ£ããéãåãä¿®æ£ã両æ¹ã«å ¥ãããã¨ã«ãªãã®ã§å¤§å¤ã
- èªåã§ä½ããããã¨ãã¦ããã®ãããã£ã¦ããªãå¯è½æ§ãé«ã
åãå¦çãè¤æ°åæã«æ¸ããªãããã«ããã«ã¯ããã®é¨åãé¢æ°ã«ãããã ãæ¹æ³ãæå¹ã
ãããããªãã¨ãããã¨ã¯ãé©åãªé¢æ°åãæãã¤ããªãã¨ããé©åãªå¼æ°ãä½ã«ãªãã®ãããããããªããã¨ããå¯è½æ§ãé«ãã
ã³ãããããã
ã³ããããã¨ããã°ã©ã ã®è¡æ°ããã£ã¨ããéã«å¢ãã¦ããããããã«ãããããä»äºãããæ°ã«ãªãããããã¯å¾ã«å¤§å¤ãªå財ãæ®ããã¨ãèªèãã¹ããé¢æ°ã«åå²ãã
ãªãé¢æ°ã«åããã®ãï¼- åããã¨ãè¤æ°ã®åæã«æ¸ããªãããã«ãããã
- é·ãé¢æ°ã¯èªã¿ã«ãããã
- ãã¼ã¿ã®ã¹ã³ã¼ã(æå¹ç¯å²)ãçµãããï¼ãã¼ã«ã«å¤æ°ã®ã¹ã³ã¼ããå°ãããªãããªã©ï¼
- ããã°ã©ã ã®å ¥åºåãæ確ã«ããããï¼ãã¼ã¿ã®æµãããããããããªãï¼
æºä¸ãããã°ã¯æéã®ç¡é§
æºä¸ãããã°ã§ã¯ã¾ããã°ã¯è¦ã¤ãããªãããªããªããããã°ã©ãã¼ã«ã¯ä½ããã®æãè¾¼ã¿ãããããã ãæºä¸ãããã°ã¯æãè¾¼ã¿ãé¤å»ããå½¹å²ãæããã¦ãããªãã
å®éã«åããã¦ã¿ã¦ãã©ããã©ã®ããã«æå³éãã«åãã¦ããªãã®ããæ¤è¨¼ããã®ãä¸çªã
ãã ããããããè¡ãå½ããã°ã£ããã§ããã°ã©ã ãæ¸ãè¨ã訳ãã«ãã¦ã¯ãããªãã
ã¾ããåç¾æ§ã®èããã°ã¯ãæºä¸ãããã°ä»¥å¤ã«è¿½è·¡ã®æ¹æ³ããªãã
è¯ãã³ã¼ãã¨ã³ã¼ãã£ã³ã°ã¬ãã«
[ThinkIT] 第1回:良いコードとは、心得5ヶ条 (1/4)ã«ãè¯ãã³ã¼ãã®å®ç¾©ãã¨ãã³ã¼ãã£ã³ã°ã¬ãã«ããè¨è¿°ããã¦ããã®ã§è¿½è¨ã
å ·ä½ä¾ãªã©ãæ¸ããã¦ãã¦ç´ æ´ãããè¨äºãæè¬ã§ãã
è¯ãã³ã¼ã
- èªã¿ããã
- é©åãªã³ã¡ã³ã
- éããè¦ãç®ããã
- ä¿®æ£åæãããã«åãã
- æ©è½ã®è¿½å ã»åé¤ã楽
- ãã°ãç¡ã
- ã»ãã¥ãªãã£ãèæ ®ããã¦ãã
- ä»æ§ãæºããã¦ãã
- è½ã¡ãªã
ã³ã¼ãã£ã³ã°ã¬ãã«
- ã¬ãã«1
- å¤é¨ä»æ§ãæºãããã¨ãã§ããªãããã°ã©ã
- ã¬ãã«2
- å¤é¨ä»æ§ãæºãããèªã¿ã«ããããã°ã©ã
- ã¬ãã«3
- èªã¿ããããªã£ã¦ããããã³ã¼ããåå²ã§ãã¦ããªãããã°ã©ã
- ã¬ãã«4
- ã³ã¼ãåå²ã§ãã¦ãããããªãã¸ã§ã¯ãæåããã°ã©ãã³ã°ã§ãã¦ããªã
- ã¬ãã«5
- æè»æ§ï¼æ¡å¼µæ§ãé«ãããã°ã©ã
ã¬ãã«ï¼ã®ã³ã¼ããæ¸ããããã«æ¥ã
ç²¾é²ãããã
- ä½è : åæ©åå¼¥
- åºç社/ã¡ã¼ã«ã¼: æè¡è©è«ç¤¾
- çºå£²æ¥: 2004/11/06
- ã¡ãã£ã¢: åè¡æ¬ï¼ã½ããã«ãã¼ï¼
- ã¯ãªãã¯: 35å
- ãã®ååãå«ãããã° (57件) ãè¦ã