Java±àÂë¹æ·¶£¨The Elements of Java Style£©
Genaral Principles Ò»°ãÔ¼¶¨
1.Adhere to the style
of the original.
±£³Ö×î³õµÄÑùʽ¡£
2.Adhere to the Principle of Least
Astonishment.
×ñÊØ×îС¾ªÆæÔÔò¡£
3.Do it right the first time.
µÚÒ»´Î¾ÍÓ¦µ±×öºÃ¡£
4.Document any deviations.
¶ÔÓÚÈκα³Àë¶¼Ó¦µ±Îĵµ×¢ÊÍ¡£
Formatting
Conventions ¸ñʽԼ¶¨
5.Indent nested code.
Ô¼ÊøÇ¶Ì×´úÂë¡£
6.Break up long lines.
²ð·Ö³¤ÐС£
7.Include white space.
°üº¬¿Õ¸ñ¡£
8.Do not use "hard" tabs.
²»ÒªÊ¹ÓÃtab¼ü¡£
Naming
Conventions ÃüÃûÔ¼¶¨
9.Use meaningful names.
ʹÓÃÓÐÒâÒåµÄÃû³Æ¡£
10.Use familiar names.
ʹÓÃÊìϤµÄÃû³Æ¡£
11.Question excessively
long names.
²»ÒªÊ¹Óùý³¤µÄÃû³Æ¡£
12.Join the vowel generation.
¼ÓÈëÔªÒô×Öĸ¡£
13.Capitalize only the first letter in acronyms.
Ö»¶Ô¼ò³ÆµÄµÚÒ»¸ö×Öĸ´óд¡£
14.Do not use names that differ only in case.
²»ÒªÊ¹ÓÃÖ»ÒÀÀµÓÚ´óСдÀ´Çø·ÖµÄÃû³Æ¡£
Package Names °üÃüÃû
15.Use
the reversed, lowercase form of your organization's Internet domain
name as the root qualifier for your package names.
²ÉÓÃÄã×éÖ¯µÄInternetÓòÃû
µÄ·´×ª¡¢Ð¡Ð´ÐÎʽ×÷Ϊ°üÃû³ÆµÄ¸ùÏÞ¶¨´Ê¡£
16.Use a single, lowercase word as the root
name of each package.
ʹÓÃÒ»¸öΨһµÄСдµ¥´Ê×÷Ϊÿ¸ö°üµÄ¸ùÃû³Æ¡£
17.Use the
same name for a new version of a package, but only if that new version
is still binary compatible with the previous versin, otherwise, use a
new name.
Ö»Óе±°üµÄа汾ÈÔÈ»Óë¾É°æ±¾¼æÈÝʱ£¬¶ÔÓÚ°üµÄа汾ʹÓÃÏàͬµÄÃû³Æ£¬·ñÔòʹÓÃÐÂÃû³Æ¡£
Type Names ÀàÐÍÃüÃû
18.Capitalize the first letter of
each word that appears in a class or interface name.
¶ÔÓÚÀàºÍ½Ó¿ÚÃû³ÆÖ»¶Ôÿ¸öµ¥´Ê
µÄµÚÒ»¸ö×Öĸ´óд¡£
Class Names ˈ̟̞
19.Use
nouns when naming classes.
ʹÓÃÃû´ÊÀ´ÃüÃûÀà¡£
20.Pluralize the
names of classes that group related attributes,
Ïà¹ØÎĵµ£º
java 23ÖÖÉè¼ÆÄ£Ê½£¬Ò»°ãÇé¿öÏ£¬³£ÓõÄÓÐÄÄЩ?
¹¤³§Ä£Ê½£¬ ¹¤³§·½·¨Ä£Ê½£¬µ¥Àýģʽ£¬ Íâ¹Û£¨Facade£©Ä£Ê½£¬ ¹Û²ìÕߣ¨Observer£©Ä£Ê½£¬ÇŽӣ¨Bridge£©Ä£Ê½¶¼ÊDZȽϳ£Óõ쬲»Í¬µÄÏîÄ¿Óв»Í¬µÄÉè¼Æ·½Ïò£¬¿ÉÒԲο¼µÄÉè¼ÆÄ£Ê½Ò²²»¾¡Ïàͬ£¬Ã»Óж¨Êý£¬Ö»ÊÇÉÏÃæÕ⼸¸öģʽÓõıȽ϶àһЩ¡£
ÆäËûµÄÄ ......
×¢£º1.·½·¨µÄ²ÎÊý length ÊÇÉú³ÉµÄËæ»úÊýµÄ³¤¶È¡£
2. Ö»ÏëÒª´óдµÄ×Öĸ ¿ÉÒÔʹ int choice =65£» Ö»ÏëҪСдµÄ×Öĸ£¬¾Í int choice =97£»
import java.util.Random;
public String getCharAndNumr(int length)
{
String val = " ......
Hibernate Ö®¸¸ Gavin King[1]½¨Ò鿪·¢ÕßÉý¼¶µ½ Java EE 6 ƽ̨£¬²¢Ö¸³ö£¬Ä¿Ç°¸÷ÖÖ²»Ô¸ÒâÉý¼¶µÄ¹ÛµãÆäʵÊÇûÓиù¾ÝµÄ¡£
Java EE 6 ·¢²¼ºó£¬ÎÒ¿´µ½Á˺ܶ෴¶ÔÉý¼¶µ½ÐÂÆ½Ì¨µÄ¹Ûµã¡£ÕâЩ·´¶Ô¹Ûµã´ó¶àÊÇÓÉ Tomcat / Jetty ÒÔ¼°Ò»Ð©¿ªÔ´¿ò¼Ü£¨ÀýÈç Hibernate Óë Spring£©µÄʹÓÃÕßÌá³ö¡£
µ±È»£¬Ñ¡Ôñ·Ç±ê×¼¡¢¿ªÔ´¼¼ÊõÓкܶàºÃ´¦¡ ......
ÒÔÏÂÄÚÈÝÕª×Ôjavaº¯ÊýµÄ²ÎÊý´«µÝºÍStringÀàÐÍ http://www.blogjava.net/thuixy/archive/2009/06/06/280302.html
˵ÍêÁËjavaµÄStringÀàÐÍ£¬ÎÒÃÇ×îºó¿´¿´javaº¯Êý²ÎÊýµÄ´«µÝ£¬µ½µ×ÊÇÖµ´«µÝ»¹ÊÇÒýÓô«µÝÄØ£¿Ò»°ãµÄ˵·¨ÊǶÔÓÚ»ù±¾ÀàÐͱÈÈçint¡¢charÊÇÖµ´«µÝ£¬¶ÔÓÚ¶ÔÏóÀàÐÍÊÇÒýÓô«µÝ¡£ÕâÖÖ˵·¨Ã»´í£¬µ«ÊÇÇë¿´ÏÂÃæµÄÀý×Ó£º
Str ......