TL;DR
æç¶ãåããã°ã©ãã³ã°ã§ã¯æç¶ããæ½è±¡åãããã¨ã§ä¿å®æ§ãæãããã¨ã«æåãããããã¼ã¿ãå®ããã¨ã«ã¯å¤±æãã¦ãã¾ã£ããããã§ãªãã¸ã§ã¯ãæåã¯ãã¼ã¿ã¨æç¶ããã²ã¨ããã¾ãã«ãããã¨ã§ãã¼ã¿ãå¤ããå®ãã¨ããã³ã³ã»ãããæã¡åºããã
ããããããæç¶ãåããã°ã©ãã³ã°ã§æ¸ãã¦ãã®ã«æç¶ããååã«æ½è±¡åããã¦ããªãã®ã¯ã¤ããããã¨ãããªãã¸ã§ã¯ãæåã§æ¸ãã¦ãã®ã«ã²ã¨ããã¾ããããªãéå¤ãªãã¼ã¿ã«é¢å¿ããã£ã¡ãã£ã¦ãã®ã¯ã¤ãããããªã©ã®è¨è¨æéãå°ããã¨ãã§ããã®ã§ãããããã¦ç´ç²é¢æ°åè¨èªã®å ´åã¯â¦â¦ã¨ãã話ã§ãã
ã¯ããã«
ããã°ã©ãã³ã°è¨èªã«ã¯ãããããªãã©ãã¤ã ããããããã®ä¸ã§æç¶ãåããã°ã©ãã³ã°ããªãã¸ã§ã¯ãæåãç´ç²é¢æ°åè¨èªã«ã¤ãã¦ãããããªãã®ã²ã¨ã¤ã®å²è¦³ã示ãã®ããã®ç¨¿ã®ç®çã§ãããã¨ãªãããã£ãã¤ãã¦è¨ã£ã¦ã¿ããã ãã©ãè¦ããã«ãããããã®ãã©ãã¤ã ãã©ããªãã¨ã«å¯¾ãã¦åé¡æèãæã£ã¦ãã¦ãã©ã®ãããªããããã§ãã®åé¡ã解決ãããã¨ãã¦ããã®ãã¨ãããã¨ããããããªãã®è¦ç¹ã§è¿°ã¹ã¦ã¿ãããªãã¨ãã試ã¿ã§ãã
ãªããããªè©¦ã¿ãããã®ã
ãªããªããããããã°ã©ãã³ã°ã®å½¹ã«ç«ã¤ããã§ããããã¯è¨ãåã£ã¦ããã¨æãããã®ãã©ãã¤ã ãã©ã®ãããªåé¡æèãæã£ã¦ãã¦ã©ã®ããã«ããã解決ãããã¨ãã¦ããã®ããç¥ããã¨ã¯ããã®ãã©ãã¤ã ã«ããã¦ã©ã®ããã«ã³ã¼ããè¨è¨ãã¹ããªã®ãã«ç´çµããããããã©ãã¤ã ã以ååå¨ããã©ã®ãããªåé¡ãã©ã®ããã«è§£æ±ºãããã¨ããã®ããã¨ãããã®ãã²ã¨ã¤ã®æ´å²ã¨ãã¦ã¨ãããã²ã¨ã¤ã®å²è¦³ãæã¤ãã¨ã«ãã£ã¦ãªãããã®è¨è¨æéãå°ããã¨ãã§ããã ããã¨ãããããã¿ã§ããããã¡ãããããã¯ãããã®å²è¦³ï¼ç«åå²è¦³ï¼ã§ããããããå¯ä¸ã®æ£è§£ã ã¨è¨ãã¤ããã¯ãªãããå²å®ã¨éããã¨ãè¨ã£ã¦ããããããªãï¼ãã®å ´åã¯ææãã¦ããããã¨ãããããªãï¼ãããããè¨è¨ã«ããããã³ãã«ã¯ãªãããã¨ä¿¡ãã¦ãããã§ã¯å§ã¾ãå§ã¾ãã
æç¶ãåããã°ã©ãã³ã°
ã§ã¯ã¾ãã¯ãæç¶ãåããã°ã©ãã³ã°ã«ã¤ãã¦è¦ã¦ã¿ã¾ãããã
èèã®ãã¨ãå«ããããæç¶ãåãã¨ããè¨èã§ãããæç¶ãã«æ³¨ç®ãããã¨ããã®ã¯æ±ºãã¦æªããã¨ã§ã¯ããã¾ãããæç¶ãã«æ³¨ç®ãã¦ããã°ã©ãã³ã°ãèããã¨ãã«ããä¼¼ããããªæç¶ãã«ã¯ååãã¤ãã¦åå©ç¨ã§ããããã«ãããããã²ã¨ããã¾ãã®æç¶ãã«ååãã¤ãã¦ããããããããããã¨ãªãã®ã¯èªç¶ãªãã¨ã§ããããã§æç¶ãåè¨èªã§ã¯ãé¢æ°(é¢æ°ã¨ããããã¯ããã·ã¸ã£ã¨ããµãã«ã¼ãã³ã£ã¦è¨ã£ãã»ããé©åã§ã¯ï¼ã¨ãããã£ã¨ããªçªã£è¾¼ã¿ã @masaru_b_cl ãããããããã¾ãããsee http://twitter.com/masaru_b_cl/status/424029964984283136 )ãã使ã£ã¦ãä¼¼ããããªæç¶ããã²ã¨ããã¾ãã®æç¶ãã«ååãã¤ãã¦æ½è±¡åãã¾ããè¨ãæ¹ãå¤ããã°ãæç¶ãåããã°ã©ãã³ã°è¨èªã¯ãä¼¼ããããªã²ã¨ããã¾ãã®æç¶ããããããªã¨ããã«æ£ãã°ã£ã¦ããã¨ãããã¨ãåé¡è¦ããããã¯ããã²ã¨ããã¾ãã®å¦çã¨ãã¦åãåºãããã®ããã¿æ¸ãããã¦ãããã¨ããåé¡è¦ãããã²ã¨ã¾ã¨ã¾ãã®æç¶ããã«ååãã¤ãã¦æ½è±¡åãããã¨ã§æç¶ããæ½è±¡åããã®ã§ãã
ãããããæç¶ãåããã°ã©ãã³ã°ã«ç½®ãããè¯ããªãåããã¨ãããã®ãè¦ãã¦ãã¾ãããã¨ãã°ããä¼¼ããããªå¦çãããããªã¨ããã«æ¸ãã¦ãããã£ã¦ãããã¿ã¼ã³ã§ãããä¼¼ããããªå¦çãããããªã¨ããã«ã¡ãã°ã£ã¦æ¸ãã¦ããå ´åããã®å¦çã«ä¿®æ£ãå¿ è¦ã«ãªã£ãå ´åã«ä¿®æ£ç®æãè¨å¤§ã«ãªãããä¼¼ã¦ããã©å¾®å¦ã«éã£ãããããã grep ã§è¦ã¤ããããªãã¿ãããªè©±ã«ãªã£ã¦ãããã£ä¿®æ£æ¼ãï¼ãã¨ãªã£ã¦ã¦ã¼ã¶ã¼ã«ä¾¡å¤ãå±ããã©ããããã°ãå±ãããã¨ã«ãªãã
ããã²ã¨ã¤ã®ãè¯ããªãåããã¯ããä¸é£ã®æç¶ãã¨ãã¦ååãã¤ãããã®ã«ãªããã¨ããå¦çãã¹ãæ¸ãããã¦ããã¨ãããã¿ã¼ã³ã§ããããã¯ä¸é£ã®æç¶ããé¢æ°ã¨ãã¦ãããã ããããã®æç¶ãã«å¿ è¦ãªãã¼ã¿ãã¯å¼æ°ã«æ¸¡ããã¨ã«ãã£ã¦
- é¢æ°ã®å¼ã³åºãå ã¯æç¶ãã®è©³ç´°ãæ°ã«ããªãã¦ãããªãï¼ãããã¾ãã«ãæ½è±¡åã§ãããï¼
- å¤æ°ã®ã¹ã³ã¼ããçããªã£ã¦ããæå³ãããã®å¤ãæ¸ãæãããã¡ãã£ãï¼ãã£ã¦äºæ ãæ¸ã
ããã§ãããã®ãããã®ãæç¶ãã«ååãã¤ãã¦æ½è±¡åãããã¨ãã«ã¤ãã¦ã¯ id:shim0mura æ°ã®åã¨ã³ããªãããã®ã§ãã¡ããåç §ãã¹ãã ã¨æãã
http://d.hatena.ne.jp/shim0mura/20130117/1358436466
æç¶ãåã®éç
ãã¦ãæç¶ãã æ½è±¡å ããããã¨ã§ããããã¡ã¯å°ã幸ãã«ãªãã¾ãããé©åã«æç¶ããæ½è±¡åãããã½ã¼ã¹ã³ã¼ãã¯ããã¾ã¾ã§ãã©ãã©ã¨æ£ãã°ã£ã¦ãããã¾ã¨ããããã¯ãã®ãã¸ãã¯ããããã¹ãå ´æã«ã¾ã¨ãããã¨ã«æåãã¾ãããä¸æ³ï¼æé«ï¼
ã¨ã¯ãæ®å¿µãªããè¡ããªãã£ãã®ã§ããä½ãåé¡ã«ãªã£ãã®ããããã¯ããå¤ãã©ãã§æ¸ãæããããããããã¨ããããã¼ã¿å´ã®åé¡ã§ããã
æç¶ããæ½è±¡åãããã¨ã§ããã¿æ¸ãããã¦ããï¼ãããã¯å ·ä½çãªå®è£ ãé²åºãã¦ããï¼æç¶ãããæ´çãããã¨ã¯ã§ãã¾ãããã§ããããã ãã§ã¯ããã®æç¶ãã§æ±ããå¤ãã«é¢ãã¦ã¯ã¾ã ã¾ã ä¸ååã ã£ãã®ã§ãã
ããããã¯ã¡ãã£ã¨å ·ä½çãªã³ã¼ããè¦ãªããèãã¦ã¿ã¾ããããããã§ããããã¨ãã°ããèªçæ¥ã«ãªã£ãã²ã¨ã®å¹´é½¢ãã²ã¨ã¤å¢ããããã°ã©ã ããèãã¦ã¿ã¾ãããã
ã§ã¯ã¾ãæç¶ãåããã
#include <stdio.h> typedef struct { char* name; int age; } person_t; void happy_birthday(person_t* p){ p->age++; } int main(int argc, char** argv){ person_t shinpei = {"shinpei", 29}; happy_birthday(&shinpei); printf("shinpei's age is %d", shinpei.age); return 0; }
人éãã¼ã¿ã表ãæ§é ä½ person_t ãåå¨ãã¦ã人éã®å¹´é½¢ã1å¢ããæç¶ãã¨ãã¦happy_birthdayãå®ç¾©ããã¦ãã¾ãã
ãã¦ãhappy_birthday ã¨ããæç¶ãã¯ãã人éãå¼æ°ã«ã¨ã£ã¦ãã®äººéã®å¹´é½¢ã1å¢ãããã¨ããæç¶ãã§ããæç¶ããã²ã¨ããã¾ãã«ãã¦æ½åºãããã¨ã«ãã£ã¦ãããã«ä»»æã®äººéï¼shinpei ã§ã jewelve ã§ã dankogai ã§ãã ãã§ãï¼ãå ¥ãããã¨ãã§ãã¾ããããã«ãåã«å¤ã1å¢ãããã ããã£ã¦ãã¨ã ãã§ã¯ãªããããã«ãèªçæ¥ãè¿ãããã ããã¨ããæå³ãæããããã¨ã«ãæåãã¦ãã¾ããããããã°ãããï¼ï¼ï¼ï¼
ããããå®ã¯ããã ãã ã¨ã¡ãã£ã¨å°ã£ããã¨ã«ãªãã®ã§ããæ§é ä½ã¯ãèªåãã©ã®ãããªãã¼ã¿ãæã£ã¦ããã®ãããç¥ã£ã¦ãã¾ããããèªåãæã£ã¦ããã¼ã¿ã«ã©ã«ãããªæç¶ããé©ç¨ããã¦ãã©ã®ããã«å¤ãå¤åãããã®ããã¨ãããã¨ãç¥ãã¾ãããããã¯ã½ããã°ã©ãã¼æ°ãã以ä¸ã®ãããªé¢æ°ãã©ããã«æ¸ãã¦ãã¾ã£ããï¼ï¼ï¼ï¼
void kuso_function(person_t* p){ p->age = -1; }
Oooooopsï¼ï¼ï¼ï¼ï¼ï¼å¹´é½¢ãè² æ°ã«ãªã£ã¦ãã¾ãã¾ããï¼person_t ã®æ§é ä½ã®å®ç¾©ã ããè¦ã¦ããããageã«è² æ°ãå ¥ãããªãã¦ãã¨ã¯æ®éã®äººéãªããããªãã§ããããããããã¯ã½ããã°ã©ãã¼ã¯å¹³æ°ã§ãããããã¨ããã¾ãããããã¯ãã¯ã½ããã°ã©ãã¼ã§ãªãã¦ãããã²ã¨ããã¾ãã®æç¶ããã¨ãã²ã¨ããã¾ãã®ãã¼ã¿ããå¥ã®å ´æã§å®ç¾©ããããéããããæ§é ä½ã®å¤ãã©ããããµãã«æä½ããããã®ãã¯ããã°ã©ã å ¨ä½ã調ã¹ãªãã¨ããããªãããã¡ãã£ã¨ããä¸æ³¨æã§ããã¼ã¿ãå£ãã¦ãã¾ããã¨ã«ãªãããã¾ããã
ã¤ã¾ããæç¶ãã ãã«æ³¨ç®ããã ãã§ã¯ããããä¸å¡ã®ãã¼ã¿ãã©ããããµãã«å¤åãããã®ããã©ãããæç¶ãã«é©ç¨ããããã®ãããããããªããããã©ãããã§ããã¼ã¿ãæ¸ãæãããã¨ãã§ãã¦ãã¾ããã®ã§ãããããªã£ã¦ããã¨ããã©ãã§ã©ããªæç¶ãã«ãã£ã¦å¤ãå¤æ´ããããããããªããæããã¨ããåé¡ãçã¾ãã¦ãã¾ããã¤ã¾ããæç¶ããæ½è±¡åããã ãã§ã¯ãå¤ããã®æä½ããããã¼ã¿ãå®ãããã¨ã¯ã§ããªãã®ã§ãã
ãã®åé¡ã解決ãããã¨ããã®ããªãã¸ã§ã¯ãæåã§ããã§ã¯ãªãã¸ã§ã¯ãæåã«ã¤ãã¦è¦ã¦ã¿ã¾ãããã
ãªãã¸ã§ã¯ãæå
ãã¦ãæç¶ãåã®éçã¯ããæç¶ãã¯ä¸ã«æã«ã¾ã¨ãããã¨ãã§ãããã©ããã¼ã¿ãããããªã¨ããã§æ¸ãæãããããã¨ãé²ããã¨ãã§ããªãï¼ããã¦äºæ ãèµ·ããï¼ãã§ãããããã§ãªãã¸ã§ã¯ãæåã¯ããããããããã¼ã¿ã¨æç¶ããç´ã¥ãã¦ããã¼ã¿ã¨ç´ã¥ããæç¶ããããã¼ã¿ãæ¸ãæããããªãããã°ããããããªãï¼ãã¨èããã®ã§ãããããããã¼ã¿ã®ã«ãã»ã«åãã§ãã
ã³ã¼ããè¦ã¾ãããã
class Person def initialize(name, age) @name = name @age = age end def happy_birthday @age += 1 end end
Personã¯ã©ã¹ããnameã¨ããå±æ§ã¨ageã¨ããå±æ§ãæã£ã¦ãã¾ããããã¦ãhappy_birthdayã¨ããã¡ã½ããï¼æç¶ãï¼ã¯ãPerson ã® @age ã 1 å¢å ãããæç¶ãã§ãããPersonã¨ããã²ã¨ããã¾ãã®ãã¼ã¿ããããããã¼ã¿ãæä½ããã²ã¨ã¾ã¨ã¾ãã®æç¶ããå®ç¾©ããã¦ãããã¾ã§ã¯æç¶ãåã®ã³ã¼ãã¨ã¨ãã«å¤ããã¯ããã¾ããããããããªãã¸ã§ã¯ãæåãåãå ¥ãããã¨ã«ãã£ã¦ãprivate ãª å¤ @age ã¯ãPerson ã¯ã©ã¹ã§å®ç¾©ããã¦ããã¡ã½ãããå¼ã°ããªãéãæ¸ãå¤ãããªããã¨ããããã¨ãä¿è¨¼ã§ãã¾ããï¼ããã¾ã Ruby ã®å ´å instance_eval ã¨ããªã¼ãã³ã¯ã©ã¹ã¨ãããããæãéã¯ãããã©ããã¯ä¾å¤ã¨ããããããã¯ï¼ãã¤ã¾ããPersonã¯ã©ã¹ã«ãkuso_functionãã¿ãããªãã®ãå®ç¾©ããã¦ããªããã°ãPerson ã® @age ã¯ã²ã¨ã¤ãã¤ããã£ã¦ããã ãã§ãæ¸ã£ãããããªã10å¢ãããããªããã¨ãä¿è¨¼ãããããã§ãï¼æé«ã£ï¼
ããã§ãããã¼ã¿ã private ã§å®ãã°ãã®ãã¼ã¿ãå®ç¾©ãããã®ã¨åãã¨ããã§å®ç¾©ãããæç¶ãã§ããå¤æ´ã§ããªãï¼ããã§äºæ ãæ¸ããï¼ï¼ãã¨ããå®å¿ãããããã¡ã¯å¾ããã¨ãã§ãã¾ããããã¾ã¾ã§ã¯æ§é ä½ã®å®ç¾©ã ããè¦ã¦ãã¦ããã§ããã®ãã¼ã¿ã¯ã©ãããæä½ãããããã®ï¼ãã£ã¦ã®ãããããªãã¦ããã£ã©ããªãã¨ãèµ·ãããããããªãã¦æããã£ã¦ãªã£ã¦ããã¨ãããã»ãã»ãããã®ãã¼ã¿ã¯ããããæä½ãããããã®ããã¨ããã®ãã¯ã©ã¹å®ç¾©ãè¦ãã ãã§ãããããã«ãªãã¾ãããå®å¿ã§ããï¼
大äºãªãã¨ãªã®ã§ããã«è¨ãæ¹ãå¤ãã¦å¿µæ¼ããã¾ããããä»ã¾ã§ã¯ãä¼¼ãæä½ã¯ã²ã¨ã¤ã«ã¾ã¨ããããã ãã ã£ãã¨ããã«ããä¸å¡ã®ãã¼ã¿ã¨ããããå¤æ´ããæä½ãã²ã¨ã¤ã«ã¾ã¨ãã¦æ´çããããã¨ããè¦ç¹ããªãã¸ã§ã¯ãæåã«ãã£ã¦ããããããã®ã§ãã
ããããããªãã¸ã§ã¯ãæåã«ããããã¤ããåãããè¦ãã¦ãã¾ãããããã¯ãä»ã®ãªãã¸ã§ã¯ãã®ãã¼ã¿ãç´æ¥ããã£ã¡ãããããªã¡ã½ãããï¼ãã¼ã¿ã¨ããã«ç´ã¥ãæä½ãä¸ã«æã«ã¾ã¨ãããã¦ãªãï¼ã ã¨ãããã©ãããã§ããããã¡ãããã¼ã¿ãï¼ãã¼ã¿ãå®ãã¦ãªãï¼ã ã¨ãããæç¶ããåãã ããã¨ãã£ã¦ãè¤æ°ã®ç¨®é¡ã®ãã¼ã¿ã«é¢å¿ãæã£ã¡ãã£ãã¯ã©ã¹ãï¼ãã²ã¨ã¾ã¨ã¾ãã®ãã¼ã¿ãã«ãªã£ã¦ããªãï¼ãªã©ã§ãã
ãã¦ãæå¾ã®ãè¤æ°ã®ç¨®é¡ã®ãã¼ã¿ã«é¢å¿ãæã£ã¡ãã£ãã¯ã©ã¹ãã¨ããã®ã¯æå¤ã¨ï¼ç¹ã«æç¶ãåã«æ £ã親ããã§ãããã©ãªãã¸ã§ã¯ãæåã«æ £ã親ããã§ããªãããã°ã©ãã¼ãï¼ãã£ã¦ãã¾ããã¡ãªã®ã§ãããã«ã¤ãã¦å ·ä½çã«è¦ã¦ã¿ã¾ãããã
ãã¨ãã°ããèªçæ¥ã«å¹´é½¢ãã²ã¨ã¤å¢ãããã£ã¦ãã¨ã¨ããèªçæ¥ãã¬ã¼ã³ãã®å¨åº«ãã²ã¨ã¤ãµãããã£ã¦ããæ©è½ãããããã°ã©ã ã«ã¤ãã¦èãã¦ã¿ã¾ãããã
æç¶ã "ã ã" ã«æ³¨ç®ããå ´åããæ°åãå¢ãããã¨ããæç¶ããæ½è±¡åã§ãããã§ããæç¶ãåã®æèã ãã ã¨ãããã§ãã¨ãã·ã£ãã®ãæ°åãå¢ãããã£ã¦æ©è½ãã¾ã¨ãã¦ã²ã¨ã¤ã®ï¼åºåºï¼ã¯ã©ã¹ã«ãããï¼ã ã¨ãªããã¡ã§ããã¨ãã«ãDRYååããããä¸çªã®æ£ç¾©ã ï¼ã¿ãããªç¶æ ã«ããããã°ã©ãã¼ã¯ãããªããã¡ã§ãã
ããããæãåºãã¦ãã ããããªãã¸ã§ã¯ãæåã§ã¯ããæç¶ããæ½è±¡åãããã¨ãã ãã§ã¯ã¾ã ä¸ååã§ããã²ã¨ããã¾ãã®ãã¼ã¿ã¨ããããæä½ããæç¶ããã¾ã¨ãããã¨ãã§åé¡ã解決ãããã¨ãã¦ããã®ã§ãããããããè¦ç¹ã§è¦ãã¨ãã«ãã人éã®èªçæ¥ãã¨ããã®ã¨ãå庫ã®å¨åº«ãã¨ããã®ã¯å ¨ãå¥ã®ãã¼ã¿ã§ããã¾ã£ããå¥ã®ãã¼ã¿ããã£ããããã®ã¯ã©ã¹ã«ã¾ã¨ãã¦ãã¾ã£ããããã£ãããªãã¸ã§ã¯ãæåãå°å ¥ãã¦å¾ãããããã¼ã¿ã¨ãã®ãã¼ã¿ã«å¯¾ããæç¶ããã¾ã¨ãã¦è¦éãããããããï¼ãã¨ããã³ã³ã»ããããéè¡ãã¦ãã¾ãã¾ãï¼
ãã®ãããªå ´åãä¾ãã°ã©ããªåé¡ãèµ·ããããããä¾ãããã¦è¦ã¦ã¿ã¾ãããããã¨ãã°ãå庫ã®å¨åº«ã¯å®ã¯ãã¼ã¹åä½ã§ããå¢ããªããã¨ããä»æ§ããã¨ããæããã«ãªã£ãã¨ãã¾ãããããã®ã¨ããå庫ã®å¨åº«ãå¢ããã¨ããæä½ã®åä½ã¯12ã§ããä¸æ¹ãå¹´é½¢ãå¢ããã¨ãªã£ãã¨ãã®åä½ã¯1ã§ããããã¯ãã¾ã£ãï¼ï¼ï¼ï¼ãããæç¶ãã ãã«æ³¨ç®ãã¦ããã®ãµãã¤ã®æä½ãã²ã¨ã¤ã®ã¡ã½ããã«ã¾ã¨ãããã¦ããããçæ¹ã®ä»æ§å¤æ´ãããçæ¹ã«å¯¾ãã¦è´å½çãªå½±é¿ããããã¦ãã¾ããã¨ã«ãªãã¾ããå°ã£ãããã°ã©ãã¼ã¯ ããã㪠if æãããã©ã°ãã¡ã½ããå ãå¼æ°ã«è¿½è¨ãã¦â¦â¦â¦â¦OOOOOOOOOOOOOOOPS!!!!! ã©ãã©ãã³ã¼ãã®è¤éæ§ã¯ããã£ã¦ããã¾ãã
ãã¾ã¾ã§ç§ãè¦ã¦ãããã誤ã£ããªãã¸ã§ã¯ãæåã«ãããæ§é åãã§ããããã®ããã®ãã¿ã¼ã³ã§ãããå ¨ç¶ç°ãªãé¢å¿ãæã£ããã¼ã¿ãªã®ã ãã©ããã¨ãã°ã表ã¨ãã¦è¡¨ç¤ºãããã ã¨ããå¹³åãåºããã ã¨ããããããããã¼ã¿ãã©ããªãã®ãªã®ããã§ã¯ãªãã¦ããã¼ã¿ãã©ãå¦çããã®ããã¨ãããã¨ã軸ã¨ãã¦æ½è±¡å/æ§é åãã¦ãã¾ããçµæç°ãªãé¢å¿ãæã£ããã¼ã¿ãªã®ã«åãã¯ã©ã¹ã§å¦çãã¦ãã¾ããçæ¹ã®å¤æ´ãããçæ¹ã«å½±é¿ãä¸ãã¦å°ã£ãããã¿ãããªã
ããã§ããªãã¸ã§ã¯ãæåã«ãããåé¡æèã®ã¾ã¨ãããã¾ãããããªãã¸ã§ã¯ãæåã¯ããæç¶ããã ãã§ã¯ãªãã¦ãããã®ãã¼ã¿ãã©ãããé¢å¿ãæã¡ãã©ãããæä½ãããããã®ããã¨ãããã¨ã¾ã§èãããã¨ã§ããä¸å¡ã®ãã¼ã¿ã¨ããã«å¯¾ããæç¶ãããã¾ã¨ãããã¨ããã®ç®çã¨ãã¦ãã¾ããããªã®ã§ããã¾ã¾ã§ãæç¶ããã ãã§ãã®ãèãã¦ããã®ã«ãã©ã¹ãã¦ããã®ã¯ã©ã¹ãé¢å¿ãæã¤ã¹ããã¼ã¿ã¯ãªããªã®ãããååã«æèããå¿ è¦ãããã§ããããå¥ç¨®ã®ãã¼ã¿ã«å¯¾ããæä½ãä¸æã«æ ããããªã¯ã©ã¹ãä½ã£ã¦ããããã¨æ°ã¥ããã¨ãã«ã¯ãä¸åº¦ç«ã¡æ¢ã¾ã£ã¦ããã£ã¨ããã®ã¯ã©ã¹ã¯ã©ããªãã¼ã¿ã«é¢å¿ããã¡ããã®ãã¼ã¿ãã©ãæä½ããããã ã£ãï¼ãã¨èãã¦ã¿ãã¨ããã§ãããã
ãªãã¸ã§ã¯ãæåè½ã¡ç©æ¾ã
ãã¦ããã®ããã«ããã¼ã¿ãã«ã注ç®ããã¦ã¯ã©ã¹ãä½ã£ã¦ããã¨ããããã¼ã¼ã¼ã¼ã¼ã¼ã¼ãããã«ãã¼ã¿ã¨ãã¦ã¯ã¾ã£ããå¥ã®é¢å¿ãªãã ãã©æç¶ãèªä½ã¯å ±éãªãã ãï¼ï¼ï¼ï¼ããããã®ãå¥ã®ã¯ã©ã¹ã®å¥ã¡ã½ããã¨ãã¦å®ç¾©ããªãã¨ãã¡ãªã®ï¼ï¼ãã¨ããå ´åãåºã¦ãã¾ããã¤ã¾ããé¢å¿ã¯å¥ãªãã ãã©å®è£ ãåããªãã ãï¼ããã¯ã©ãããã®ï¼ã¨ãã話ã§ããããããã¨ãã«ã¯ãä¼çµ±çãªãªãã¸ã§ã¯ãæåãªãã°ãæç¶ãã ãã«é¢å¿ãæã¡ããã¼ã¿ã«ã¯é¢å¿ãæããªãã¯ã©ã¹ãã£ã¦ã®ãä½ã£ã¦ããã®ã¯ã©ã¹ï¼ãã¤ã³ã¹ã¿ã³ã¹ï¼ããã¼ã¿ã«è²¬ä»»ãæã¤ã¯ã©ã¹ãä¿æããå®éã®å¦çã¯ãæç¶ãã ãã«é¢å¿ãæã¤ã¯ã©ã¹ã®ã¡ã½ãããå¼ã¶ãã¨ãããããããããã¨è¯ãã§ãããããã®ãæç¶ãã ãã«é¢å¿ãæã¤ãã£ã¦ã®ãæåã¯ç解ãã¥ããã®ã ããã©ããã®ãããã¯ã¹ãã©ãã¸ã¼ãã¿ã¼ã³ã¨ãããªãã¸ãã¿ã¼ã³ã¨ãã³ãã³ããã¿ã¼ã³ã¿ãããªã®ããå¦ãã§ã¿ãã¨è¯ãã§ãããããã®ãããã®è©±ãã·ã³ãã«ã«è¡¨ç¾ããã¨ããå®è£ ã®åå©ç¨ã«ç¶æ¿ã使ããªãå§è²ã使ããã¨ãããã¬ã¼ãºã«ãªãããã§ããã
ãããã¯ãtraitãæã¤ãããªè¨èªã Ruby ã® module ã¿ãããªæ©è½ãããè¨èªãªãã°ããããã使ããã¨ãæ¤è¨ãã¦ãè¯ãã§ãããã
ç´ç²é¢æ°åè¨èª
ãã¾ãã«ã¨ã³ããªãé·ããªã£ãã®ã§ã次åã¸ç¶ãã
ãã®ã¨ã³ããªã«å¯¾ããè¿æ
http://www.tatapa.org/~takuo/structured_programming/structured_programming.html
@cocoa_ruto æ°ããã¡ããã¡ãæç¨ã§èå³æ·±ãè¨äºãã¬ã¹ãã³ã¹ã¨ãã¦æ¸ãã¦ãã ããã¾ãããå¿ èªã§ãã