C# Coding Practices


C# Coding Practices

Authors: Cory House, Deborah Kurata, Steve Smith

Writing clean and maintainable code is a skill every developer needs to know how to do. Clean code is easier to extend, lowers maintenance cost over time and is easier to work... Read more

What you will learn

  • Naming conventions for classes, methods and variables
  • How to write methods that are maintainable and easily understood
  • Class and code organization strategies
  • Defensive coding practices
  • Strategies for refactoring code
  • The SOLID principles and their application


Knowledge of the C# programming language


Writing high quality code starts with writing clean code. In this section you will learn how to write code that is clean and maintainable by using good naming conventions, writing better methods and organizing your classes properly. Then you will learn how to write code that is more robust by learning the best practices around defensive coding.

Clean Coding Principles in C#

by Cory House

Jan 2, 2020 / 3h 18m

3h 18m

Start Course

Clean code is the art of writing code that humans can understand. In this course, Clean Coding Principles in C#, you'll elevate your professionalism and increase your C# code quality by writing with the reader in mind. This course is built upon three core clean coding practices: selecting the right tool for the job, optimizing the signal to noise ratio, and creating self-documenting logic. Throughout this course you'll see clear comparisons between "dirty" C# code to avoid and the "clean" equivalent. You'll explore patterns like arrow code, failing fast, returning early, magnet classes, mayfly variables, techniques for reducing method complexity, and much more. These practices are the foundation for a professional development career and provide developers a clear vocabulary for evaluating code quality.

Table of contents
  1. Course Overview
  2. Why Writing Clean Code Matters
  3. Clean Coding Principles
  4. Naming
  5. Writing Conditionals That Convey Intent
  6. Writing Clean Methods
  7. Writing Clean Classes
  8. Writing Clean Comments
  9. Demo: Refactoring to Clean C#
  10. Staying Clean

Defensive Coding in C#

by Deborah Kurata

Jan 2, 2020 / 2h 14m

2h 14m

Start Course

Great applications perform required operations as expected, help users enter correct data, handle system and application exceptions, and make it easy for future developers to modify and maintain the code. Defensive coding focuses on improving code comprehension through clean code, improving code quality with unit tests, and improving code predictability by building clear methods and preparing for the unexpected. In this course, Defensive Coding in C#, you will gain the ability to strengthen your application’s defenses against the perils awaiting it in the real world. First, you will learn how to improve your code comprehension by following techniques such as the Single Responsibility principle. Next, you will discover how to improve your code quality through unit tests. Finally, you will explore how to improve your code predictability by validating method arguments, handling nulls appropriately, returning predictable results, and managing exceptions. When you are finished with this course, you will have the skills and knowledge needed to strengthen your code’s defenses.

Table of contents
  1. Course Overview
  2. Why Defensive Coding Matters
  3. Strengthening Our Code’s Defenses
  4. Validating Method Arguments
  5. Handling Nulls
  6. Returning Predictable Results
  7. Managing Exceptions
  8. Final Words


Refactoring is the process of changing the structure of code to be more readable and maintainable without altering its underlying functionality. It is also a critical skill to develop so you can transform messy code into clean code when called upon, which you will learn to do in this section.

Refactoring for C# Developers

by Steve Smith

Aug 22, 2019 / 2h 17m

2h 17m

Start Course

Over time, software design tends to degrade, and systems become increasingly difficult to maintain. In this course, you'll learn how to recognize and evaluate potential flaws in your system's design, known as "code smells." You'll be introduced to code smells at the statement, method, and class levels in C# applications. You'll also learn about the process of refactoring your code to eliminate design flaws and improve its maintainability. Finally, you'll learn how to apply dozens of specific refactorings to common, known problems in C# applications. When you're finished with this course, you'll have the skills and knowledge needed to identify code quality problems and correct them with quick and reliable refactoring techniques.

Table of contents
  1. Course Overview
  2. Introducing Refactoring and Code Smells
  3. Statement Code Smells
  4. Method Code Smells
  5. Class Code Smells


Are you a SOLID developer? By applying the SOLID principles to the code you write, you will write code that is easier to understand, maintain and extend. The course in this section will teach you what you need to know to implement these principles in your code.

SOLID Principles for C# Developers

by Steve Smith

Apr 2, 2019 / 2h 8m

2h 8m

Start Course

It's easy to write software that fulfills its users' immediate needs, but is difficult to extend and maintain. Such software becomes a burden for companies striving to remain competitive.

In this course, SOLID Principles for C# Developers, you will learn five fundamental principles of object-oriented design that will keep your software loosely coupled, testable, and maintainable.

First, you will see how to keep classes small and focused, and how to extend their behavior without having to edit their source code.
Then, you will discover the importance of properly designing interfaces and abstractions in your systems.
Finally, you will explore how to arrange dependencies in your system so different implementations can be added or plugged in as needed, allowing a truly modular design.

When you are finished with this course, you will understand how to build maintainable, extensible, and testable applications using C# and .NET.

Table of contents
  1. Course Overview
  2. Single Responsibility Principle
  3. Open / Closed Principle
  4. Liskov Substitution Principle
  5. Interface Segregation Principle
  6. Dependency Inversion Principle
Offer Code *
Email * First name * Last name *
Country *

* Required field

Opt in for the latest promotions and events. You may unsubscribe at any time. Privacy Policy

By providing my phone number to Pluralsight and toggling this feature on, I agree and acknowledge that Pluralsight may use that number to contact me for marketing purposes, including using autodialed or pre-recorded calls and text messages. I understand that consent is not required as a condition of purchase from Pluralsight.

By activating this benefit, you agree to abide by Pluralsight's terms of use and privacy policy.

I agree, activate benefit