C# Development Best Practices


C# Development Best Practices

Authors: Cory House, Deborah Kurata, Steve Smith, Jeremy Clark, Zoran Horvat, Vladimir Khorikov, Filip Ekberg, Matthew Renze, Dino Esposito, Thomas Claudius Huber

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

You will be able to write clean extensible and maintainable code that you can be proud of.

You will learn how to tackle the challenges of building complex applications and the principles of application design, organizing your code, implementing dependency injection, and the advanced concepts of object oriented programming techniques.


C# Language Fundamentals

Coding and Application Design Best Practices

Learn the best practices of C# development by writing clean, extensible and maintainable code.

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

Object-Oriented Programming Fundamentals in C#

by Deborah Kurata

Mar 11, 2019 / 3h 26m

3h 26m

Start Course

This course takes you through the principles and practices of object-oriented programming (OOP). The course provides you with the firm foundation in OOP that you need to progress to intermediate-level C# courses. It begins by showing you how to turn a set of words into a set of well-defined and related classes. Through demonstrations, it teaches you key object-oriented concepts such as abstraction, encapsulation, inheritance, polymorphism, and interfaces.

Table of contents
  1. Course Overview
  2. Introduction
  3. Identifying Classes from Requirements
  4. Building Entity Classes
  5. Building Entity Classes - Methods
  6. Separation of Responsibilities
  7. Establishing Relationships
  8. Leveraging Reuse through Inheritance
  9. Building Reusable Components
  10. Understanding Interfaces
  11. Final Words and Next Steps

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 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

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

Getting Started with Dependency Injection in .NET

by Jeremy Clark

Mar 5, 2019 / 2h 8m

2h 8m

Start Course

Tight coupling makes our code hard to change and test. In this course, "Getting Started with Dependency Injection in .NET", you will learn the foundational knowledge to break tight coupling with Dependency Injection. First, you will learn how to use constructor injection to create loosely-coupled code. Next, you will see how to snap those loosely-coupled pieces together in different ways to easily change functionality. Then, you will discover how easy it is to unit test code that uses dependency injection. Finally, you will explore some of the magic of dependency injection containers. When you are finished with this course, you will have the skills and knowledge of dependency injection needed to break tight coupling and write more maintainable code.

Table of contents
  1. Course Overview
  2. What Is Tight Coupling and How Does It Impact Your Applications?
  3. Using Dependency Injection to Build Loosely-coupled Applications
  4. Taking Advantage of Loose Coupling
  5. How Dependency Injection Makes Unit Testing Easier
  6. Dependency Injection Containers

Making Your C# Code More Object-oriented

by Zoran Horvat

Oct 19, 2016 / 7h 4m

7h 4m

Start Course

Programmers do have conceptual understanding of OO concepts, but often fail to turn that into a proper object-oriented code. In this course, Making Your C# Code More Object-oriented, you'll learn how to create proper object-oriented code. First, you'll learn how to avoid branching and looping. Next, you'll learn how to avoid Boolean expressions. Finally, you'll learn how to make domain logic implementation dynamic and configurable. By the end of this course, you'll be able to recognize your own error of the past and build more correct coding style.

Table of contents
  1. Course Overview
  2. Attaining Extensibility with Object-oriented Code
  3. Rendering Branching Over Boolean Tests Obsolete
  4. Keeping the Focus on Domain Logic with Sequences
  5. Untangling Structure from Operations on Business Data
  6. Turning Algorithms into Strategy Objects
  7. Using Immutable Objects When Possible
  8. Leveraging Special Case Objects to Remove Null Checks
  9. Turning Optional Calls into Calls on Optional Objects
  10. Increasing Flexibility by Avoiding Switch Statements
  11. Turning Chained Branching into the Chain of Rule Objects
  12. Refactoring to Bind It All Together

Applying Functional Principles in C#

by Vladimir Khorikov

Apr 8, 2016 / 3h 28m

3h 28m

Start Course

With the advent of LINQ, C# has gotten a significant exposure to functional programming. However, functional programming in C# is not restricted to the use of extension methods, lambdas and immutable classes. There are a lot of practices that haven't been adopted as widely because there's not much of native language support for them in C#. Still, they can be extremely beneficial should you incorporate them into your day-to-day work. This course, Applying Functional Principles in C#, will show them to you. You will learn the fundamental principles behind functional programming, why they are important and how to apply them in practice. Specific topics you'll cover include refactoring to an immutable architecture, avoiding exceptions, primitive obsession, how to handles failures and input errors, and more. By the end of this course, you will have a much more comprehensive understanding of why and how to use functional programming.

Table of contents
  1. Course Overview
  2. Introduction
  3. Refactoring to an Immutable Architecture
  4. Refactoring Away from Exceptions
  5. Avoiding Primitive Obsession
  6. Avoiding Nulls with the Maybe Type
  7. Handling Failures and Input Errors in a Functional Way
  8. Putting It All Together

Applying Asynchronous Programming in C#

by Filip Ekberg

Dec 11, 2020 / 3h 18m

3h 18m

Start Course

Do you want to build fast, responsive, and overall better applications by applying asynchronous principles? You'll need to understand how to safely and effectively introduce asynchronous programming in your applications.

In this course, Applying Asynchronous Programming in C#, you’ll learn the fundamentals of asynchronous programming in C#:

  • explore how to properly apply the async and await keywords
  • discover the Task Parallel Library and understand how it relates to async and await
  • learn more about how introducing asynchronous patterns affects the application, how to avoid pitfalls, and how to best approach these patterns
When you’re finished with this course, you’ll have the skills and knowledge of asynchronous programming needed to apply this in your C# applications.

Table of contents
  1. Course Overview
  2. Getting Started with Asynchronous Programming in C# using Async and Await
  3. Using the Task Parallel Library for Asynchronous Programming
  4. Exploring Useful Methods in the Task Parallel Library
  5. Async and Await Advanced Topics and Best Practices
  6. Asynchronous Programming Deep Dive

C# Application Design

Having mastered the C# language and know how to implement the time-tested best practices, take you learning to the next level by learning how to engineer applications using design patterns, domain models, CQRS, and event sourcing.

Design Patterns Overview

by Steve Smith

May 14, 2020 / 37m


Start Course

Design patterns help developers and teams solve problems using proven approaches. Patterns also enable teams to discuss design decisions using a richer, more descriptive language.

In this course, Design Patterns Overview, you are introduced to the idea of patterns - how they're discovered, defined, and applied.

  • First, you'll demonstrate a few useful patterns.
  • Next, you'll discover how they can be combined and stacked to produce elegant, useful designs.
  • Finally, you'll explore why you should spend time learning them.
When you complete this course, you'll understand the role design patterns play in modern software development and you'll be ready to start mastering individual patterns that will make you more productive.

Table of contents
  1. Course Overview
  2. Design Patterns Overview

Clean Architecture: Patterns, Practices, and Principles

by Matthew Renze

Jan 11, 2017 / 2h 20m

2h 20m

Start Course

Hello, and welcome to Pluralsight! My name is Matthew Renze, and I want to give you a quick overview of my course, Clean Architecture: Patterns, Practices, and Principles.

This course is designed to help you learn how software experts keep their architecture clean using a modern approach to software architecture called Clean Architecture, and covers things like:

  • Domain-centric architecture
  • Application layers
  • CQRS (Command-Query Responsibility Separation)
  • Event sourcing
  • Functional cohesion
  • Bounded contexts, and more
In addition, you'll use these practices to replace the outdated three-layer database-centric architecture that has been used for decades. Most important though, you'll see how these practices, when combined, create an architecture that is simple, understandable, flexible, testable, and maintainable.

When you’re done, you’ll have the skills necessary to understand and implement these clean architecture practices on your own software projects.

As an introductory course, there are no prerequisites for this course. However, having basic experience with at least one C like programming language, and basic knowledge of software architecture will be beneficial.

I look forward to working with you on Clean Architecture: Patterns, Practices, and Principles, here at Pluralsight.

Table of contents
  1. Course Overview
  2. Introduction
  3. Domain-centric Architecture
  4. Application Layer
  5. Commands and Queries
  6. Functional Organization
  7. Microservices
  8. Testable Architecture
  9. Evolving the Architecture

Modern Software Architecture: Domain Models, CQRS, and Event Sourcing

by Dino Esposito

Dec 3, 2019 / 4h 25m

4h 25m

Start Course

This course covers DDD analysis patterns helpful in discovering the top-level architecture of a business domain. Architects and developers will find details of implementation patterns such as:

  • Domain Model
  • CQRS
  • Event Sourcing

Table of contents
  1. DDD at a Glance
  2. Discovering the Domain Architecture through DDD
  3. The DDD Layered Architecture
  4. The "Domain Model" Supporting Architecture
  5. The CQRS Supporting Architecture
  6. Event Sourcing
  7. Designing Software Driven by the Domain

Test Driven Development in C#

by Thomas Claudius Huber

Jan 29, 2020 / 2h 26m

2h 26m

Start Course

At the core of writing solid and robust C# code is a thorough knowledge of Test Driven Development (TDD). In this course, Test Driven Development in C#, you will learn the skills you need to be able to apply TDD in your .NET projects. First, you will discover the basics of TDD and about the red-green-refactor cycle. Next, you will learn how to test and implement business logic for a .NET Core application with TDD. You’ll use xUnit as a testing framework and Moq as a mocking library. Finally, your business logic will be used in an ASP.NET Core Razor Pages application, and you will use TDD to add additional features in that application. When you’re finished with this course, you’ll have a foundational knowledge of Test Driven Development that will help you as you move forward to test and implement new features in your C# projects.

Table of contents
  1. Course Overview
  2. Getting Started with Test Driven Development
  3. Testing and Implementing Business Logic
  4. Adding Features in an ASP.NET Core App
Learning Paths

C# Development Best Practices

  • Number of Courses13 courses
  • Duration39 hours

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 with. The courses in this skill path are designed to help you refine your practices as a C# developer, to learn how to write code that is not just functional, but clean, maintainable and something you can be proud of.

After you have mastered the best coding practices using the C# language, you will be challenged to build larger and more complex applications. This skill path is designed to equip you with the knowledge to tackle these challenges by teaching you time tested practices in application design. This includes how to organize your code, how to take care of dependency injection and how to use advanced object oriented and functional programming techniques.

Join our learners and upskill
in leading technologies