锘??xml version="1.0" encoding="utf-8" standalone="yes"?> http://fedoranews.org/contributors/stanton_finley/fc3_note/ 6. Reusing Classes 鍏充簬娓呯悊鍔ㄤ綔錛岃娉ㄦ剰鐨勬槸欏哄簭錛氶鍏堟墽琛屽綋鍓嶇被鐨勬墍鏈夋竻鐞嗗姩浣滐紙鍏朵腑嬈″簭鍜岀敓鎴愭搴忕浉鍙嶏級(jí)錛岃屽悗鍐嶈皟鐢╞ase class鐨勬竻鐞嗗嚱鏁般傚甯︿竴鍙ワ紝闄や簡(jiǎn)鍐呭瓨錛屾渶濂芥案榪滀笉瑕佺浉淇″瀮鍦懼洖鏀舵満鍒躲?/P>
Final data Bruce鍦ㄨ繖閮ㄥ垎璇達(dá)細(xì)Java涓璮inal淇グ瀵逛簬鍩烘湰綾誨瀷鍜屽璞″紩鐢紙object reference錛夎岃█錛屾剰涔夋槸涓嶅悓鐨勩傜敤浜庡熀鏈被鍨嬫椂錛宖inal璁﹙alue錛堟暟鍊鹼級(jí)淇濇寔涓嶅彉銆傜敤浜巓bject reference鏃訛紝final璁﹔eference淇濇寔涓嶅彉錛屼絾瀵硅薄鏈韓鐨勫唴瀹瑰嵈鏄彲浠ユ洿鍔ㄧ殑鎭躲侸ava騫舵湭鎻愪緵璁╀換浣曞璞′繚鎸佷笉鍙樼殑鏈哄埗錛岃櫧鐒跺彲浠ヨ嚜宸辯紪鍐欏叿鏈変繚鎸佷笉鍙樻晥鏋滅殑class銆傜壒鍒彁閱掞紝array涔熸槸瀵硅薄銆?
Tips 1錛?FONT face="Arial, Helvetica, sans-serif" size=2>EMF MUST BE INSTALLED PRIOR TO USING LOMBOZ.
Using google, you'll find many article about the Installation of Lomboz. But many of them didn't talk about the EMF. I haven't used Lomboz 2.X on eclipse 2.X, perhaps that old version didn't need EMF. Now, Lomboz v3.x uses models based on EMF. So EMF must be installed with Lomboz.
Tips 2: IT IS VERY IMPORTANT THAT YOU CLICK APPLY
Your change will be taken into account only after this. It's very strange -_-b
BTW, the speed for exploring websites abroad is very very slow these days. For example , eclipse.org, sourceforge.net and so on. My ISP is Shanghai's Oriental Cable Network.
]]>
]]>
涓句袱涓緥瀛愶細(xì)
浣犳槸鍚︽湁鏃跺欒涓浜涚綉绔欏尓澶鋒墍鎬濈殑灝忓瓧浣撴墍鍥版壈錛烮E鎻愪緵鐨勬煡鐪?-銆夊瓧浣撳ぇ灝忓湪緇濆ぇ澶氭暟鍦哄悎涓嬮兘鏄棤鐢ㄧ殑 :( firefox閲岋紝浣犲彧闇瑕佽交鏉劇殑ctrl + +/- 錛屽搱鍝堬紝鍐嶄篃涓嶄細(xì)鏈変粈涔堝皬瀛椾綋鐪嬩笉娓呮鍦版伡浜轟簨鎯呬簡(jiǎn)銆?br>
鍘熸湰blogjava.net浣跨敤鐨刾ost edit鐨勪唬鐮佸祵鍏ヤ嬌鐢―IV錛屽湪澶勭悊 /* */ 娉ㄩ噴鏃訛紝緙╂斁鐨勬寜閽湪IE涓嬩笉鑳芥甯稿伐浣溿傜幇鍦ㄥ湪firefox閲屽彲浠ヤ簡(jiǎn)銆?br>
褰撶劧錛岀敱浜庡吋瀹歸棶棰橈紝濡傛灉鍙嬌鐢╢irefox錛屽湪璁塊棶鐩稿綋涓閮ㄥ垎緗戠珯鏃惰繕鏄細(xì)鍙戠敓闂鐨勩傛墍浠ワ紝鍙屽紑鍟娿?br>
BTW錛岄『渚塊棶涓涓嬶紝鏈変漢鐭ラ亾浠涔堢敤java鍐欑殑浼樼blog紼嬪簭涔堬紵 濡傜幇鍦ㄨ繖鏍蜂嬌鐢?text鎬昏寰楁湁浜涘鎬紝鍛靛懙銆傚皾璇曡繃 blojsom 錛屼笉鐭ラ亾涓轟粈涔堬紝鎴戝緇堟棤娉曟垚鍔熺殑璁╁叾浣跨敤mysql浣滀負(fù)鏁版嵁搴撱?鑰屼笖錛屽湪寤虹珛catalog鏃訛紝涔熸繪槸鍙戠敓濂囨殑緇撴灉銆備緥濡傦紝鍚屽悕catalog,post鏃犳硶褰掑叆鏌愪釜catalog
]]>
http://www.mjmwired.net/resources.php?PHPSESSID=e63a1fe2caddc29e491f26c285189cdf
]]>
Java緙栬瘧鍣ㄥ茍涓嶄細(xì)緇欎換浣時(shí)eference浜х敓緙虹渷瀵硅薄錛岃繖鏍峰氨閬垮厤浜?jiǎn)澶у鏁版儏鍐典笅鐨勪笉蹇呰鐨勮礋鎷呫傚垵濮嬪寲闇瑕佺殑瀵硅薄鍙互鍦ㄤ互涓嬪湴鐐癸細(xì)
錛戯紝瀵硅薄瀹氫箟澶勩傜敱浜庣被鍒濆鍖栭『搴忕殑瑙勫垯錛岃繖鏍峰仛鍙互淇濊瘉浠ユ鏂規(guī)硶鍒濆鍖栫殑瀵硅薄灝嗕細(xì)鍦ㄦ瀯閫犲嚱鏁拌璋冪敤鍓嶅畬鎴愬垵濮嬪寲銆?
錛掞紝鏋勯犲嚱鏁板唴閮ㄣ?
錛擄紝褰撻渶瑕佷嬌鐢ㄨ瀵硅薄鏃訛紝榪欑鏂瑰紡琚О涓猴紙緙撳紡鍒濆鍖栵級(jí)lazy initialization銆傚鏋滀竴涓璞″茍闈炴繪槸蹇呴』錛岄偅涔堣繖縐嶆柟寮忓彲浠ュ噺灝戦澶栬礋鎷呫?
鎴戣璇寸殑鏄紝鎴戞病鍙戠幇final鍦ㄥ熀鏈被鍨嬩笌瀵硅薄寮曠敤鐨勬剰涔夋湁浣曚笉鍚屻俧inal閮芥槸璁╀袱鑰呯殑value淇濇寔涓嶅彉錛屽熀鏈被鍨嬬殑value灝辨槸瀵瑰簲鐨勬暟鍊兼垨鑰卋ool鍊箋傝屽璞″紩鐢ㄧ殑value鍦ㄧ悊瑙d笂鍙互瑙i噴涓烘寚鍚憃bject鐨勫湴鍧銆傚綋鐒?dòng)灱寴q欓噷浼間箮瀵逛簬Java鐨勫簳灞傚疄鐜板仛浜?jiǎn)鍋囪鑰屾垜紜疄涔熸病緇嗙┒榪嘕ava濡備綍瀹炵幇object reference鐨勩備絾鏄紝灝盝ava璇硶鍙?qiáng)鎴戜釜錆h鐨勪綋浼?xì)鑰岃█錛屾垜瑙夊緱榪欐槸寰堝ソ鐨勪竴縐嶇悊瑙f柟寮忋?
Blank finals
Java鍏佽鎶婃暟鎹垚鍛樺0鏄庝負(fù)final鍗翠笉璧嬩簣鍒濆鍊箋傚綋鐒?dòng)灱宖inal淇グ鐨勬暟鎹垚鍛樺繀欏誨湪鍏惰浣跨敤鍓嶅畬鎴愬垵濮嬪寲錛岃繖涓鐐圭敱緙栬瘧鍣ㄤ繚璇併傝繖涓壒鎬ц鎴戜滑鍙互鎶婃煇涓暟鎹垚鍛樺0鏄庝負(fù)final鍏鋒湁涓嶅彉鐨勭壒鎬э紝鍗村湪姣忎釜瀵硅薄涓負(fù)涓嶅悓鐨勫箋?
Final arguments
Java涓繕鍙互鎶妋ethod鐨刟rguments澹版槑涓篺inal錛屾剰涔変笉鍙橈紝鍙槸涓嶅彉鐗規(guī)х殑鑼冨洿浠呬粎鍦ㄦmethod鍐呫傚浜庡璞″紩鐢紝鍗蟲(chóng)槸鍦ㄦmethod鍐呮嫢鏈夋瀵硅薄鐨勪竴涓笉鍙彉鏇寸殑寮曠敤錛岃屼笉褰卞搷姝ゅ璞″瓨鍦ㄥ叾浠栭潪final鐨勫紩鐢ㄣ?
Final method
鏈変袱涓師鍥犳妸涓涓猰ethod淇グ鎴恌inal銆傜涓錛屽浜庣被A涓殑鏌愪釜method錛屼綘甯屾湜鍦ㄧ被A鎵鏈夊瓙綾諱腑姝ゆ柟娉曠殑琛ㄧ幇涓嶅彉錛屽嵆姝ゆ柟娉曚笉鍙瑕嗗啓錛坥verriding錛夈傜浜岋紝澶勪簬鏁堢巼鑰冭檻錛屽洜涓虹紪璇戝櫒浼?xì)灏濊瘯鎶婁笉澶暱鐨刦inal method鏀逛負(fù)inner method銆傝孊ruce Eckel寤鴻鎴戜滑涓嶈鐩鎬俊緙栬瘧鍣ㄧ殑鏅哄晢錛屽彧鍦ㄧ‘瀹炲浜庤璁$殑鑰冭檻闇瑕佹椂錛屾墠鎶妋ethod淇グ涓篺inal銆?
final & private
private鐨刴ethod瀵逛簬瀛愮被鏄笉鍙鐨勶紝鑷劧涔熸棤娉曡鍐欙紙overriding錛夈備技涔庯紝private闅愬惈浜?jiǎn)final錛熷鏋滀竴涓嚱鏁板凡緇忔槸private錛屼技涔巉inal淇グ涓庡惁閮芥棤鍏崇揣瑕侊紵
棣栧厛錛岃繖涓や釜鍋囪錛屽墠鑰呴敊璇紝鍚庤呮紜傚洜涓簆rivate鐨刴ethod瀵逛簬瀛愮被鏄笉鍙鐨勶紝 鎵浠ュ浜庡瓙綾昏岃█濡傛鐨勫嚱鏁板氨濡傚悓鏄埗綾諱腑鐨勪竴孌墊櫘閫氫唬鐮併傚鏋滄鏃跺湪瀛愮被涓0鏄庝竴涓笌鐖剁被涓殑private method鍚屽悕鐨勫嚱鏁幫紝緙栬瘧鍣ㄦ槸鍏佽鐨勩傜劧鑰岋紝娉ㄦ剰錛屾鏃跺彧鏄湪榪欎釜緇ф壙浣撶郴涓姞鍏ヤ簡(jiǎn)涓涓柊鍑芥暟鑰屽凡錛屽茍闈炴槸涓涓鍐欍傚洜涓鴻鍐欙紙overriding錛夌殑鍓嶆彁鏄紝琚鍐欑殑鍑芥暟鏄彲瑙侊紝鏄埗綾葷殑瀵瑰鐨勭晫闈€傝嚦浜庡private鍑芥暟鍐嶅姞final淇グ錛岀紪璇戝櫒鏄厑璁哥殑銆備絾姣棤鎰忎箟錛屽洜涓簆rivate鐨勫嚱鏁板浜庡瓙綾諱笉鍙錛屾墍浠ヤ篃灝辨棤闇澹版槑鏄惁鍏佽瑕嗗啓(overriding)銆?
涓嬮潰榪樻槸璐存浠g爜鏉ヨВ閲婏細(xì) /**//*
* Created on 2004-11-30
*
* TODO To change the template for this generated file go to
* Window - Preferences - Java - Code Style - Code Templates
*/
package com.smilereader.test;
/**//**
* @author Sinbadblue Kong
*
* TODO To change the template for this generated type comment go to
* Window - Preferences - Java - Code Style - Code Templates
*/
class Treasure
{
private final void f()
{
System.out.println("Treasure.f()");
}
private void g()
{
System.out.println("Treasure.g()");
}
final void e()
{
System.out.println("Treasure.e()");
}
}
/**//*
* Created on 2004-12-5
*
* TODO To change the template for this generated file go to
* Window - Preferences - Java - Code Style - Code Templates
*/
package com.smilereader.test;
/**//**
* @author Sinbadblue Kong
*
* TODO To change the template for this generated type comment go to
* Window - Preferences - Java - Code Style - Code Templates
*/
class Gemstone extends Treasure
{
// add a new method Gemstone.f(), it isn't an overriding
public final void f()
{
System.out.println("Gemstone.f()");
}
// add a new method Gemstone.g(), it isn't an overriding
public void g()
{
System.out.println("Gemstone.g()");
}
//can't overriding Treasure.e()
// public void e(){
// System.out.println("Gemstone.e()");
// }
}
鎴戣寰桱ava鐨勭紪璇戝櫒鍦ㄦ澶勭殑澶勭悊涓嶅お鍚堥傦紝瀹規(guī)槗瀵艱嚧娣鋒穯銆傚鏋滃浜巔rivate 涓?final淇グ鍋氫簰鏂ュ鐞嗭紝鎴戜釜浜鴻寰椾細(xì)鏄瘮杈冨悎閫傜殑鍙堝鏄撶悊瑙g殑鏂瑰紡銆?
]]>
The Open Closed Principle (OCP) states that we should be able to add new features to our system without having to modify our set of preexisting classes. The following Class Diagram shows that how to design the relationship between the classes so as to adhere the OCP under certain circumstance:
The User class has a relationship to the UserType abstract class. The simple sample design shows that it adheres one of the tenets of OCP:鈥渢o reduce the coupling between classes to the abstract level. Instead of creating relationships between two concrete classes, we create relationships between a concrete and an abstract class ,or in Java, between a concrete class and an interface.
Principles should be reminded again and again. ^_^