Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö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
 
Ò»¸ö¸É»î²»¶àµÄÀà¡£ÀàµÄά»¤ÐèÒª¶îÍâµÄ¿ªÏú


Ïà¹ØÎĵµ£º

JavaдÎļþÔ´Âë

import java.io.*;
public class FileWrite {
public static void main(String args[]) {
String outPut = "C:\\bin";
StringBuffer ab = new StringBuffer();
for(int i=6;i<=30;i++){
ab.append("http://www.test.com/joke/index_"+i+".htm\r\n&qu ......

±È½Ï Java Êý¾Ý¶ÔÏóºÍ EJB ¼¼Êõ

 JDO ¸ÅÊö
¡¡¡¡³¤¾ÃÒÔÀ´£¬Java Ó¦ÓóÌÐòºÍ³Ö¾ÃÊý¾Ý¹ÜÀíÖ®¼äµÄ¹ØϵһֱÊDz»ÈÝÒ×´¦ÀíµÄ¡£Ðí¶à³Ö¾ÃÐÔ»úÖÆÒÔ¹ØϵµÄ·½·¨¶ø²»ÊÇÃæÏò¶ÔÏó·½·¨´æ´¢Êý¾Ý¡£¼´£¬Êý¾Ý´æ´¢ÔÚÓÉ°üº¬×ֶεļǼ×é³ÉµÄ±íÖУ¬¶ø²»ÊǴ洢Ϊ×Ô°üº¬¶ÔÏó(ÕâЩ¶ÔÏóÓµÓÐÄÚ²¿Êý¾ÝºÍ¶ÔÆäËü¶ÔÏóµÄÒýÓ㬶øÆäËü¶ÔÏóÒ²ÓµÓÐÄÚ²¿Êý¾ÝºÍÒýÓÃ)¡£½«ÃæÏò¶ÔÏóµÄ±íʾת»»³ ......

Java¶ÁÈ¡ÎļþµÄ¼òµ¥´úÂë

ÕâÊÇÒ»¸ö¼òµ¥µÄ¶ÁÈ¡ÎļþµÄ´úÂ룬²¢ÊÔ×ŶÁÈ¡Ò»¸ölogÎļþ£¬ÔÙÊä³ö¡£
import java.io.*;
public class FileToString {
public static String readFile(String fileName) {
String output = "";

File file = new File(fileName);

if(file.exists()){
......

javaÄÚ´æ¹ÜÀí

1. JVMÄÚ´æ¶Î·ÖÅä¼°Æô¶¯²ÎÊý£º
J2EE·þÎñÆ÷µÄÄÚ´æ×é³É£º
? Java¶Ñ£ºÎÒÃǵijÌÐòºÍ¶ÔÏó¶¼ÔÚÕâ¸ö¶Ñ½øÐйÜÀí
? C¶Ñ£ºµ±ÒýÓõ½Ò»Ð©NativeµÄ¶ÔÏó£¬ÈçÍøÂç·ÃÎÊ¡¢OCI·½Ê½µÄÊý¾Ý¿âÁ¬½ÓµÈ¶¼ÔÚC¶ÑÀï½øÐйÜÀí
Java¶ÑµÄÃèÊö£º
ÈçÏÂͼ
 
ÄÚ´æÓÉ Perm ºÍ Heap ×é³É. ÆäÖÐ
Heap = {Old + young = { Eden , from, to } }
? You ......

Java native2ascii ¼òµ¥×ªÂë

native2ascii.exe ÊÇ Java µÄÒ»¸öÎļþתÂ빤¾ß£¬Êǽ«ÌØÊâ¸÷ÒìµÄÄÚÈÝ ×ªÎª ÓÃÖ¸¶¨µÄ±àÂë±ê×¼ÎÄÌåÐÎʽͳһµÄ±íÏÖ³öÀ´£¬Ëüͨ³£Î»ÓÚ JDK_home\bin Ŀ¼Ï£¬°²×°ºÃ Java SE ºó£¬¿ÉÔÚÃüÁîÐÐÖ±½ÓʹÓà native2ascii ÃüÁî½øÐÐתÂ룬ʾÀý£º
native2ascii -encoding 8859_1 c:\test.txt c:\temp.txt
½« test.txt ÎļþÄÚÈÝÓà 8859_1 × ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ