




版權(quán)說(shuō)明:本文檔由用戶(hù)提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
1、編輯編輯pptLishoulin,PTC普聯(lián)軟件普聯(lián)軟件(中國(guó)中國(guó))有限公司有限公司2011年度入職培訓(xùn),濟(jì)南燕山學(xué)院年度入職培訓(xùn),濟(jì)南燕山學(xué)院PANSOFTJULY,2011編碼規(guī)范編碼規(guī)范(JAVA版版)JAVA之路之路JAVA開(kāi)發(fā)人員編碼規(guī)范開(kāi)發(fā)人員編碼規(guī)范Technology Team Progress編輯編輯ppt編輯編輯ppt編輯編輯ppt編輯編輯ppt編輯編輯ppt編輯編輯pptcom.pansoft.public class JRaster;class JImageSprite interface IRasterDelegate;interface IStoring; 編輯編輯
2、pptrun();runFast();getBackground(); 編輯編輯pptchar c;int i;float myWidth; 編輯編輯pptint mEmployeeId;String mName;Customer mCustomer; 編輯編輯pptpublic void callMe(int pAge, String pName)編輯編輯pptstatic final int MIN_WIDTH = 4;static final int MAX_WIDTH = 999;static final int GET_THE_CPU = 1; 編輯編輯ppt/* * Classna
3、me * * Version information * * Date * * Copyright notice */編輯編輯ppt package java.awt; import java.awt.peer.CanvasPeer; 編輯編輯ppt編輯編輯ppt編輯編輯ppt編輯編輯ppt編輯編輯ppt編輯編輯ppt編輯編輯ppt編輯編輯ppt編輯編輯ppt /正常斷行 someMethod(int anArg, Object anotherArg, String yetAnotherArg, Object andStillAnother) . /若斷行后很靠右,則下面行可以縮進(jìn)8個(gè)空格,看
4、上去更美 觀。 private static synchronized horkingLongMethodName(int anArg, Object anotherArg, String yetAnotherArg, Object andStillAnother) . 編輯編輯ppt /縮小過(guò)少,不易閱讀1 if (condition1 & condition2)2 | (condition3 & condition4)3 |!(condition5 & condition6) 4 doSomethingAboutIt(); /這一行不易閱讀識(shí)別 /較多的縮進(jìn),便于閱
5、讀5 if (condition1 & condition2)6 | (condition3 & condition4)7 |!(condition5 & condition6) 8 doSomethingAboutIt(); 編輯編輯ppt1 alpha = (aLongBooleanExpression) ? beta : gamma;2 alpha = (aLongBooleanExpression) ? beta : gamma;3 alpha = (aLongBooleanExpression) ? beta : gamma;編輯編輯ppt編輯編輯ppt編輯編
6、輯ppt /* * Here is a block comment. */編輯編輯ppt1 if (condition) 2 /* Handle the condition. */3 /code.4 編輯編輯ppt1 if (a = 2) 2 return TRUE; /* special case */3 else 4 return isPrime(a); /* works only for odd a */5 編輯編輯ppt1 if (foo 1) 2. / Do a double-flip.3 4 else 5. return false; / Explain why here.6 7.
7、 /if (bar 1) 8 / / Do a triple-flip.9 /10 /else 11 / return false;12 /編輯編輯ppt /* * The Example class provides . */ public class Example .編輯編輯ppt1 int level; / indentation level int size; / size of table /這樣不好 3 int level, size; 4 int foo, fooarray; /錯(cuò)誤寫(xiě)法錯(cuò)誤寫(xiě)法編輯編輯ppt編輯編輯ppt1 void myMethod() 2 int int1
8、 = 0; / 好的聲明3 if (condition) 4 int int2 = 0; / 不好的聲時(shí)5 .6 7 編輯編輯ppt1 class Sample extends Object 2 int ivar1;3 int ivar2;4 Sample(int i, int j) 5 ivar1 = i;6 ivar2 = j;7 8 int emptyMethod() 9 .10 編輯編輯ppt 1 argv+; / Correct 2 argc-; / Correct 3 argv+; argc-; / AVOID!編輯編輯ppt 1 if ( this.isExist(“0001”)
9、 2 argc-; / Correct 3 System.out.println(“HELLO”); 4 編輯編輯ppt 1. return; 2. return myDisk.size(); 3. return (size ? size : defaultSize);編輯編輯ppt 1. if (condition) 2 statements; 3 4 if (condition) 5 statements; 6 else 7 statements; 8 9 If (condition) 10 statements;11 else if (condition) 12 statements;
10、13 else 14 statements; 15 編輯編輯ppt if (condition) /非法的,應(yīng)該以包括 statement; 編輯編輯ppt for (initialization; condition; update) statements; 編輯編輯ppt while (condition) statements; while (condition) ;編輯編輯ppt do statements; while (condition);編輯編輯ppt1 switch (condition) 2 case ABC:3 statements;4 /* falls through
11、*/5 case DEF:6 statements;7 break;8 case XYZ:9 statements;10 break;11 default:12 statements;13 break;14 編輯編輯ppt try statements; catch (ExceptionClass e) statements; finally statements; 編輯編輯ppt編輯編輯ppt編輯編輯ppt1 a += c + d;2 a = (a + b) / (c * d);3 while (d+ = s+) 4 n+;5 6 printSize(size is + foo + n);
12、7 for (expr1; expr2; expr3)8 myMethod(byte) aNum, (Object) x);9 myMethod(int) (cp + 5), (int) (i + 3) + 1);編輯編輯ppt 1 ooBar.fChar = barFoo.lchar = c; / 禁止此種方法 2 if (c+ = d+) / AVOID! (Java disallows) . 3 /應(yīng)該寫(xiě)成 4 if (c+ = d+) != 0) . 5 編輯編輯ppt 1 d = (a = b + c) + r; / AVOID /應(yīng)該寫(xiě)成 2 a = b + c; 3 d = a
13、+ r;編輯編輯ppt1 if (booleanExpression) 2 return true;3 else 4 return false;5 應(yīng)該代之以如下方法:6 return booleanExpression;1 if (condition) 2 return x;3 4 return y; 應(yīng)該寫(xiě)做:5 return (condition ? x : y);編輯編輯ppt編輯編輯ppt編輯編輯ppt編輯編輯ppt1 JResponseObject RO = new JResponseObject();/獲得一個(gè)可用連接,這個(gè)連接可能獲取不到。2 JConnection conn
14、= 3 (JConnection) JActiveDComDM.AbstractDataActiveFramework.InvokeObjectMethod(4 DBManagerObject, GetDBConnection, Param);/因此,這里要判斷一下。5 if ( conn = null ) /如果是無(wú)效連接,要返回錯(cuò)誤信息。6 RO.ErrorCode = -1;7 RO.ErrorString = 無(wú)法獲得數(shù)據(jù)庫(kù)連接;8 return RO;9 編輯編輯ppt1 try 2 DBOFormService.3 SQLQuery(conn,msgInput.asStringVa
15、lue(SqlText,),IE.getResultMessage(); /根據(jù)需要,返回對(duì)象類(lèi)型的結(jié)果。4 RO.ResponseObject = IE;5 catch (Exception E) /發(fā)生異常時(shí),要把異常信息返回。6 RO.ErrorCode = -1;7 RO.ErrorString = E.getMessage();8 9 finally /finally里執(zhí)行連接的關(guān)閉操作。10 conn.close();11 12 return RO;編輯編輯ppt1 Statement pSession = null;2 ResultSet pRS = null;3 pSessio
16、n = conn. createStatement();4 String pSql = “SELECT * FROM LSCONF WHERE 1 = 1 ”;5 try6 pRS = pSession. executeQuery (pSql);7 if ( pRS.next()8 /這里是邏輯代碼。用來(lái)取數(shù)。9 10 11 catch(Exception E)12 /這里是一個(gè)異常,需要把異常信息想法通知調(diào)用者??梢允褂胻hrow 拋出。13 編輯編輯ppt 1 finally 2 try 3 /清理操作。 4 if ( pRS != null ) 5 pRS.close(); 6 7 if
17、 ( pSession != null ) 8 pSession.close(); 9 10 11 catch(Exception EE) 12 /這里可能也有異常,不需要拋出。 13 14 編輯編輯ppt編輯編輯ppt編輯編輯ppt編輯編輯ppt 1 IAction mActStop = TAction.Create(STOP, 停止,S,this,onStop,SYS_STOP); 2 JButton btStop = new JButton(“”); 3 btStop.setAction(mActStop); 4 public boolean onStop(IAction pAct,Ac
18、tionEvent pEvt) 5 return true; /這里即是處理代碼。 6 7 JMenuItem pMM = new JMenuItem(); 8 pMM.setAction(mActStop);編輯編輯ppt編輯編輯ppt編輯編輯ppt編輯編輯ppt1 public static String F(String pStringFormat,String P1)2 public static String F(String pStringFormat,String P1,String P2)3 public static String F(String pStringFormat,String P1,String P2,String P3)4 public static String F(String pStringFormat,String P1,String P2,String
溫馨提示
- 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶(hù)所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶(hù)上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶(hù)上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶(hù)因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 敏捷開(kāi)發(fā)方法論2025年考試試題及答案
- 2025年軟考軟件設(shè)計(jì)師有效試題及答案匯編
- 法學(xué)概論從入門(mén)到精通的試題及答案
- 管理者的時(shí)間與精力分配計(jì)劃
- 會(huì)計(jì)軟件應(yīng)用能力提升計(jì)劃
- 積極心理與職業(yè)幸福感提升計(jì)劃
- 供應(yīng)鏈優(yōu)化計(jì)劃
- 城市交通需求管理重點(diǎn)基礎(chǔ)知識(shí)點(diǎn)
- 美術(shù)班級(jí)文化建設(shè)活動(dòng)計(jì)劃
- 2024年陜西師范大學(xué)輔導(dǎo)員考試真題
- 過(guò)熱蒸汽壓力控制設(shè)計(jì)
- 國(guó)際志愿服務(wù)培訓(xùn)與實(shí)踐-浙江外國(guó)語(yǔ)學(xué)院中國(guó)大學(xué)mooc課后章節(jié)答案期末考試題庫(kù)2023年
- 其他常見(jiàn)疾病的康復(fù)
- 技術(shù)人員能力考核評(píng)分表
- 中國(guó)傳統(tǒng)文化知到章節(jié)答案智慧樹(shù)2023年西安理工大學(xué)
- 四位數(shù)乘四位數(shù)乘法題500道
- 英語(yǔ)閱讀知到章節(jié)答案智慧樹(shù)2023年北京大學(xué)
- 三室兩廳家具、家電采購(gòu)清單
- 裝配式建筑混凝土結(jié)構(gòu)施工監(jiān)理實(shí)施細(xì)則
- 噴涂過(guò)程PFMEA分析實(shí)例
- 文明之痕:流行病與公共衛(wèi)生智慧樹(shù)知到答案章節(jié)測(cè)試2023年四川大學(xué)
評(píng)論
0/150
提交評(píng)論