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

javaÃüÃû¹æ·¶_±à³Ì¹ßÀýºÍ´úÂë·¶Àý

1.       ±à³Ì¹ßÀý(Programming Practices)
9.1  Ìṩ¶ÔʵÀýÒÔ¼°Àà±äÁ¿µÄ·ÃÎÊ¿ØÖÆ(Providing Access to Instance and Class Variables)
ÈôûÓÐ×ã¹»ÀíÓÉ£¬²»Òª°ÑʵÀý»òÀà±äÁ¿ÉùÃ÷Ϊ¹«ÓС£Í¨³££¬ÊµÀý±äÁ¿ÎÞÐèÏÔʽµÄÉèÖÃ(set)ºÍ»ñÈ¡(gotten)£¬Í¨³£Õâ×÷Ϊ·½·¨µ÷ÓõıßԵЧӦ (side effect)¶ø²úÉú¡£
Ò»¸ö¾ßÓй«ÓÐʵÀý±äÁ¿µÄÇ¡µ±Àý×Ó£¬ÊÇÀà½ö×÷ΪÊý¾Ý½á¹¹£¬Ã»ÓÐÐÐΪ¡£Ò༴£¬ÈôÄãҪʹÓÃÒ»¸ö½á¹¹(struct)¶ø·ÇÒ»¸öÀà(Èç¹ûjavaÖ§³Ö½á¹¹µÄ»°)£¬ÄÇô°ÑÀàµÄʵÀý±äÁ¿ÉùÃ÷Ϊ¹«ÓÐÊǺÏÊʵġ£
9.2  ÒýÓÃÀà±äÁ¿ºÍÀà·½·¨(Referring to Class Variables and Methods)
±ÜÃâÓÃÒ»¸ö¶ÔÏó·ÃÎÊÒ»¸öÀàµÄ¾²Ì¬±äÁ¿ºÍ·½·¨¡£Ó¦¸ÃÓÃÀàÃûÌæ´ú¡£ÀýÈ磺
classMethod(); //OK
AClass.classMethod(); //OK
anObject.classMethod(); //AVOID!
9.3  ³£Á¿(Constants)
λÓÚforÑ­»·ÖÐ×÷Ϊ¼ÆÊýÆ÷ÖµµÄÊý×Ö³£Á¿£¬³ýÁË-1,0ºÍ1Ö®Í⣬²»Ó¦±»Ö±½ÓдÈë´úÂë¡£
9.4  ±äÁ¿¸³Öµ(Variable Assignments)
±ÜÃâÔÚÒ»¸öÓï¾äÖиø¶à¸ö±äÁ¿¸³ÏàͬµÄÖµ¡£ËüºÜÄѶÁ¶®¡£ÀýÈ磺
fooBar.fChar = barFoo.lchar = 'c'; // AVOID!
²»Òª½«¸³ÖµÔËËã·ûÓÃÔÚÈÝÒ×ÓëÏàµÈ¹ØϵÔËËã·û»ìÏýµÄµØ·½¡£ÀýÈ磺
if (c++ = d++) { // AVOID! (Java disallows)
...
}
Ó¦¸Ãд³É
if ((c++ = d++) != 0) {
...
}
²»ÒªÊ¹ÓÃÄÚǶ(embedded)¸³ÖµÔËËã·ûÊÔͼÌá¸ßÔËÐÐʱµÄЧÂÊ£¬ÕâÊDZàÒëÆ÷µÄ¹¤×÷¡£ÀýÈ磺
d = (a = b + c) + r; // AVOID!
Ó¦¸Ãд³É
a = b + c;
d = a + r;
9.5  ÆäËü¹ßÀý(Miscellaneous Practices)
9.5.1        Ô²À¨ºÅ(Parentheses)
Ò»°ã¶øÑÔ£¬ÔÚº¬ÓжàÖÖÔËËã·ûµÄ±í´ïʽÖÐʹÓÃÔ²À¨ºÅÀ´±ÜÃâÔËËã·ûÓÅÏȼ¶ÎÊÌ⣬ÊǸöºÃ·½·¨¡£¼´Ê¹ÔËËã·ûµÄÓÅÏȼ¶¶ÔÄã¶øÑÔ¿ÉÄܺÜÇå³þ£¬µ«¶ÔÆäËûÈËδ±ØÈç´Ë¡£Äã²»ÄܼÙÉè±ðµÄ³ÌÐòÔ±ºÍÄãÒ»ÑùÇå³þÔËËã·ûµÄÓÅÏȼ¶¡£
if (a == b && c == d) // AVOID!
if ((a == b) && (c == d)) // RIGHT
9.5.2        ·µ»ØÖµ(Returning Values)
Éè·¨ÈÃÄãµÄ³ÌÐò½á¹¹·ûºÏÄ¿µÄ¡£ÀýÈ磺
if (booleanExpression) {
return true;
} else {
return false;
}
Ó¦¸Ã´úÖ®ÒÔÈçÏ·½·¨£º
return booleanExpression;
ÀàËƵأº
if (condition) {
return x;
}
return y;
Ó¦¸Ãд×ö£º
return (condition ? x : y);
9.5.3   &


Ïà¹ØÎĵµ£º

java¹ØÓÚ23ÖÖÉè¼Æģʽ֮ÅÝMM°æ£¨ÍƼö£©[ת]


´´½¨ÐÍģʽ
1¡¢FACTORY——×·MMÉÙ²»ÁËÇë³Ô·¹ÁË£¬Âóµ±À͵ļ¦³áºÍ¿ÏµÂ»ùµÄ¼¦³á¶¼ÊÇMM°®³ÔµÄ¶«Î÷£¬ËäÈ»¿ÚζÓÐËù²»Í¬£¬µ«²»¹ÜÄã´øMMÈ¥Âóµ±ÀÍ»ò¿ÏµÂ»ù£¬Ö»¹ÜÏò·þÎñԱ˵“À´Ëĸö¼¦³á”¾ÍÐÐÁË¡£Âóµ±ÀͺͿϵ»ù¾ÍÊÇÉú²ú¼¦³áµÄFactory
¹¤³§Ä£Ê½£º¿Í»§ÀàºÍ¹¤³§Àà·Ö¿ª¡£Ïû·ÑÕßÈκÎʱºòÐèҪijÖÖ²úÆ·£¬Ö»ÐèÏò¹ ......

JAVAÕýÔòÖÐÎÄÆ¥Åä

1¡¢Æ¥ÅäË«ÒýºÅ¼äÄÚÈÝ£º
Java´úÂë
public
 
void
 test1() {  
    // Æ¥ÅäË«ÒýºÅ¼äÄÚÈÝ
  
    String pstr = "\"([^\"]+)\""
;  
    Pattern  ......

Siebel Java Data Bean: Query first record

Following codes will show you how to query the first record from DB using Java Data Bean. package com ;
import com.siebel.data.*;
import com.siebel.data.SiebelException;
public class DataBeanDemo {
private SiebelDataBean m_dataBean = null;
private SiebelBusObject m_busObject = null;
......

java±àÂë¹æ·¶_Ëõ½øºÍ×¢ÊÍ

1.       Ëõ½øÅÅ°æ(Indentation)
4¸ö¿Õ¸ñ³£±»×÷ΪËõ½øÅÅ°æµÄÒ»¸öµ¥Î»¡£Ëõ½øµÄÈ·ÇнâÊͲ¢Î´Ïêϸָ¶¨(¿Õ¸ñ vs. ÖƱí·û)¡£Ò»¸öÖƱí·ûµÈÓÚn¸ö¿Õ¸ñ(ÊÓ¾ßÌåµÄ±à¼­Æ÷¶ø¶¨£¬EclipseĬÈÏÒ»¸öÖƱí·ûΪ4¸ö×Ö·û)¡£
3.1    Ð㤶È(Line Length)
¾¡Á¿±ÜÃâÒ»Ðеij¤¶È³¬¹ý80¸ö×Ö·û£¬ÒòΪºÜ ......

java±àÂë¹æ·¶_¿Õ°×ºÍÃüÃû¹æ·¶

1.       ¿Õ°×(White Space)
7.1  ¿ÕÐÐ(Blank Lines)
¿ÕÐн«Âß¼­Ïà¹ØµÄ´úÂë¶Î·Ö¸ô¿ª£¬ÒÔÌá¸ß¿É¶ÁÐÔ¡£ÏÂÁÐÇé¿öÓ¦¸Ã×ÜÊÇʹÓÃÁ½¸ö¿ÕÐУº
·Ò»¸öÔ´ÎļþµÄÁ½¸öƬ¶Î(section)Ö®¼ä
·ÀàÉùÃ÷ºÍ½Ó¿ÚÉùÃ÷Ö®¼ä
ÏÂÁÐÇé¿öÓ¦¸Ã×ÜÊÇʹÓÃÒ»¸ö¿ÕÐУº
·Á½¸ö·½·¨Ö®¼ä
··½ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ