C# Interfaces

Welcome to this review of the Pluralsight course “C# Interfaces” by Jeremy Clark.image

Jeremy makes developers better. With over 15 years of experience in application development, he helps developers take a step up in their skillset with a focus on making complex topics approachable regardless of skill level. He is a Microsoft MVP for .NET, and he has authored seven courses for Pluralsight.


This course forms part of the following learning paths:

This is categorized as an Intermediate level course, but is quite easy to follow as long as you have a basic understanding of the C# language.

If you’ve never worked with C# before there are several other courses that can help you, my recommendation is Scott Allen’s C# Fundamentals with Visual Studio 2015 course.

The C# Interfaces course has six modules and the duration is 2 hours and 52 minutes at standard playback speed.

Interfaces, Abstract Classes, and Concrete Classes

C# Interfaces are very important, because they help us to write code that is maintainable, extensible and easily testable.

This module explains how to create interfaces and how they help maintainability and extensibility.

There are demos for creating abstract classes, concrete classes and interfaces, followed by a clip discussing how to decide between a concrete class and an abstract class.

Using Interfaces to Future-Proof Code

This module discusses programming to an abstraction rather than a concrete type.

Interfaces give you these abstractions, and they help to future proof your code because you can create new implementations of your existing interface, and not need to change a lot of existing code.

The majority of this module is spent demoing concrete classes and interfaces.

Creating Interfaces to Add Extensibility

The previous two modules have explained how interfaces can make code more maintainable, and this module focuses on how interfaces make code extensible.

Jeremy begins with the Repository Pattern. If you haven’t heard of the Repository Pattern before, Scott Allen presents a module on it in the Design Patterns Library course.

Basically it is a design pattern inside of applications that need to perform data access, and the idea is to separate business code from data access and increase testability. Here is the definition from Patterns of Enterprise Application Architecture:

“Mediates between the domain and data mapping layers using a collection-like interface for sccessing domain objects”

Jeremy describes the Repository as a layer to separate our application from the data storage technology.

We see code for an IPersonRepository interface, which interacts with a collection of person objects. This contains Create Read Update and Delete methods.

Jeremy create three repositories: WCF Service, CSV File, and SQL Database. Then he creates a repository factory with a GetRespository method of type IPersonRepository, and the concreate type returned is based on a switch statement. This part of the code is revisited and refined later in the course.

With this repository factory in place, the duplicate data access logic can be eliminated. We instead have a FetchData method that takes a repositoryType of type string.

Explicit Interface Implementation

This module begins with a description of explicit interface implementation.

Jeremy uses the example ISaveable.Save(), defined within our concrete class, and we have a second Save method defined in the same class.

Using explicit interface implementation, we can get different behaviors by casting our concrete type to each interface: this will make a lot more sense when you see the demonstration.

Jeremy then explains why we might need to use this: so that we can have two methods with the same name and parameters, but different return types.

We see that when you ask Visual Studio for a standard interface implementation, it will automatically create an explicit interface implementation whenever it knows that the standard one would be invalid.

Finally we see Interface Inheritance: where an interface implements another interface. If you are new to interfaces, this might sound strange, but this is actually a very important technique for simplifying complex code.

Interfaces and Dynamic Loading

This module examines the testability aspect of interfaces.

Jeremy mentions Test Driven Development, but this is not a Test Driven Development course and I recommend watching one if you aren’t familiar with it.

Jeremy criticizes the earlier code using and switch statement, and compares the features of a Compile-Time Factory with those of a Dynamic Factory.

In the demonstration, we see how to fetch the repository type from the App Settings file. This allows us to replace our data storage mechanism just be making a simple configuration change. No need to rebuild our code.

He introduces the basics of Unit Testing: it’s about testing small pieces of code. He explains the difference between unit testing and integration and why both are needed.

This module also demonstrates adding a new layer and a fake repository, and writing some unit tests using the MSTest framework.

Advanced Topics

This module covers the Interface Segregation Principle. This is one of the SOLID principles, and to gain a thorough understanding of these I recommend watching Steve Smith’s SOLID Principle of Object Oriented Design

Jeremy explains the similarities and differences between an Interface and an Abstract Class

He also explains a bit about Dependency Injection and Mocking

Related courses: Another very good course by Jeremy Clark that is not on the C# Deep Dive or C# End to End learning paths but follows on very nicely is Abstract Art: Getting Things Just Right. If you want to learn Dependency Injection in a bit more detail, Jeremy also has a course called Dependency Injection On-Ramp.

Exercise files (pluralsight plus subscribers only) contains: slides and code (before and after) for each module.

Summary / Verdict

This is the most popular of Jeremy’s courses, with an average 4.5 star rating out of 2682 reviews. A couple of reasons for this are:

  1. Interfaces are an enormously important concept for professional developers, but are not absolutely essential for solving simple problems. So beginner books, and even some more advanced books tend not to explain them very well. This mean there is a demand for a good course like this to explain them
  2. It is an interesting course because it is very varied. The beneficial effects of using interfaces are wide and numerous, but Jeremy keeps it simple by categorizing these benefits as maintainability, extensibility and testability. So this course covers a lot of ground, but remains easy to understand throughout.

4 thoughts on “C# Interfaces

  1. Pingback: C# End to End Learning Path | Zombie Code Kill

  2. Pingback: C# Deep Dive Learning Path | Zombie Code Kill

  3. Pingback: Getting to Great with C# | Zombie Code Kill

  4. Pingback: Getting to Great with C# Learning Path | Zombie Code Kill

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s