Skip to content

c# review checklist

Naming Conventions

  • [ ] List item

Source code file

  • [ ] Sort all the using statements (Organize Using)
  • [ ] Check if the code is structured in regions
  • [ ] Does the code work?
  • [ ] Don’t just ignore warnings
  • [ ] Check for SOLID, DRY, KISS principle opprtunities
  • [ ] Any dependency injection is missing?
  • [ ] Use interfaces wherever needed to maintain decoupling.
  • [ ] Code Consistency e.g. int or Int32
  • [ ] Do care for Null all the times var first = person?.FirstName;
  • [ ] Dead code, remove commented, unreachable code
  • [ ] Use constants and readonly wherever applicable.
  • [ ] Avoid type casting and type conversions as much as possible
  • [ ] Override ToString (from Object class) method for the types which you want to provide with custom information.
  • [ ] Large function alert (more than 20-30 lines)
  • [ ] More parameters to a function (more than 3-4 params)
  • [ ] One file shall not be more than 250-300 lines
  • [ ] Check if we have logged all required infromation
  • [ ] Declare access specifiers explicitly (private, public, protected, internal, protected internal)
  • [ ] Use C# new language features, for example, use nameof operator to get the property/method names instead of hard coding it
  • [ ] Avoid nested for/foreach loops
  • [ ] Usage of ‘out' and 'ref' keywords be avoided as recommended by Microsoft
  • [ ] Use PLINQ wherever applicable, as it makes parallel operation within LINQ query and improves the performance

    https://docs.microsoft.com/en-us/dotnet/standard/parallel-programming/introduction-to-plinq - [ ] Avoid nested for/foreach loops - [ ] if (IsNullOrWhiteSpace(lastName)) throw new ArgumentException(message: “Cannot be blank”, paramName: nameof(lastName));

  • [ ] if (IsNullOrWhiteSpace(lastName))

Performance

  • [ ] Does it have a paged service endpoint?
  • [ ] Are we using foreach.parallel....
  • [ ] Are there local concurrency issues?

Unit Test cases