程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> .NET網頁編程 >> .NET實例教程 >> IDesign C#編碼規范(之五)

IDesign C#編碼規范(之五)

編輯:.NET實例教程
續四,休息天翻得很少,不過總算在keep doing,:-) 

4 Framework特別指導 
Framework Specific Guidelines 
4.1 數據訪問 
Data Access 
1. 總是使用類型安全的數據集或者數據表。避免使用原始的ADO.Net。 
Always use type-safe data sets or data tables . Avoid raw ADO.Net. 
2. 訪問數據庫時總是使用事務。 
Always use transactions when Accessing a database. 
a) 總是使用服務組件事務。 
Always use Enterprise Services transactions. 
b) 不要使用ADO.Net事務。 
Do not use ADO.Net transactions. 
3. 總是將事務隔離級別設置為序列的。 
Always use transaction isolation level set to Serializable. 
a) 使用其它隔離級別需要管理層決定。 
Requires management decision to use anything else. 
4. 不要使用服務器浏覽器將數據庫連接拖到Windows表單、ASP.Net表單或Web服務中。這樣做耦合了界面層和數據層。 
Do not use the Server Explorer to drop connections on Windows forms, ASP.Net forms or web services. Doing so couples the presentation tier to the data tIEr. 
5. 避免使用SQL Server驗證。 
Avoid SQL Server authentication. 
a) 而是使用Windows驗證。 
Use Windows authentication instead. 
6. 將訪問SQL Server的組件以調用該組件客戶端不同的身份運行。 
Run components Accessing SQL Server under separate identity from that of the calling clIEnt. 
7. 總是在高層用類型安全的類包裝存儲過程。僅在那個類中調用存儲過程。 
Always wrap your stored procedures in a high level, type safe class. Only that class invokes the stored procedures. 
8. 避免在存儲過程中放任何邏輯。 
Avoid putting any logic inside a stored procedure. 
a) 如果存儲過程中有IF,你可能犯了錯誤。 
If there is an IF inside a stored procedure, you are doing something wrong. 

待續。忽然想到曾閱讀過一篇關於business layer的文章,總體是責問有多少程序真正有business layer,文中甚至倡議presentation layer中不要引用System.Data命名空間,你做得到嗎?小雞射手還不行,嘻嘻... 
  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved