1.在連線字串的時候盡量避免使用
2. 多使用preparedstatement代替statement這樣可以避免在拼接字串的時候出現
"select * from tablename where col = '"+col+"'"單引號過多的情況 3.
在拼接查詢語句的時候加上"where 1=1 "
4.多使用messageformat類 5.
**中盡量少出現"123".equals(str)這樣的危險字元
而要public static final string str = "123"; str.equals(str)去代替.
6.方法的命名要能夠表達出方法的功能
7、為了程式的健壯性
我們可能使用integer.valueof(1)去代替new integer(1);
原因:public static integer valueof(int i)返回乙個表示指定的int 值的integer 例項。如果不需要新的integer 例項,則通常應優先使用該方法,而不是構造方法integer(int),因為該方法有可能通過快取經常請求的值而顯著提高空間和時間效能。
一些小技巧
關注 乙個好的程式設計師不應該把所有的判斷交給編譯器和偵錯程式,應該在程式中自己加以程式保護和錯誤定位,具體措施包括 對於所有有返回值的函式,都應該檢查返回值,除非你確信這個函式呼叫絕對不會出錯,或者不關心它是否出錯。一些函式返回錯誤,需要用其他函式獲得錯誤的具體資訊。例如accept返回inval...
一些小技巧
protected void repparent itemdatabound object sender,system.web.ui.webcontrols.repeateritemeventargs e 在父datalist的itemdatabound事件裡面寫子datalist的資料來源 繫結 ...
一些小技巧
protected void repparent itemdatabound object sender,system.web.ui.webcontrols.repeateritemeventargs e 在父datalist的itemdatabound事件裡面寫子datalist的資料來源 繫結 ...