Course Reflection: "Lessons from Real World .NET Code Reviews"
When I started going through the Pluralsight course "Lessons from Real World .NET Code Reviews" by Shawn Wildermuth, I thought it was a great topic and expected it to offer tangible suggestions that I could use a checklist. I'm a fan of checklists and I like the style & organization of the checklists in the Patterns & Practices book Improving .NET Application Performance and Scalability (published in 2004 but never updated). I felt that the two hour course started well but got preachy. I wish it was more comprehensive, focusing on coding issues that impact projects significantly rather than touching upon a few random experiences.
Key points from the course:
- A code review is a systematic way of quantifying code quality
- The job of a code review is to determine what is being done well as well as what can be done better. It is not a witch hunt.
- Look for common problems, not on-off issues
- Review 200-400 lines at a time
- Avoiding "Magic Numbers' can clarify your code and make it harder to make typing mistakes
- Avoid using the + operator to concatenate strings in all cases. Consider using String.Concat() & String.Format(). Use StringBuilder for large amounts of text.
- For unmanaged resources, using IDisposable correctly can prevent resource leaks
- Knowing how enumerations handle defaults makes you understand you always need a zero value
- Breaking up large methods into smaller methods can increase readability and maintainability
- Creating multiple layers of inheritance for it's own sake or identity is adding complexity
- Using nested classes for information hiding isn't necessary and hurts maintainability
- The Singleton pattern is useful, but static classes simplify the way to accomplish this pattern
- The less code inside a Razor file the better
- Building code frequently improves code quality.
- Write unit tests for both client-side & server-side code