第7ç« ã³ã¼ãã£ã³ã°æ¨æºã¨è¦ç´ - ãCode Readingã
1ã2å¹´åããæè¡æ¸ãèªã¿ãªããèãããã¨ããã¯ãã¼ãºããªTwitterã¢ã«ã¦ã³ãã§å»¶ã ã¤ã¶ãããã¨ããæ ¹æãªãã¨ãå®æçã«ãã£ã¦ãã¾ããããµã¨ããããããã°ã§ããã¨ã©ããªæãã«ãªããã ããã¨æã£ãã®ã§ãå®é¨çã«ãã£ã¦ã¿ã¾ãã
ãCode Readingâãªã¼ãã³ã½ã¼ã¹ããå¦ã¶ã½ããã¦ã§ã¢éçºææ³ãã®ç¬¬7ç« ãã³ã¼ãã£ã³ã°æ¨æºã¨è¦ç´ããèªãã§ãèãããã¨ãåãããªããã¨ããã©ãã©ã¨æ¸ãã¾ããæ¬ã®å 容ã®ã¾ã¨ãã§ã¯ããã¾ããã
ã¾ã¨ãã§ã¯ãªãã¨ããã¤ã¤ã7ç« ã®åé ã§æãããã¦ããæåãª3ã¤ã®ã³ã¼ãã£ã³ã°è¦ç´ã«ãä¸å¿ãªã³ã¯ãã¦ããã¾ãã
- GNUã³ã¼ãã£ã³ã°æ¨æº
- BSDã¹ã¿ã¤ã«ã¬ã¤ã
- FreeBSDã®ã¿ã¼ããã«ã§ãman 9 styleã
- http://www.freebsd.org/cgi/man.cgi?query=style&sektion=9
- Javaã³ã¼ãã£ã³ã°è¦ç´
- ããããªï¼ http://www.oracle.com/technetwork/java/codeconv-138413.html
7.1 ãã¡ã¤ã«ã®ååã¨ç·¨æ
Javaã§ã¯ãã¯ã©ã¹å¤æ°ãã¤ã³ã¹ã¿ã³ã¹å¤æ°ãã³ã³ã¹ãã©ã¯ã¿ãã¡ã½ããã®é ã«æ¸ãã®ãããã¨æ¸ããã¦ãã¾ãããããã«ãåºå ¸ããã3.1.3 Class and Interface Declarationsãã«ããã¾ããã
ããããå¤æ°ã¨ã¡ã½ãããprivateãprotectedãpublicã®é ã§å®ç¾©ãããã¨ãæ¸ããã¦ããããã¡ãã®åºå ¸ãåããã¾ãããéã§ã¯ï¼
ã11.1 Java Source File Exampleããè¦ããããããããªãã¨ãå¤æ°ã®å®ç¾©ã¯éã§ãããã®ã³ã¼ãã«ã¯ãã¡ã½ããã¯publicããããã¾ããã
å人çã«ã¯ãJavaã®æ¸ãæ¹ã¯ã次ã®æ¬ããã¼ã¹ã«ããã°ããã¨æã£ã¦ãã¾ãã
Javaã«ã¼ã«ããã¯ã?èªã¿ãããå¹ççãªã³ã¼ãã®åå
- ä½è : 大谷æå¹³,ç±³ææ£æ,çå±±æé,横ç°å¥å½¦,é»éå½éæ å ±ãµã¼ãã¹
- åºç社/ã¡ã¼ã«ã¼: æè¡è©è«ç¤¾
- çºå£²æ¥: 2011/02/15
- ã¡ãã£ã¢: åè¡æ¬ï¼ã½ããã«ãã¼ï¼
- è³¼å ¥: 4人 ã¯ãªãã¯: 163å
- ãã®ååãå«ãããã° (20件) ãè¦ã
ç·´ç¿åé¡ 7.2
å³å¯ã«æå®ããã¦ããé åºã§ã³ã¼ãè¦ç´ ãå®ç¾©ãã¦å®£è¨ãããã¨ã®é·æã¨çæãè«ããªãããæè¿ã®çµ±åéçºç°å¢ãèªè ã®è¦æ¹ã«ã©ã®ãããªå½±é¿ãä¸ãã¦ããã¨æãããè¿°ã¹ãªããã
ãã®è©±é¡ã¯ããã¡ã¤ã«å ã®ã¡ã½ããå®ç¾©ä½ç½®ããåããã¡ã¤ã«ããã®å¼ã³åºãå¯å¦ã«å½±é¿ãä¸ããè¨èªããããã§ãªããã«ãã£ã¦ãèããã¹ããã¨ãå¤ãã£ã¦ããã¨æãã¾ããâ¦ããä»åã¯èå¯ãã¦ãã¾ããã
- é·æ
- publicã¡ã½ããããã¡ã¤ã«ã®ä¸ãä¸ã«ã¾ã¨ã¾ã£ã¦ããã°ããã®é¨åã ãããã£ããèªããã¨ãã©ã¯ã«ã§ããã
- çæ
- æ°è¦ã«ã¡ã½ãããæ¸ãæãæ¿å ¥ç®æã«æ³¨æãæããªããã°ãªãããç ©ãããã
- ã¾ããå¯è¦ç¯å²ã§ã¯ãªããæ¯ãèãã®ç¨®é¡ãã¨ã«é¢é£ã¡ã½ãã群ãã¾ã¨ãããå ´åã«ãå°ãã
IDEã«ããå½±é¿ã¨ãã¦ã¯ããã¨ãã°ãEclipseã使ãã¨ãã³ã¼ãè¦ç´ ãæå®é åºã«ä¸¦ã¹ãããã®æéãæ¸ãããã¨ãã§ãã¾ãã
- ï¼»Preferencesï¼½âï¼»Javaï¼½âï¼»Appearanceï¼½âï¼»Members Sort Orderï¼½ã§è¨å®ããã¨ããã«ãå³ã¯ãªãã¯âï¼»Sourceï¼½âï¼»Sort Membersï¼½ã§ã¡ã³ãã¼ã並ã¹æ¿ãã¦ããã¾ãã
- Outlineãã¤ã³ã§ã¢ã«ãã¡ãããé ã«ä¸¦ã¹ã¦è¦ããã¨ãããã¿ã³1ã¤ã§ã§ãã¾ãã
ã表7.1 ä¸è¬çãªãã¡ã¤ã«åãã«ã¤ãã¦
ãã®ãããªåå¥ã®ãã¡ã¤ã«æ¡å¼µåãææ¡ããã®ã大äºã§ããã使ç¨ãã¦ãããã¼ã«ç¹æã®ãã¡ã¤ã«/ãã£ã¬ã¯ããªæ§é ãç¥ã£ã¦ããã®ã大äºã ã¨æãã¾ãããã¬ã¼ã ã¯ã¼ã¯ããã«ããã¼ã«ã«ãã£ã¦ããç´æã®æ§é ããããã©ãã«ä½ãããããææ¡ã§ãã¦ããã°ãã³ã¼ããèªã¿ããããªãããºã§ãã
7.2 ã¤ã³ãã³ã
ã¤ã³ãã³ãã®è©±é¡ã§ã¯ããã¼ãã¿ããã½ããã¿ãã¨ããè¨èãããåºã¦ããã®ã§ãæå³ããããã¦ããã¾ãã
- ãã¼ãã¿ã
- ã¿ãæåã\tãã使ã£ãã¤ã³ãã³ã
- ã½ããã¿ã
- åè§ã¹ãã¼ã¹ã使ã£ãã¤ã³ãã³ã
ãã¼ãã¿ãã¨ã½ããã¿ãã®ä½¿ãæ¹ã«ã¤ãã¦ã¯ããããã話ãããããã§ãã
ãã¼ãã¿ãï¼viã§ã¯ tsï¼ã¯ä¸è¬ã«8æåã¶ãã®å¹ ã ããã½ããã¿ãã¯ãã®è£å©ã¨ãã¦å®ç¾©ããï¼vi ã§ã¯ swï¼ãé常4æåå¹ ã¨ããã¦ããã
字下げスタイル - Wikipedia
ãã¼ãã¿ãã¯ãããã¯ã示ãã®ã«ä½¿ãããã½ããã¿ãã¯æã1è¡ã«åã¾ããã«æãè¿ããªããã°ãªããªãã¨ãã«ä½¿ãããã
ãã¦ãã¤ã³ãã³ããã©ãæ¸ããã¨ãã話ã¯ãã¦ãããã³ã¼ããªã¼ãã£ã³ã°ã®è¦³ç¹ã§èããã°ã次ã®2ã¤ãã§ããã°ããã§ãããã
- 対象ã®ã³ã¼ããã¼ã¹ã§ä½¿ããã¦ããã¿ãè¨å®ãæ£ããææ¡ãããã¨
- ãã®è¨å®ãæå ã®ã¨ãã£ã¿ã«åæ ããããã¨
æ¬æã§ã¯ãã³ã¡ã³ãã«æ¸å¼è¨å®ãæ¸ããã¦ããä¾ãæãããã¦ãã¾ããã¨ãã£ã¿ã«ãã£ã¦ã¯ããã®è¨å®ãèªã¿åãã表示ãèªåçã«èª¿æ´ãã¦ãããããã§ããç´ æµã§ãããï¼!!!æªç¢ºèª!!!ï¼
æ¸ããã¦ããªãå ´åã¯ãã©ã®ããã«å¤å¥ããã®ã§ããããããã®æ¹æ³ãç·´ç¿åé¡ 7.3ã§åããã¦ãã¾ãããèªåã«ã¯ããã«æãã¤ãã¾ãããã¾ã¨ãã«ãããã¨ããã¨ãæåã³ã¼ãã®å¯¾å¿ãå¿ è¦ã§é£ãããã§ãã
è²ã è¦ã¦åã£ã¦ããããã³ã¼ããå ¬éããã¦ãã人ãããã®ã§ãã¡ã¢ãã¦ããã¾ãã
7.3 æ¸å¼
7.3ç¯ã¯ãã¹ãã¼ã¹ãä¸æ¬å¼§ãã³ã¡ã³ãã®ä½¿ãæ¹ã«ã¤ãã¦æ¸ããã¦ãã¾ãã
æ¸å¼ã¯è¨èªããã¼ã ã«ãã£ã¦æ§ã ã§ãããåºæ¬æ¹éã¨ãã¦ã
- æ¸ãã¨ãã¯ãã³ã¼ãå ¨ä½ã§çµ±ä¸ãããã¨ãä½ããã大äº
- èªãã¨ãã¯ãã©ããªã¹ã¿ã¤ã«ã§ãèªãããã¨ã大äº
ã¨ãã価å¤è¦³ãç¹°ãè¿ãæãã£ãã®ã§ããã®æã®è©±ã¯ããã¤ããããã£ãçµè«ãããã§èªãã§ãã¾ãã¾ããå·ãè¾¼ã¿ãããã
ã³ã¡ã³ãã¯äººéã ãã§ãªãæ©æ¢°ï¼ãã¼ã«ï¼ãèªããã®ã§ãããã¨ãã話ã¯ãããããã°ããã ãªã¨æãã¾ããããã¼ã«ã¨ããã®ã¯ãJavadocãlintãªã©ã§ãã
ã³ã³ãã¤ã©è¦åæå¶ã®ããã®ã³ã¡ã³ã
ããã°ã©ã ã®å¶å¾¡ããã¼ãå°éããªããã¤ã³ããç¥ãããããã«ã
/* NOTREACHED */
ã¨æ¸ã件ã«ã¤ãã¦ãæ¬æã®èª¬æã足ããªãæ°ãããã®ã§ãåãããããã¨æã£ã説æãå¼ç¨ãã¾ãã
gcc ã§ã¯ï¼ä¸ç¥ï¼ããã°ã©ã ã®æµããè¤éã«åå²ãã¦ãã¦ããããã®æµãã辿ã£ã¦ããã¹ã¦ã®å ´åã«å¤æ°ãæ£ããã»ããããããã©ããããã§ãã¯ãã¦ããã®ã§ããããã®æãåºæ¬çã«é¢æ°ã¯æ»ã£ã¦æ¥ããã®ã¨ãã¦å¦çããããå¼ã³åºãããããã«æ»ããã«ãã©ããã«è¡ã£ã¦ãã¾ãé¢æ°ã¯å¤æ ã§ãããããããã©ã¤ãã©ãªé¢æ°ã¯æ°å°ãªããããããããã®ãããªã©ã¤ãã©ãªé¢æ°ãã©ããããã¦ã¼ã¶é¢æ°ã¯ãä»»æã«ä½ããããã§ããï¼warning() ãªãã¦è¯ãä¾ã ã...ï¼ããã®æããã¦ã¼ã¶é¢æ° warning() ã¯æ»ã£ã¦æ¥ãªãããã¨ãã³ã³ãã¤ã©ã«ä¼ãã¦ãããªãã¨ãããã¼è§£æã§ã¯æ»ã£ã¦æ¥ããã¨ãåæã«ããã®ã§ãç¡æå³ã«ãåæå¤ãã»ããããã¦ããªããã¨ããè¦åãçºçãããã¨ããããã ãããã³ã¡ã³ãã®ããã¡ã§ /* NOTREACHED */ ã¨æ¸ãã¦ããã¨ãã³ã³ãã¤ã©ã¯ãã®ã³ã¡ã³ããèªèãããã®ã³ã¡ã³ãã«ã¯å¶å¾¡ã移ããªããã¨ãç解ããã
Super Technique 講座〜longjmpと例外
ã¨ã©ã¼ãæå¶ããã ãã§ãªããæ£ããåããä¿è¨¼ãããå ´åã¯ãä½ãassertæã使ããæ¸ãæ¹ã«ããã¨ããã®ããããã¾ãããï¼ãã¡ããã表æã®æ©æ§ãè¨èªä»æ§ã«åå¨ããåæã«ãªãã¾ããï¼
ã¨ãã£ã¿ã§ã¿ã°ã¨ãã¦æ±ãããã®ã³ã¡ã³ã
ä¿®æ£å¯¾è±¡ã«ãFIXMEãã¨æ¸ããããæ¡å¼µäºå®ã«ãTODOãã¨æ¸ãããããç¿æ £ã«ã¤ãã¦ã
Eclipseã®å ´åãï¼»Preferencesï¼½âï¼»Javaï¼½âï¼»Compilerï¼½âï¼»Task Tagsï¼½ã§ã好ããªã¿ã°ãè¨å®ã§ãã¾ãããã
7.4 ååä»ãè¦å
7.4ç¯ã¯ãå¤æ°åã®ãã£ã¡ã«ã±ã¼ã¹ã¨ã¢ã³ãã¼ã¹ã³ã¢åºåãã®è©±ãããã³ã¬ãªã¢ã³è¨æ³ã®è©±ã§ãã
ããããã°ãå æ¥ãããã¨ã³ããªã®ãããã§ããã³ã¬ãªã¢ã³è¨æ³ã«2種é¡ãããã¨ãç¥ãã¾ãããæ¬ã§åãä¸ãããã¦ããã®ã¯ãã·ã¹ãã ãã³ã¬ãªã¢ã³ã®æ¹ã§ããã
ç·´ç¿åé¡ 7.5
ãã³ã¬ãªã¢ã³è¨æ³ã«ããååä»ãè¦åã¯ãåãã§ãã¯ã³ã³ãã¤ã©ãè¡ã£ã¦ããã®ã¨åæ§ã®æ©è½ãæããã®ã ã¨ãã主張ãããããããã«ã¤ãã¦è«ããªããã
ï¼ãããªä¸»å¼µåãã¦èãããã»ã»ã»ï¼
ã¾ãããã³ã¬ãªã¢ã³è¨æ³ã¯ããååã«ãã³ããä¸ãããã¨ã§èªã人ã«å½¹å²ãæ¨æ¸¬ãããã以ä¸ã®è²¢ç®ãããã®ã§ãããããèªåã¯ããªãã¨èãã¦ãã¾ãããªã®ã§ãããããããããã§ã«ããã§èªèä¸è¶³ããããã¾ãããããæã£ãä¸ã§ããã
æ©æ¢°çãªãã§ãã¯æ©æ§ãæã¤ã®ã§ãªãéãããã³ã³ãã¤ã©ã¨åæ§ã®æ©è½ãæãããã¨ã¯ããã¾ãããæ £ç¿ã¨ç°ãªãç¨æ³ã§ã·ã¹ãã ãã³ã¬ãªã¢ã³è¨æ³ã使ãããå ´åãã¤ã¾ããåæ§ç¯èå¥åãç°ãªãå ´åã«ãè¦åã¯è¡ãããã®ãï¼ ããè¡ãããã¨ãã¦ããã®è¦åã«æå³ã¯ããã®ãï¼ ã¨ãã話ã«ãªãã¨æãã¾ãã
ã¨ãããããã³ã¬ãªã¢ã³è¨æ³ã®è©±ã¯èãããã飲ã¿ä¼ã§ããã£ã¦ãã£ã¡ããè¨ã£ã¦ãã
7.5 ããã°ã©ãã³ã°ä½æ³
移æ¤æ§ãèªãã¨ãã¯ãã©ã®ã¬ã¤ã¤ã¼ã®è©±ããã¦ããããæèããæ¹ãè¯ãããã§ããããã»ããµã¼éã§ã®ç§»æ¤æ§ãªã®ããOSéã§ã®ç§»æ¤æ§ãªã®ãããªã©ã
æ¬æã§ã¯ãããã°ã©ãã³ã°ä½æ³ã®ä¾ã¨ãã¦ããã³ãã³ãã©ã¤ã³ãªãã·ã§ã³ãå¦çããããã«argvã®é åãèµ°æ»ããã®ã§ã¯ãªããgetoptã使ããã¨ããè¦ç´ãæãããã¦ãã¾ãããããã«ããããã¨ãè¨è¿°ã«ä¸è²«æ§ãåºã¦ãåããããããªãã¨ãã話ã§ãã
ããããä¾å¤ãããã§ããããgetoptã¯ãUNIXç¨ã®ããããã¡ã¤ã«ã«å«ã¾ãã¦ãã¾ãããã®ããããã©ãããã©ã¼ã ç¬ç«ã®ã³ã¼ããæ¸ããã¨ããã¨ãããªããããä¸ã®è¦ç´ã«ã¯æ²¿ãã¾ããã
- è¦ç´ãæé»ã®åæã¨ãã¦ãããã¨
- æ¸ããã¦ããã¢ããªã±ã¼ã·ã§ã³ã®æ§è³ª
ã®2ã¤ãææ¡ãã¦ããã¨ããã¨æãã¾ãã
7.6 ããã»ã¹æ¨æº
7.6ç¯ã¯ãããã¥ã¡ã³ãä½æããªãªã¼ã¹ããã«ããªã©ã®è©±ã§ãã
æ¨æºåããããã«ãããã»ã¹ã§è¨è¿°ã®è¤éããã©ããã¦éã£ã¦ããã®ãã¯ãNetBSDã®ãããã¯ã¼ã¯ã¿ã¤ã ãããã³ã«ï¼NTPï¼ã©ã¤ãã©ãªã®64åã®ãã¡ã¤ã«ãã³ã³ãã¤ã«ããã®ã«ä½¿ããã18è¡ã®Makefileã¨ãapacheãµãã¼ãã©ã¤ãã©ãªã®12åã®ãã¡ã¤ã«ãã³ã³ãã¤ã«ããã®ã«ä½¿ããããæ製ã®40è¡ã¨èªåçæããã37è¡ã¨ããæãMakefileãã³ãã¬ã¼ããæ¯è¼ãã¦ã¿ãã¨ãããã§ãããã
ã¨ã®ãã¨ãªã®ã§ãæ¯è¼ãã¦ã¿ã¾ããã
netbsd/lib/libntp/Makefile
- LIBã«ãçæããã©ã¤ãã©ãªåãæå®
- SRCSã«ãå¿ è¦ãªã½ã¼ã¹ãã¡ã¤ã«ã1å1åãã©ããã«æå®
- CPPFLAGSã«ãã³ã³ãã¤ã©ãªãã·ã§ã³ãæå®
- å ±æã©ã¤ãã©ãªãä½ãããã®bsd.lib.mkãincludeãã
â¦ããã ãã
apache/src/ap/Makefile.tmpl
- ä¸ã«å ãã¦ãè¤æ°ã®ãã«ãã¿ã¹ã¯ãå®ç¾©ããã¦ãããcleanã¨ããdist cleanã¨ãã
- ããã«ããDO NOT REMOBEããªã注æã®å¾ã«ããªãã¸ã§ã¯ããã¡ã¤ã«ãä¸æ¦ä½æããããã®è¨è¿°ã延ã ã¨ããã
çµè«ã¨ãã¦ããè¨è¿°ã®è¤éããã©ããã¦éã£ã¦ããã®ããã¯ããããããã¨ã®è¤éããéããããããªãã®ãã¨ããå½ããåã®çãã«ããè³ããªãã£ãã®ã§ãããããã§ãããã§ããããããåããã¾ããã
ã»ã»ã»
ã¨ã¾ãããããªæãã§ãå®é¨çµäºã§ãã誰å¾ã§ãããããã