Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

Java³£¼ûµÄÎÊÌâ

1.Duplicated Code ´úÂëÖظ´¼¸ºõÊÇ×î³£¼ûµÄÒìζÁË¡£ËûÒ²ÊÇRefactoringµÄÖ÷ҪĿ±êÖ®Ò»¡£´úÂëÖظ´ÍùÍùÀ´×ÔÓÚcopy-and-pasteµÄ±à³Ì·ç¸ñ¡£ÓëËûÏà¶ÔÓ¦OAOOÊÇÒ»¸öºÃϵͳµÄÖØÒª±êÖ¾¡£ 2.Long method ËüÊÇ´«Í³½á¹¹»¯µÄ“ÒŶ¾”¡£Ò»¸ö·½·¨Ó¦µ±¾ßÓÐ×ÔÎÒ¶ÀÁ¢µÄÒâͼ£¬²»Òª°Ñ¼¸¸öÒâͼ·ÅÔÚÒ»Æð¡£ 3.Large Class ´óÀà¾ÍÊÇÄã°ÑÌ«¶àµÄÔðÈν»¸øÁËÒ»¸öÀà¡£ÕâÀïµÄ¹æÔòÊÇOne Class One Responsibility. 4.Divergent Change Ò»¸öÀàÀïÃæµÄÄÚÈݱ仯Âʲ»Í¬¡£Ä³Ð©×´Ì¬Ò»¸öСʱ±äÒ»´Î£¬Ä³Ð©Ôò¼¸¸öÔÂÒ»Äê²Å±äÒ»´Î£»Ä³Ð©×´Ì¬ÒòΪÕâ·½ÃæµÄÔ­Òò·¢Éú±ä»¯£¬¶øÁíһЩÔòÒòΪÆäËû·½ÃæµÄÔ­Òò±äÒ»´Î¡£ÃæÏò¶ÔÏóµÄ³éÏó¾ÍÊÇ°ÑÏà¶Ô²»±äµÄºÍÏà¶Ô±ä»¯Ïà¸ôÀë¡£°ÑÎÊÌâ±ä»¯µÄÒ»·½ÃæºÍÁíÒ»·½ÃæÏà¸ôÀë¡£ÕâʹµÃÕâЩÏà¶Ô²»±äµÄ¿ÉÒÔÖØÓá£ÎÊÌâ±ä»¯µÄÿ¸ö·½Ã涼¿ÉÒÔµ¥¶ÀÖØÓá£ÕâÖÖÏàÒì±ä»¯µÄ¹²´æʹµÃÖØÓ÷dz£À§ÄÑ¡£ 5.Shotgun Surgery ÕâÕýºÃºÍÉÏÃæÏà·´¡£¶Ôϵͳһ¸öµØ·½µÄ¸Ä±äÉæ¼°µ½ÆäËûÐí¶àµØ·½µÄÏà¹Ø¸Ä±ä¡£ÕâЩ±ä»¯Âʺͱ仯ÄÚÈÝÏàËƵÄ״̬ºÍÐÐΪͨ³£Ó¦µ±·ÅÔÚͬһ¸öÀàÖС£ 6.Feature Envy ¶ÔÏóµÄÄ¿µÄ¾ÍÊÇ·âװ״̬ÒÔ¼°ÓëÕâЩ״̬½ôÃÜÏà¹ØµÄÐÐΪ¡£Èç¹ûÒ»¸öÀàµÄ·½·¨Æµ·±ÓÃget ·½·¨´æÈ¡ÆäËûÀàµÄ״̬½øÐмÆË㣬ÄÇôÄãÒª¿¼ÂÇ°ÑÐÐΪÒƵ½É漰״̬ÊýÄ¿×î¶àµÄÄǸöÀà¡£ 7.Data Clumps ijЩÊý¾Ýͨ³£Ïñº¢×ÓÒ»Ñù³ÉȺÍæË££ºÒ»Æð³öÏÖÔںܶàÀàµÄ³ÉÔ±±äÁ¿ÖУ¬Ò»Æð³öÏÖÔÚÐí¶à·½·¨µÄ²ÎÊýÖУ¬ÕâЩÊý¾Ý»òÐíÓ¦¸Ã×Ô¼º¶ÀÁ¢ÐγɶÔÏó¡£ 8.Primitive Obsession ÃæÏò¶ÔÏóµÄÐÂÊÖͨ³£Ï°¹ßʹÓü¸¸öԭʼÀàÐ͵ÄÊý¾ÝÀ´±íʾһ¸ö¸ÅÄƩÈç¶ÔÓÚ·¶Î§£¬ËûÃÇ»áʹÓÃÁ½¸öÊý×Ö¡£¶ÔÓÚMoney£¬ËûÃÇ»áÓÃÒ»¸ö¸¡µãÊýÀ´±íʾ¡£ÒòΪÄãûÓÐʹÓöÔÏóÀ´±í´ïÎÊÌâÖдæÔڵĸÅÄÕâʹµÃ´úÂë±äµÄÄÑÒÔÀí½â£¬½â¾öÎÊÌâµÄÄѶȴó´óÔö¼Ó¡£ºÃµÄÏ°¹ßÊÇÀ©³äÓïÑÔËùÄÜÌṩԭʼÀàÐÍ£¬ÓÃС¶ÔÏóÀ´±íʾ·¶Î§¡¢½ð¶î¡¢×ª»¯ÂÊ¡¢ÓÊÕþ±àÂëµÈµÈ¡£ 9.Switch Statement »ùÓÚ³£Á¿µÄ¿ª¹ØÓï¾äÊÇOO µÄ´óµÐ£¬ÄãÓ¦µ±°ÑËû±äΪ×ÓÀà¡¢state»òstrategy. 10. Parallel Inheritance Hierarchies ²¢Ðеļ̳вã´ÎÊÇshotgun surgeryµÄÌØÊâÇé¿ö¡£ÒòΪµ±Äã¸Ä±äÒ»¸ö²ã´ÎÖеÄijһ¸öÀàʱ£¬Äã±ØÐëͬʱ¸Ä±äÁíÍâÒ»¸ö²ã´ÎµÄ²¢ÐÐ×ÓÀà¡£ 11. Lazy Class Ò»¸ö¸É»î²»¶àµÄÀà¡£ÀàµÄά»¤ÐèÒª¶îÍâµÄ¿ªÏú£¬Èç¹ûÒ»¸öÀà³Ðµ£ÁËÌ«ÉÙµÄÔðÈΣ¬Ó¦µ±Ïû³ýËü¡£ 12. Speculative Generality Ò»¸öÀàʵÏÖÁË´ÓδÓõ½µÄ¹¦ÄܺÍͨÓÃÐÔ¡£Í¨³£ÕâÑùµÄÀà»ò·½·¨Î¨Ò»µÄÓû§ÊÇtestcase.²»ÒªÓÌÔ¥£¬É¾³ýËü¡£ 13. Temporary Field Ò»¸ö¶ÔÏóµÄÊôÐÔ¿ÉÄÜ


Ïà¹ØÎĵµ£º

dzÎöJava·ºÐÍ

±íÃæÉÏ¿´ÆðÀ´£¬ÎÞÂÛÓï·¨»¹ÊÇÓ¦ÓõĻ·¾³£¨±ÈÈçÈÝÆ÷Àࣩ£¬·ºÐÍÀàÐÍ£¨»òÕß·ºÐÍ£©¶¼ÀàËÆÓÚ C++ ÖеÄÄ£°å¡£µ«ÊÇÕâÖÖÏàËÆÐÔ½öÏÞÓÚ±íÃ棬Java ÓïÑÔÖеķºÐÍ»ù±¾ÉÏÍêÈ«ÔÚ±àÒëÆ÷ÖÐʵÏÖ£¬ÓɱàÒëÆ÷Ö´ÐÐÀàÐͼì²éºÍÀàÐÍÍƶϣ¬È»ºóÉú³ÉÆÕͨµÄ·Ç·ºÐ͵Ä×Ö½ÚÂë¡£ÕâÖÖʵÏÖ¼¼Êõ³ÆΪ²Á³ý£¨erasure£©£¨±àÒëÆ÷ʹÓ÷ºÐÍÀàÐÍÐÅÏ¢±£Ö¤ÀàÐÍ°²È«£¬È»ºóÔ ......

ÈçºÎÌá¸ß×Ô¼ºµÄJava±à³Ìˮƽ

       1.
ÔúʵµÄ»ù´¡¡£Êý¾Ý½á¹¹¡¢ÀëÉ¢Êýѧ¡¢±àÒëÔ­Àí£¬ÕâЩÊÇËùÓмÆËã»ú¿ÆѧµÄ»ù´¡£¬Èç¹û²»ÕÆÎÕËûÃÇ£¬ºÜÄÑд³ö¸ßˮƽµÄ³ÌÐò¡£¾ÝÎҵĹ۲죬ѧ¼ÆËã»úרҵµÄÈ˱ÈѧÆäËû
רҵµÄÈ˸üÄÜд³ö¸ßÖÊÁ¿µÄÈí¼þ¡£³ÌÐòÈËÈ˶¼»áд£¬µ«µ±Äã·¢ÏÖдµ½Ò»¶¨³Ì¶ÈºÜÄÑÔÙÌá¸ßµÄʱºò£¬¾ÍÓ¦¸ÃÏëÏëÊDz»ÊÇÒª»Ø¹ýÍ·À´ ......

final ÔÚjavaÖеÄ×¢Òâµã

×¢ÒâÊÂÏîÂýÂý»ýÀÛ
final À಻¿É±»¼Ì³Ð£¬Ò²²»ÄÜÓÐ×ÓÀà¡£
final class Book{}
//class ComBook extends Book{}     Õ⽫±àÒëʧ°Ü£¬ÒòΪBookÀ಻¿É±»¼Ì³Ð¡£
final·½·¨²»¿É±»¸Äд
class Book{
          final void show£¨£©{System.out.println("Book ......

JavaÖеÄÉÖÆÓëdz¸´ÖÆ

1£®Ç³¸´ÖÆÓëÉÖƸÅÄî
¢Ådz¸´ÖÆ£¨Ç³¿Ë¡£©
±»¸´ÖƶÔÏóµÄËùÓбäÁ¿¶¼º¬ÓÐÓëÔ­À´µÄ¶ÔÏóÏàͬµÄÖµ£¬¶øËùÓеĶÔÆäËû¶ÔÏóµÄÒýÓÃÈÔȻָÏòÔ­À´µÄ¶ÔÏó¡£»»ÑÔÖ®£¬Ç³¸´Öƽö½ö¸´ÖÆËù¿¼ÂǵĶÔÏ󣬶ø²»¸´ÖÆËüËùÒýÓõĶÔÏó¡£
 
¢ÆÉÖÆ£¨Éî¿Ë¡£©
±»¸´ÖƶÔÏóµÄËùÓбäÁ¿¶¼º¬ÓÐÓëÔ­À´µÄ¶ÔÏóÏàͬµÄÖµ£¬³ýÈ¥ÄÇЩÒýÓÃÆäËû¶ÔÏóµÄ±äÁ¿¡ ......

CµÄenum struct ÒÔ¼° JavaµÄenum

 ÔÚcÖÐenumµÄʹÓúÍstructºÜÏñ
enum name{
a,b,c
};

 
struct name{
int a;
int b;
char c;
};

 
or
 
typedef struct{
int a;
int b;
char c;
}Name;

ʹÓõÄʱºò¶¼ÒªÏÈÉùÃ÷±äÁ¿
 
enum name n1,n2,n3;
n1=a;
n2=b;
n3=enum name(3-1);
struct name sn1,sn2;
s ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ