Friday, 22 January 2021

The State Pattern

 

How many developers does it take to change a lightbulb? With the State pattern, not very many.

Topics include:
  • The State Pattern
  • Design Patterns
  • WPF

IAsyncEnumerable and Yield Return

Getting data from a Web Service? Why wait until it's all arrived before you start processing?

Topics include:
  • C#8
  • .Net Core
  • IAsyncEnumerable<T>
  • yield return
  • async
  • await
Related videos:

Thursday, 21 January 2021

Synchronous Yield Return

 

Ever wanted to leave a function, and then come back in where you left off? In C# yield return does the trick.

Topics include:

  • yield return
  • IEnumerable<T>
  • Collections
  • Fibonacci sequence
Related videos:

Collections vs In-Memory Database

 

Entity Framework Core in-memory databases are great for unit testing, but would we ever use them in production code?

Topics include:

  • .NET Core
  • Entity Framework Core
  • In-Memory Database
  • Unit Testing
  • TDD
  • Mocking

C# Extension Methods and the Interface Segregation Principle

 

How do you add a method to and interface without altering the interface? In C#, the answer is extension methods.

Topics include:
  • C#
  • Extension methods
  • SOLID code
  • The Interface Segregation Principle
  • Turtle graphics
  • Kebab casing
Related Videos:

C# Contravariance

Got your head around covariance? Here's contravariance - welcome to opposite land!

Topics include:

  • Contravariance
  • C#
  • Liskov Substitution Principle
  • Interfaces
  • Delegates
  • Sorting
Related videos:

Wednesday, 20 January 2021

C# Covariance

Is a bag of apples a kind of bag of fruit? It all comes down to covariance.

Topics include:

  • Covariance
  • C#
  • Liskov Substitution Principle
  • IEnumerable<T>
  • List<T>
  • Inheritance
  • Collections
Related videos:

Implementing IEnumerable

The C# foreach loop works on any standard collection, but what do we need to do to make it work on collections we've written for ourselves?

Topics include:
  • C#
  • foreach
  • IEnumerable<T>
  • IEnumerator<T>
  • LINQ
  • Extension methods
Related videos:

Explicit Interface Implementation

 'Disambiguation' is a wonderful word - and it's an important concept in software too. Here's how C# explicit interface implementation can disambiguate otherwise indistinguishable methods.

Topics include:
  • C#
  • Interfaces
  • Explicit interface implementation

Random Changes

 

There are big differences between .NET Framework and .NET Core, but a number of small ones too. Here's a random example - which explains a lot about .NET Standard too.

Topics include:

  • .NET Core
  • .NET Standard
  • .NET Framework
  • Random numbers
  • Rock, Paper, Scissors
Related videos:

SOLID: The Dependency Inversion Principle

 

Dependency Inversion doesn't just mean reversing your existing dependencies. It's about making your entire system easier to extend and maintain.

Topics include:

  • C#
  • SOLID Code
  • The Dependency Inversion Principle
  • DIP
  • Dependency Injection
  • Interfaces
  • Rock, Paper, Scissors
Related videos:

SOLID: The Interface Segregation Principle

 

The Single Responsibility and Open-Closed Principles help us to keep our classes under control. But how do can we do the same for interfaces?

Topics include:

  • C#
  • SOLID Code
  • The Interface Segregation Principle
  • ISP
  • Interfaces
  • Task Parallel Library
  • Turtle graphics
Related videos:

SOLID: The Liskov Substitution Principle

 

Inheritance is one of the most fundamental features of Object-Oriented Programming. Why do we get it wrong so often?

Topics include:

  • C#
  • SOLID Code
  • The Liskov Substitution Principle
  • LSP
  • Inheritance
  • Substitutability
  • Abstract classes
  • Sealed classes
Related videos:

Wednesday, 13 January 2021

SOLID: The Open-Closed Principle

 

Making classes open to extension but closed to modification can improve productivity and reduce bugs. Here's how it's done.

Topics include:

  • C#
  • SOLID Code
  • The Open-Closed Principle
  • OCP
  • Strategy Pattern
  • Rock, Paper, Scissors
  • Interfaces

SOLID: The Single Responsibility Principle

 

Why should a class have only one reason to change? A quick look at the first SOLID principle.

Topics include:

  • SOLID Code
  • SRP
  • Single Responsibility Principle
  • Rock, Paper, Scissors, Lizard, Spock

C# Events

 

Most C# developers use events, but do you know how they relate to delegates? Have you ever implemented an event manually? All is explained here.

Topics include:

  • C#
  • Events
  • Delegates
  • Lambda expressions
  • Auto-implemented events
  • Manually-implemented events
  • add
  • remove
Related videos:

C# Delegates and Lambdas

 

C# programmers use delegates and lambdas every day. But do we really understand what they are and how the are related?

Topics include:

  • C#
  • Delegates
  • Lambda expressions
  • Func
  • Action
Related videos:

C# Null Forgiving Operator

 

One of the more obscure features of C#8 is the Null Forgiving Operator. Here's how it works, and when it can get you out of a bind.

Topics include:

  • C#
  • C#8
  • .NET Core
  • Nullable references
  • Null forgiving operator
  • null!
Related videos:

C# Nullable References

 

The biggest new feature in C#8 is nullable references. Here's a quick look at how they work and why you should use them.

Topics include:

  • C#
  • C#8
  • .NET Core
  • Composition
  • Association
  • Nullable references
  • Nullable values
Related videos:

C# async, await and Task

 

Just like JavaScript, C# has async and await keywords. Here we explore the similarities and differences between the two languages.

Topics include:

  • C#
  • async
  • await
  • Tasks
  • Task Parallel Library
  • Asynchronous programming
Related videos:

EF Core In-Memory DB Best Practices

 

In-memory databases are great for unit testing, but tread carefully if you want to avoid false positives - and worse, false negatives.

Topics include:

  • .NET Core
  • Entity Framework Core
  • Unit testing
  • Test Driven Development
  • Mocking
  • In-memory databases
Related videos:

EF Core In-Memory Database

Writing a mock repository for unit testing can require a large amount of coding that simply duplicates the features of a real database. Nowadays, the Entity Framework Core In-Memory database does the work for you.

Topics include:

  • .NET Core
  • Entity Framework Core
  • Unit testing
  • Test Driven Development
  • Mocking
  • In-memory databases

Units

 

Ever called a function passing seconds instead of milliseconds? Or metres instead of feet? Here's a robust way to avoid problems with units.

Topics include:

  • C++
  • C++ 11/14
  • Time
  • Units
  • Type safety
Source code available at: https://github.com/JasperKent/Units

ASP.NET Core Pipeline Events

 

The pipeline works very differently in ASP.NET Core from ASP.NET Framework. Here we examine one aspect of the differences.

Topics include:
  • C#
  • ASP.NET Core
  • Middleware
  • Authorization
  • Authentication

JavaScript Async and Await

Once you've got to grips with JavaScript promises, you can make your code much more legible using the keywords async and await.

Topics include:
  • JavaScript
  • async
  • await
  • Promises
  • Ajax
  • Web Services
Related videos:

Promises, Promises

Promises are becoming ever more popular in JavaScript, but it's not always obvious what the benefits are. Here a simple caching example explains the essentials.

Topics include:

  • JavaScript
  • Promises
  • Ajax
  • Web Services
Related videos:

Dynamic Overloading

 

The dynamic keyword allows decisions about object type to be deferred until runtime. One benefit of this is that we can make method overloading decisions at runtime rather than having them locked in by the compiler.

Topics include:

  • C#
  • dynamic
  • Polymorphism
  • Overloading
  • Strong typing

IEnumerable vs IQueryable

 

The two interfaces IQueryable and IEnumerable seem almost interchangeable. Here I discuss one of the key differences, and how it can have a serious effect on performance.

Topics include:

  • C#
  • IQueryable<T>
  • IEnumerable<T>
  • Extension methods
  • Entity Framework
  • SQL
  • Performance
  • Deferred execution
Related videos:

The State Pattern

  How many developers does it take to change a lightbulb? With the State pattern, not very many. Topics include: The State Pattern Design Pa...