Monday, October 25, 2010

.NET Code Review Checklist

PROBLEM:
How do you know your team's .NET code is well written?

SOLUTION:
Use the following checklist in your code reviews

Inline Documentation
  1. Module Headers
  2. Standard Routine Headers
  3. Routine parameters, return values, assumptions
  4. Constants, Module and Global variables
  5. Routines primary path
  6. Tricky code, special cases, exception handlers

Standards and guidelines
  1. Project Name and description
  2. Standard designs – message handling, clipboard, settings, etc
  3. Namespaces:
  4. CompanyName.TechnologyName[.Feature][.Design]
  5. Class Naming – (Pascal Case, do not use _ or prefix)
  6. Interface Naming – (I prefix, Pascal Case)
  7. Attributes Naming – (use attribute suffix)
  8. Interface Naming – (I prefix, Pascal Case)
  9. Enum Naming – (no suffix, Pascal Case)
  10. Static Field Naming – (Pascal Case)
  11. Parameter Naming – (Camel Case)
  12. Method Naming – (Pascal Case)
  13. Property Naming – (Pascal Case)
  14. Event Handler– (EventHandler suffix)

Change Control
  1. Amendment history included
  2. Marked changed code
  3. Implementation of new/changed Interfaces

Requirements/Design
  1. All specification features implemented
  2. Verification of the requirements - Unit Test
  3. Implementation of all interfaces defined
  4. Design document updated, according design changes in the implementation

Performance/Optimization
  1. File I/O optimized for efficiency
  2. File opened only once to process (unless a random-access file)
  3. DB - operations implemented for efficiency
  4. DB – correct cursor and location specified for the type of use
  5. DB – Use of indexed, record pointers, bookmarks
  6. DB – Extra records (unused) in recordsets
  7. Loops optimization
  8. Recursive routines optimization

Robustness
  1. Error Handling – avoid application crash
  2. Error Handling – meaningful defined error messages
  3. Error Handling – raise different error messages, according to the exceptions to provide appropriate automated response or indication to the user
  4. Error Handling – use of event log (to be isolated and reproduced later)
  5. Error Handling – catch blocks for all type of exceptions
  6. Transaction – group related executions and protect against failures (Commit, Rollback)

Data Use and Control
  1. Minimize use of global variables
  2. Module variables use
  3. Variables – declarations with the smallest scope possible
  4. Variables – declared with a specific type (the smallest type appropriate for the data)
  5. Variables – clear names to identify the use
  6. Variables - Data comparisons of the same type
  7. Variables (module and global) – initialized to default values
  8. Magic numbers avoided using constants and macros
  9. Use of Multiple-individual variables – group related data instead

Execution Control
  1. Functions – return proper value
  2. Recursive functions – boundary safeguards
  3. Modularization use – remove deep nesting of control statements.
  4. Comparisons – proper bracketed evaluations (ensure right order of priority)

Portability
  1. External OS related components testing – ensure compliance with requirements
  2. Platform specific code – clearly identified

Localization (if supported)
  1. Component integrations with the OS regional settings or any application settings
  2. Code implemented to account for user localization issues
  3. Presenting data – user specified date, currency formats, font, color selections, sort orders etc.
  4. Application correct respond to region changes
  5. Use of Resource file or language library – to enable easy deploy in multiple languages

Style and Layout
  1. Consistent use of style elements
  2. Code easy to read

Reusable
  1. Common code identified for inclusion in a common library
  2. Duplicated common code

Testable
  1. Driver program for independent test of the component
  2. Unit test plans used and applied – to identify critical test elements

Data Access
  1. General configurations (connection string)
  2. Proper use of Data objects
  3. Error Handle – use try – catch – finally blocks (close connection object)

Assemblies
  1. Naming Conventions (namespace)
  2. Assembly location (local, GAC)
  3. Multi File / Single File assembly
  4. Versioning

ASP.NET
  1. State Management (State object, Session / Application)
  2. Configuration
  3. Controls
  4. Security
  5. Caching
  6. Error Message Handle
  7. UI – CSS, Page Templates

Remoting Configurations
  1. Activation Type (Client, Singlecall, Singleton)
  2. Registration
  3. Appropriate use - (synchronous, asynchronous)


If you find this solution useful, you are welcome to press one of the ads in this page.. Thanks!


8 comments: