Ãô½Ý¿ª·¢Öбàд¸ßÖÊÁ¿Java´úÂë
Ãô½Ý¿ª·¢µÄÀíÄîÒѾÁ÷ÐÐÁ˺ܳ¤µÄʱ¼ä£¬ÔÚÃô½Ý¿ª·¢ÖеĿª·¢µü´ú½×¶ÎÖУ¬ÎÒÃÇ¿ÉÒÔͨ¹ýÎå¸ö²½Ö裬À´ÓÐЧµÄÌá¸ßÕû¸öÏîÄ¿µÄ´úÂëÖÊÁ¿¡£
JavaÏîÄ¿¿ª·¢¹ý³ÌÖУ¬ÓÉÓÚ¿ª·¢ÈËÔ±µÄ¾Ñé¡¢Java´úÂë±àдϰ¹ß£¬ÒÔ¼°È±·¦Í³Ò»µÄ±ê×¼ºÍ¹ÜÀíÁ÷³Ì£¬ÍùÍùµ¼ÖÂÕû¸öÏîÄ¿µÄ´úÂëÖÊÁ¿½Ï²î£¬ÄÑÓÚά »¤£¬ÐèÒª½Ï´óµÄ²âÊÔͶÈëºÍÖÜÆÚµÈÎÊÌâ¡£ÕâЩÎÊÌâÔÚÒ»¸öÏîÄ¿×é³õ½¨¡¢ÐèÇóºÍÉè¼Æ¾ù¾ßÓв»ÍêÈ«¿ÉÔ¤ÆÚÐÔºÍÍ걸ÐÔµÄÈ«ÐÂÏîÄ¿Öн«ÓÈΪͻ³ö¡£
Èçͼ1Ëùʾ£¬Ãô½Ý¿ª·¢¹ý³Ì¾ÀúÐèÇóµ÷ÑУ¬ÓÃÀý·ÖÎöºÍÓÃÀý·Ö½â£¬½øÈ뿪·¢µü´ú½×¶Î¡£ÔÚÿ¸öµü´ú¹ý³ÌÖУ¬¿ÉÒÔ²ÉÓÃÒÔϲ½ÖèÀ´±£Ö¤ºÍÌá¸ßÕû¸öÏîÄ¿µÄ´ú ÂëÖÊÁ¿£ºÍ³Ò»±àÂë¹æ·¶¡¢´úÂëÑùʽ;¾²Ì¬´úÂë·ÖÎö(staticcodereview);µ¥Ôª²âÊÔ;³ÖÐø¼¯³É;´úÂëÆÀÉóºÍÖع¹ (Review&Refactor)¡£ÏÂÎĽ«Õë¶Ôÿ¸ö²½ÖèºÍÆäËùʹÓõŤ¾ß¡¢·½·¨½øÐÐÏêϸÃèÊö¡£
ͼ1.Ãô½Ý¿ª·¢ÖеÄJava´úÂëÖÊÁ¿±£Ö¤²½Öè
²½ÖèÒ»£ºÍ³Ò»±àÂë¹æ·¶¡¢´úÂëÑùʽ
¹æ·¶Í³Ò»µÄ±àÂë»áÔö¼ÓÏîÄ¿´úÂëµÄ¿É¶ÁÐԺͿÉά»¤ÐÔ£¬µ«Êµ¼ÊÇé¿öÍùÍùÊÇÏîÄ¿×éÄÚµÄJava´úÂ뿪·¢ÈËÔ±µÄ±àÂë·ç¸ñ³£³£¸÷²»Ïàͬ£¬Õâ¿ÉÄÜÊÇÓÉÓÚ²»Í¬ µÄ¾ÑéÏ°¹ß»òÕßȱ·¦±àÂë¹æ·¶·½ÃæµÄѧϰÔì³ÉµÄ¡£ÕâÑùÒ»À´£¬ÆäËûÏîÄ¿³ÉÔ±»òÕßά»¤ÈËÔ±ÔÚÔĶÁÏîÄ¿´úÂëʱ¾ÍÐèÒª»¨·Ñ¸ü¶àµÄʱ¼äÀ´Àí½â´úÂë×÷ÕßµÄÒâͼ£¬ËùÒÔÖƶ¨ ²¢²ÉȡͳһµÄ±àÂë¹æ·¶¾ÍÏԵúÜÖØÒª¡£±àÂë¹æ·¶Ö÷ÒªÓ¦°üº¬ÒÔϼ¸¸ö·½Ã棺
¡ôÒ»°ã¹æÔòºÍ¸ñʽ¹æ·¶¡£ÀýÈç´úÂëËõ½ø¡¢³ÌÐò¿é¹æ·¶¡¢Ã¿ÐÐ×î´ó´úÂ볤¶ÈµÈ¡£
¡ôÃüÃû¹æÔò¡£ÀýÈç°üÃû¡¢ÀàÃû¡¢±äÁ¿¡¢·½·¨¡¢½Ó¿Ú¡¢²ÎÊýµÈÃüÃû¹æ·¶
¡ôÎĵµ¹æ·¶¡£ÀýÈçÀàÎļþÍ·ÉùÃ÷¡¢Àà×¢ÊÍ¡¢³ÉÔ±±äÁ¿ºÍ·½·¨×¢Ê͵ȹ淶¡£
¡ô±à³Ì¹æ·¶¡£ÀýÈçÒì³£¡¢²¢·¢¡¢¶àÏ̵߳ȷ½ÃæµÄ´¦Àí·½Ê½¡£
¡ôÆäËû¹æ·¶¡£ÀýÈçÈÕÖ¾¸ñʽ¡¢ÊôÐÔÎļþ¸ñʽ£¬·µ»ØÖµºÍÏûÏ¢¸ñʽ¡£
ÏîÄ¿µÄ±àÂë¹æ·¶¿ÉÒԲο¼ÒÑÓеÄһЩJava±à³Ì¹æ·¶Êé¼®ºÍÆäËûÏà¹Ø×ÊÁϲ¢½áºÏÏîÄ¿µÄ±¾ÉíÀ´Öƶ¨£¬¿É¹©²Î¿¼µÄÊé¼®ÓС¶Java±à³Ì·ç¸ñ¡·(Ó¢ÎÄÊé ÃûΪ£ºTheElementsofJavaStyle)¡£±àÂë¹æ·¶ÒªÐγÉÎĵµ£¬¶øÇÒÒª¼ò½àÃ÷ÁË£¬²¢×éÖ¯ÏîÄ¿³ÉÔ±Ò»Æðѧϰ£¬È·±£ËùÓгÉÔ±ÕýÈ·Àí½âËùÓÐÌõÄ¿¡£
Ò»µ©±àÂë¹æ·¶È·¶¨£¬¾Í¿ÉÒÔÀûÓÃEclipse×ÔÉíÌṩµÄ¹¦ÄÜÀ´¿ØÖÆ´úÂëÑùʽºÍ¸ñʽ¡£¾ßÌå×ö·¨ÊÇ£¬µã»÷EclipseµÄ Windows->Preference²Ëµ¥ÏÔÚ´ò¿ªµÄPreferences¶Ô»°¿òµÄ×ó²àÀ¸ÖÐÕÒµ½Java½ÚµãϵÄ×ÓÏîCodeStyle(Èçͼ2)£¬¸ÃÏî ºÍËüµÄ×ÓÏîÔÊÐíÄú¶ÔJava´úÂëµÄÑùʽ½øÐпØÖÆ¡£
ͼ2.Eclipse´úÂëÑùʽÉèÖô°¿Ú
ÀýÈ磬ΪÁËʹÓÃ×Ô¶¯¸ñʽ»¯¹¤¾ß£¬¿ÉÒÔÔÚEclipseÌṩµÄĬÈÏ´úÂë¸ñʽÅäÖ
Ïà¹ØÎĵµ£º
JavaỊ̈߳ºÏ̵߳ĵ÷¶È-Èò½
Ï̵߳ÄÈò½º¬Òå¾ÍÊÇʹµ±Ç°ÔËÐÐ×ÅÏß³ÌÈóöCPU×ÊÔ´£¬µ«ÊÇÈ»¸ø˲»ÖªµÀ£¬½ö½öÊÇÈóö£¬Ïß³Ì״̬»Øµ½¿ÉÔËÐÐ״̬¡£
Ï̵߳ÄÈò½Ê¹ÓÃThread.yield()·½·¨£¬yield() Ϊ¾²Ì¬·½·¨£¬¹¦ÄÜÊÇÔÝÍ£µ±Ç°ÕýÔÚÖ´ÐеÄÏ̶߳ÔÏ󣬲¢Ö´ÐÐÆäËûÏ̡߳£
/**
* JavaỊ̈߳ºÏ̵߳ĵ÷¶È-Èò½
*
......
import
java
.io.BufferedReader;
import
java
.io.FileInputStream;
import
java
.io.FileNotFoundException;
import
java
.io.FileOutputStream;
import
java
.io.IOException;
import
java
. ......
java³£ÓõÄÕýÔò±í´ïʽ¼°patternÓëmatcher -------------------------------------------------------------------------------- 2009-05-27 00:04:28¡¡±êÇ©£º¡¡¡¡¡¡[ÍÆË͵½¼¼ÊõȦ] (0) ³£ÓõÄÕýÔò±í´ïʽ: ½âÊÍ: ^ Æ¥ÅäÊäÈë×Ö·û´®µÄ¿ªÊ¼Î»Öᣠ$ Æ¥ÅäÊäÈë×Ö·û´®µÄ½áÊøλÖᣠ* Æ¥ÅäÇ°ÃæµÄ×Ó±í´ïʽÁã´Î»ò¶à´Î¡£ + Æ¥ÅäÇ°ÃæµÄ× ......
ÎÒÃǶ¼ÖªµÀÒ»¸ö¶ÔÏóֻҪʵÏÖÁËSerilizable½Ó¿Ú£¬Õâ¸ö¶ÔÏó¾Í¿ÉÒÔ±»ÐòÁл¯£¬javaµÄÕâÖÖÐòÁл¯Ä£Ê½Îª¿ª·¢ÕßÌṩÁ˺ܶà±ãÀû£¬ÎÒÃÇ¿ÉÒÔ²»±Ø¹Øϵ¾ßÌåÐòÁл¯µÄ¹ý³Ì£¬Ö»ÒªÕâ¸öÀàʵÏÖÁËSerilizable½Ó¿Ú£¬Õâ¸öµÄËùÓÐÊôÐԺͷ½·¨¶¼»á×Ô¶¯ÐòÁл¯¡£
È»¶øÔÚʵ¼Ê¿ª·¢¹ý³ÌÖУ¬ÎÒÃdz£³£»áÓöµ½ÕâÑ ......
ÔÚÁ˽âJavaµÄͬ²½ÃØÃÜ֮ǰ£¬ÏÈÀ´¿´¿´JMM(Java Memory Model)¡£
Java±»Éè¼ÆΪ¿çƽ̨µÄÓïÑÔ£¬ÔÚÄÚ´æ¹ÜÀíÉÏ£¬ÏÔȻҲҪÓÐÒ»¸öͳһµÄÄ£ÐÍ¡£¶øÇÒJavaÓïÑÔ×î´óµÄÌصã¾ÍÊǷϳýÁËÖ¸Õ룬°Ñ³ÌÐòÔ±´ÓÍ´¿àÖнâÍѳöÀ´£¬²»ÓÃÔÙ¿¼ÂÇÄÚ´æʹÓú͹ÜÀí·½ÃæµÄÎÊÌâ¡£
¿ÉϧÊÀÊÂ×ܲ»¾¡ÈçÈËÒ⣬ËäÈ»JMMÉè¼ÆÉÏ·½±ãÁ˳ÌÐòÔ±£¬µ«ÊÇËüÔö¼ÓÁËÐéÄâ»úµÄ¸ ......