Friday, January 27, 2006

C# Quality Code Checklist

  1. Test

    • Functional - Automated Tests

    • Unit Tests

  2. Dispose

    • Use the System.Component memory management properly

    • Implement IDispose

  3. Fix Exception handling

    • Explicit exception handling only

    • Remove catches with no explicit handling

    • Remove all System.Exception catches

    • Ensure either exception handling is in place or propagate the exception

    • Remove catch alls

  4. Build Properly

    • Deliver a Debug build to QA

    • Build warning free

      • Build on warning level 4

      • Build with all warnings as errors

    • Build with XML Documentation switched on

    • Build Release configuration with debug information switched on

    • Run FXCop in the build - warning free

  5. Assert

    • Assert Every Assumption

    • Convert Asserts to Exceptions as part of the last iteration

    • On average every 5th line should be an Assert

  6. Refactor

    • Refactor classes and methods

      • One class per file

    • Replace boolean multi states and method arguments with enums

    • Remove redundant code

  7. Logging

    • Use a TextFile writing TraceListener and a logging exception

    • Log failures that do not justify throwing an exception

    • Log all API calls as part of API validation

  8. Apply v2.0 improvements

    • Create Typesafe Collections with Generics

    • Use DataGrid

    • Use Safe Handle and Critical Regions for all system resources

  9. Documentation

    • Write sensible documentation

    • Log all changes in the log book

No comments: