国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發 > 綜合 > 正文

C# Code Review Checklist

2024-07-21 02:19:08
字體:
來源:轉載
供稿:網友


收集最實用的網頁特效代碼!

ted graham 提到了39 條 checklist, 我覺得還是總結的挺全面.

are exceptions used to indicate error rather than returning status or error codes?
使用異常來只是錯誤而不是使用狀態或者錯誤代碼值
are all classes and public methods commented with .net style comments?? note that comments should discuss the "what" of public methods.? discussion of "how" should be in blocks or in-line with the code in question.
所有類以及 public 方法 都使用.net 樣式的注釋, 即 /// summary 格式. 注意 summary 中說明代碼有那些功能,而不是這個功能如何實現的. 可以在 remarks 塊或者代碼中說明.
are method arguments validated and rejected with an exception if they are invalid?
所有方法的參數的合法性是否做驗證, 對非法的參數是否拋出異常?
are debug.asserts used to verify assumptions about the functioning of the code?? comments like, "j will be positive" should be rewritten as asserts.?
是否使用 debug.asserts 來驗證代碼中的假設? “ j 應該是正數?“之類的注釋應該用 debug.asserts 來重寫.
do classes that should not be instantiated have a private constructor?
不需要實例化的類有 私有構造函數嗎?
are classes declared as value types only infrequently used as method parameters, returned from methods or stored in collections?
值類型的類用于參數,方法返回值以及存放在集合中?
are classes, methods and events?that are specific to an assembly marked as internal?
assembly 特有的類,方法,事件的訪問修飾符是否已經標記為 internal ?
are singletons that may be accessed by multiple threads instantiated correctly?? see the enterprise solution patterns book, p. 263.
多線程同時訪問的單件對象是否正確的初始化?
are methods that must be overriden by derived classes marked as abstract?
必須被衍生類重寫的方法申明為 abstract 了嗎?
are classes that should not be overriden marked as sealed?
不能重寫的類是否標記為 sealed?
is "as" used for possibly incorrect downcasts??
可能失敗的轉換是否使用了 as 運算符?
do classes override tostring?instead of defining a dump method for outputting the object's state?
輸出對象的狀態的時候應該重寫 tostring 方法而不是加一個類似 dump 之類的方法.
are log messages sent to the logging component instead of console?
所有log 的消息都有 log 組建處理,而不是僅僅輸出到 控制臺.
are finally blocks used for code that must execute following a try??
finnally 代碼塊用于try 后必須執行的代碼
is foreach used in preference to the for(int i...) construct?
盡可能的采用 foreach 而不是 for(int i...)
are properties used instead of implementing getter and setter methods?
是否屬性沒有實現getter 和 setter 方法
are readonly variables used in preference to?properties without setters?
只讀的屬性應該沒有 setter 方法
is the override keyword used on all methods that are overriden by derived classes?
衍生類重寫的方法是否都使用了 override 關鍵字
are interface classes used in preference to abstract classes?
正確的使用interface 和抽象類.
is code written against an interface rather than an implementing class?
接口實現和抽象類繼承
do all objects that represent "real-world" or expensive resources implement the idisposable pattern?
操作系統資源的類是否實現了 idisposable 接口?
are all objects that implement idisposable instantiated in a using block?
是否所有實現idisposable 的類初始化的時候使用了 using 語句?
is the lock keyword used in preference to the monitor.enter?construct?
使用lock 語句而不是 monitor.enter
are threads awakened from wait states by events or the pulse construct, rather than "active" waiting such as sleep()?
線程使用事件或者pulse 喚醒, 而不是使用 sleep 主動的喚醒.
if equals is overridden, is it done correctly?? the rules for overriding equals are complex, see richter p153-160 for details.
是否正確的重寫了 equals
if == and != are overridden, so they redirect to equals?
== 和 != 操作符號被重寫
do all objects that?override equals also provide an overloaded version of gethashcode that?provides the same semantics as equals?? note that overrides to gethashcode should?take advantage of the object's member variables, and must?return an unchanging hash code.
equals gethashcode 的重寫問題
do all exception classes?have a constructor that takes a string and and another constructor that takes a string and an exception?
異常類的構造問題
do all exception classes derive from the base matrix exceptions and fit correctly into the exception hierarchy?
自定義異常類的繼承層次問題
are all classes that will be marshaled or remoted marked with the serializable attribute?
所有被 marshal 或者遠程處理的對象有序列化標志
do all classes marked with the?serializable attribute have a default constructor?? this includes exception and?eventargs?classes.
所有標記有 serializable 屬性的類是否有默認的構造函數, 包括常見的 exception 和 eventargs 類.
do all classes that explicitly implement iserializable provide both the required getobjectdata and the implied constructor that takes a serializationinfo?and a?streamingcontext?
實現 iserializable 接口的類是否顯式的實現 getobjectdata 和 隱式的構造函數,例如 serializaioninfo 和 streamingcontext 作為參數
when doing floating point calculations,?are all constants doubles rather than integers?
做浮點運算的時候,所有的常量都是double 類型而不是整數
do all delegates have a void return type and avoid using output or ref parameters?
委托是否都有 void 返回值,避免使用 out 或者 ref 類型的參數
do?all delegates send the sender (publisher) as the first argument?? this allows the subscriber to tell which publisher fired the event.?
所有的委托又有 sender 對象作為第一個參數
are all members of derived eventarg classes read-only?? this prevents one subscriber from modifying the eventargs, which would affect the other subscribers.
從 eventarg 繼承的類是否是只讀的, 只讀的參數可以避免一個訂閱者對參數的修改影響其他的參數訂閱者
are delegates published as events?? this prevents the subscribers from firing the event, see lowy, p. 102?for details.
所有的委托發布事件?
is common setup and teardown nunit code isolated in?setup and teardown methods that are marked with the appropriate attribute?
單元測試的時候, 常見的驅動代碼和測試代碼分開.
do negative nunit tests use the expectedexception attribute to indicate that an exception must be thrown?
使用 expectedexcetpion 來指示異常必須拋出?

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 海口市| 化州市| 清河县| 张家口市| 乌海市| 苏尼特右旗| 平泉县| 陆丰市| 子洲县| 桃江县| 嵩明县| 云阳县| 绥阳县| 洛隆县| 卢龙县| 龙胜| 新竹市| 泸州市| 中山市| 兖州市| 璧山县| 塔城市| 商水县| 泽库县| 大厂| 巴彦淖尔市| 新乐市| 林州市| 福贡县| 顺义区| 齐齐哈尔市| 常德市| 隆回县| 高安市| 老河口市| 福安市| 黑水县| 光泽县| 吉安县| 错那县| 吴旗县|