Book Image

Clean Code with C# - Second Edition

By : Jason Alls
4.5 (2)
Book Image

Clean Code with C# - Second Edition

4.5 (2)
By: Jason Alls

Overview of this book

Traditionally associated with Windows desktop applications and game development, C# has expanded into web, cloud, and mobile development. However, despite its extensive coding features, professionals often encounter issues with efficiency, scalability, and maintainability due to poor code. Clean Code in C# guides you in identifying and resolving these problems using coding best practices. This book starts by comparing good and bad code to emphasize the importance of coding standards, principles, and methodologies. It then covers code reviews, unit testing, and test-driven development, and addresses cross-cutting concerns. As you advance through the chapters, you’ll discover programming best practices for objects, data structures, exception handling, and other aspects of writing C# computer programs. You’ll also explore API design and code quality enhancement tools, while studying examples of poor coding practices to understand what to avoid. By the end of this clean code book, you’ll have the developed the skills needed to apply industry-approved coding practices to write clean, readable, extendable, and maintainable C# code.
Table of Contents (18 chapters)

Code Review – Process and Importance

The primary motivation behind any code review is to improve the overall quality of the code. Code quality is very important. This almost goes without saying, especially if your code is part of a team project or is accessible to others, such as open-source developers and customers through escrow agreements.

If every developer were free to code as they pleased, you would end up with the same kind of code written in so many ways, and ultimately, the code would become an unwieldy mess. That is why it is important to have a coding standards policy that outlines the company’s coding practices and code review procedures that are to be followed.

When code reviews are carried out, colleagues will review the code of other colleagues. Colleagues will understand that it is only human to make mistakes. They will check the code for mistakes, such as code that breaks the company’s code of coding conduct, and any code that, while syntactically correct, can be improved upon to make it more readable, more maintainable, or more performant.

Therefore, in this chapter, we will cover the following topics to understand the code review process in detail:

  • A brief introduction to GitHub
  • The code review process
  • Preparing code for review
  • Leading a code review
  • Knowing what to review
  • Knowing when to send for code review
  • Providing and responding to review feedback

Note

For the Preparing code for review and Knowing when to send code for review sections, we will be talking from the point of view of the programmer. For the Leading a code review and Knowing what to review sections, we will be talking from the point of view of the code reviewer. However, concerning the Providing and responding to review feedback section, we will cover the viewpoints of both the programmer and the code reviewer.

The learning objectives for this chapter are for you to be able to do the following:

  • Understand GitHub and its potential use in the code review process
  • Understand code reviews and why they are good
  • Partake in code reviews
  • Provide constructive criticism
  • Respond positively to constructive criticism

Before we dive deep into these topics, let’s understand the general code review process.