C# Coding Practices

Paths

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

Pre-requisites

Knowledge of the C# programming language

Beginner

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 Code: Writing Code for Humans

by Cory House

Oct 7, 2013 / 3h 10m

3h 10m

Start Course
Description

Are you a technical debt generator? Do your co-workers cringe at the thought of having to work with your code? Clean code is the art of writing code humans can understand. Elevate your professionalism and increase your code quality by writing with the reader in mind! We'll walk through three core clean coding practices: 1) Select the right tool for the job. 2) Optimize the signal to noise ratio. 3) Create self-documenting logic. These practices are the foundation for a professional development career and provide developers a clear vocabulary for evaluating code quality.

Table of contents
  1. Introduction
  2. Principles
  3. Naming
  4. Conditionals
  5. Functions
  6. Classes
  7. Comments
  8. Demo
  9. Stay Clean

Defensive Coding in C#

by Deborah Kurata

May 9, 2014 / 4h 33m

4h 33m

Start Course
Description

You will learn how to write clean, maintainable, and testable code when faced with constantly changing requirements, legacy issues, intensive time pressures, and a rapidly evolving environment. You will also learn how to keep that code great after maintenance activities, multiple developers, and the ravages of time.

Table of contents
  1. Introduction
  2. Defending Your Methods - Part 1
  3. Defending Your Methods - Part 2
  4. Automated Code Testing
  5. Defending Your Methods Part 3: Returning Predictable Results
  6. Defending Your Code Constructs
  7. Asserts, Errors, and Exceptions
  8. Final Words

Intermediate

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

2h 18m

Start Course
Description

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

Advanced

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

2h 9m

Start Course
Description

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