Image for post
Image for post

I’m not ashamed to admit that for a long time I avoided writing tests for my code. I saw it as something that took up precious time that I could have spent on “real” coding. However, after experiencing first-hand the headache caused from having to maintain production code with little-to-no tests, I’ve been convinced that writing tests really are worth your time. Too many times have I been bitten by hidden bugs, that could have easily been identified if the appropriate tests were in place.

Test Driven Development

Test Driven Development (TDD) is a software development cycle that focusses on describing the behaviour of your code first using tests, then implementing those behaviours. The advantage of this is that, once you have defined exactly how you expect you code to behave (including handling errors and edge cases), you can be confident that your implementation will actually handle all these behaviours properly, and it’s less likely that bugs will creep in. …


Image for post
Image for post

I recently wrote a blog post introducing some of my favourite NuGet packages: My Top 4 NuGet Packages for ASP.NET Core. In that post, I briefly introduced a package called MediatR. Today, I will dedicate this post to revisiting MediatR in further detail.

What is MediatR?

MediatR is an implementation of the mediator pattern. It is a behavioural software design pattern that helps you to build simpler code by making all components communicate via a “mediator” object, instead of directly with each other. This helps the code to remain highly decoupled and reduces the number of complex dependencies between objects.

A good real-world example of the mediator pattern is the air-traffic control (ATC) tower at airports. If every plane had to directly communicate with every other plane, it would be chaos. Instead, they all report to the ATC tower, and the tower decides how to relay those messages to other aircraft. In this, scenario the ATC tower is the mediator object. …


Image for post
Image for post

In this article, I will teach you the basics of making your own web app, by creating a checklist app. ASP NET Core will be used to create a CRUD API and Vue will be used to create the frontend UI. Using the knowledge gained here, you should be able to apply it to start making your own web apps. You can find the complete solution in the GitHub repository.

We will first start with building the API and then move on to the Vue client.

Creating a checklist API

Start by creating a new ASP NET Core Web API project in Visual Studio.


Image for post
Image for post

When you think about database providers for ASP NET Core apps, you probably think about Entity Framework Core (EF Core), which handles interacting with SQL databases. But what about the NoSQL options? A popular option for NoSQL is MongoDB. So in this article we’re going to learn how to create a simple ASP NET Core CRUD API using MongoDB as the database provider.

I have created a GitHub repo for this project, so please feel free to clone it here.

Start by creating an ASP NET Core Web API project and then install the MongoDb C# Driver NuGet package:

MongoDB.Driver

Actually creating the MongoDB database is outside of the scope of this tutorial, so I will assume that you already have a MongoDB database, either locally or hosted on some provider. I personally used Docker to host my database locally, so you can see how I did that by seeing my docker-compose.dcproj and mongo-init.js


Image for post
Image for post

Method overloading and overriding are two common forms of polymorphism ( the ability for a method or class to have multiple forms) in C# that are often confused because of their similar sounding names. In this article, we show the difference between the two with some practical code examples.

Overloading

Overloading is the ability to have multiple methods within the same class with the same name, but with different parameters. Each of these methods has their own implementation as well, meaning that they can behave differently depending on what is passed in.

Overloading is known as compile-time (or static) polymorphism because each of the different overloaded methods is resolved when the application is compiled. …


Image for post
Image for post

User authentication and authorization can be difficult and time consuming. Getting it wrong can also have disastrous consequences, such as malicious users accessing and stealing personal or sensitive information from your app.

Unless you are a large organisation that can afford to spend lots of time on developing a bespoke authentication/authorization system, it is often best to make use of existing solutions to streamline your development process and give you peace of mind.

Auth0

Auth0 is one such solution, and could be called Authentication as a Service (AaaS) or Identity as a Service (IDaaS). In short, it is a complete user management system that can be used to authenticate requests to your application. It has plenty of built in features that you would expect from modern authentication, such as social login (Google, Facebook, etc.), …


Image for post
Image for post

.NET 5.0 was officially released this week, bringing with it a range of improvements to the .NET ecosystem. Like many .NET developers, I was quick to download it and give it a test run. This article discusses some of the most exciting new features in .NET 5.

.NET is Microsoft’s developer platform, used to write applications for a range of different applications, including web, mobile and desktop applications. .NET is the predominant platform for developers that write in the C#, F# and VB languages.

Originally the .NET Framework was designed to run only on Windows machines, giving it significant limitations. That all changed in 2016, when the first version of .NET Core was released, allowing developers to write cross-platform applications for almost any type of device. …


Image for post
Image for post

Software development is a complex task and as a developer you gain nothing from “reinventing the wheel”. I’m a firm believer that you should make your life as easy as possible as a developer, by using tried and tested packages where possible; it will take so much headache out of your development experience.

Below are a few of the packages that I use in most of my projects. I believe they make for an easier development experience and make my code much easier to maintain. I would recommend that you consider them for your own projects in the future. …


Image for post
Image for post

I’ve recently gotten into using Docker in my development cycle and I’m really enjoying how much of a wonderful tool it is. One thing that always used to be a pain was setting up a development server to run SQL Server. Now with Docker, I can just spin up a Docker container and I instantly have a SQL Server ready to go.

I recently wrote a blog on Getting Started with Docker. If you haven’t read that yet, I’d recommend checking it out first.

In this tutorial I will first show you how to configure ASP.NET Core to run on Docker, then how to configure SQL Server on Docker. Finally, I will walk you through a simple CRUD app based on this configuration, and using EF Core as the database ORM. …


Image for post
Image for post

Hangfire is a .NET library that makes it really easy to adding background tasks to your .NET app. It supports one-off “fire and forget” tasks, as well as scheduling recurring tasks. On top of that it supports persistence, so all of your tasks will continue to exist even after restarting your app.

Why do I need background tasks?

Background tasks are important in cases where you need to perform an operation that takes a long time to execute. Without a background task, the response to the user would be delayed while waiting for the task to complete, which leads to a bad user experience. With a background task, the process can continue running in the background and a response can be immediately sent to the user. …

Sam Walpole

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store