From Zero to Hero: Writing Clean Code with C#

Learn how to write elegant C# using modern Clean Code practices

About This Course

"Clean Code" is one of the most used phrases in software engineering but is also one of the most misused. What does Clean Code mean, and what makes our code dirty or clean? The concept was popularized by Robert C. Martin or "Uncle Bob", and it is a set of practices that will help you write code that is easier to change, read and understand and less prone to mistakes or issues when it comes time to change or expand it. In this course, Gui Ferreira will teach you everything you need to know to start writing excellent C# code using the knowledge he gained after years of writing clean code professionally for big companies.

Course Curriculum

4h 06m 14 sections
Welcome
01:31 Free preview
What will you learn in this course?
02:17 Free preview
Who is the course for and prerequisites
01:17 Free preview
Why Clean Code is essential
02:42
The Boy Scout Rule
01:05
The Broken Windows Theory
01:10
The YAGNI principle
00:47
The KISS principle
00:54
The Principle of Least Surprise
01:39
What is Coupling?
02:27
What is Cohesion?
01:06
Readability vs Performance
02:18
Spotting Duplication
02:27
Writing Idiomatic code
01:59
Section Recap
00:34
Introduction
00:33
The impact of Naming
02:30
How long should a Name be
02:25
Naming Variables
03:34
Naming Booleans
02:19
Naming Methods
04:24
Naming Classes
03:17
Using Acronyms and Abbreviations
02:29
Section Recap
00:47
Introduction
00:27
Good and Bad Comments
05:54
Removing Historic Comments
01:13
Converting Comments to Code
02:19
Removing Formatting Comments
04:11
Replacing Comments with Tests
02:02
Section Recap
00:39
Introduction
00:37
Applying Indentation
01:56
Using Braces
02:06
Using Whitespace
02:45
Vertically Ordering a Class
03:12
Section Recap
00:19
Introduction
00:23
Writing Boolean Comparisons
05:00
Removing Double Negatives
01:59
Avoiding short-circuits
02:39
Avoiding Magic Numbers
06:28
Expressive Switch Statements
05:54
Section Recap
00:42
Introduction
00:51
Removing Nesting
04:07
Returning early
03:03
Using Guard Clauses
03:33
Applying the Single Responsibility Principle
06:09
Removing Flag Arguments
04:07
Parameter Order
04:11
Controlling the number of Parameters
03:17
Output Parameters
03:08
Working with collections
01:53
Section Recap
00:44
Introduction
00:32
Exceptions vs Error Codes
03:31
Writing the Try-Catch block
03:51
Providing Context with Exceptions
03:43
Section Recap
00:31
Introduction
00:40
Applying the Single Responsibility Principle
03:37
Segregating Interface
02:37
Writing Constructors
02:31
Removing Nested Classes
01:50
Converting anemic to rich objects
07:25
Primitive Obsession
04:24
Section Recap
00:51
Introduction
00:27
The Problem of Nulls
00:59
Creating Null Objects
05:58
Rewriting Null Returns
03:25
Section Recap
00:27
Introduction
00:36
The importance of Tests to Clean Code
01:32
Writing better assertions
04:17
Using the Act, Arrange, Assert structure
04:49
Replacing Mocks with real Objects
03:09
Using Test Data Builders
05:24
Using realistic test data
02:46
Section Recap
00:45
Introduction
00:54
Measuring code complexity
03:03
Using refactoring tools
03:49
Applying Standards with an editorconfig
04:21
Using a Spell Checker
01:31
Enforcing Code Quality
01:54
Section Recap
00:37
Refactoring Walkthrough
25:16
Conclusion
01:34

Meet Your Instructor

Gui Ferreira

Gui Ferreira

Guilherme Ferreira, also known as Gui, is a Minimalist Software Craftsman, passionate about simplicity and continuous learning. Gui is a Microsoft MVP for Developer Technologies, a Tech Speaker, a YouTuber, and a .NET content creator. With over 15 years of experience in software development, Gui went from Startups to Tech Giants. Along his journey, he got to know several hats, including Software Engineer, Architect, CTO, and Developer Advocate, gathering a diverse and invaluable skill set.

View all courses by Gui Ferreira

What's New

Getting Started: Building .NET Applications on AWS
course

Getting Started: Building .NET Applications on AWS

Learn how to build and deploy .NET applications on AWS using CDK, Lambda, DynamoDB, S3, and more.

Learn More
What's new in C# 14
blog

What's new in C# 14

This guide covers every new C# 14 feature, explains its benefits, and provides practical code examples to help you navigate how you can use them.

Learn More
Let's Build It: AI Chatbot with RAG in .NET Using Your Data
course

Let's Build It: AI Chatbot with RAG in .NET Using Your Data

Build a Retrieval-Augmented Generation (RAG) chatbot that can answer questions using your data.

Learn More
From Zero to Hero: SignalR in .NET
course

From Zero to Hero: SignalR in .NET

Enable enterprise-grade real-time communication for your web apps with SignalR.

Learn More
Deep Dive: Solution Architecture
course

Deep Dive: Solution Architecture

Master solution architecture and turn business needs into scalable, maintainable systems.

Learn More
Migrating: ASP.NET Web APIs to ASP.NET Core
course

Migrating: ASP.NET Web APIs to ASP.NET Core

A step-by-step process to migrate ASP.NET Web APIs from .NET Framework to ASP.NET Core.

Learn More
Getting Started: Caching in .NET
course

Getting Started: Caching in .NET

Let's make the hardest thing in programming easy for .NET software engineers.

Learn More
From Zero to Hero: Testing with xUnit in C#
course

From Zero to Hero: Testing with xUnit in C#

Learn how to test any codebase in .NET with the latest version of xUnit, the industry-standard testing library.

Learn More
Create a ChatGPT Console AI Chatbot in C#
blog

Create a ChatGPT Console AI Chatbot in C#

This walkthrough is your hands-on entry point to create a basic C# console application that talks to ChatGPT using the OpenAI API.

Learn More