Because Developers are Awesome - page 2

Recent posts

Local development for the cloud: Transitioning to .NET Aspire

September 05, 2024  13 minute read  

I’ve been working on a new project recently. It requires that I work with microservices and containers as it will eventually be runnable on either Kubernetes or (more likely) Azure Container Apps. My latest task is to get ASP.NET Identity working with PostgreSQL. In order to properly debug the code, I need the ASP.NET bits to be running locally. But to integrate with PostgreSQL, I need to set up containers and docker compose. This all feels like “too much work”. Wouldn’t it be amazing if...

Making ASP.NET Core applications readable - the options patterns

September 03, 2024  6 minute read  

Applications are read more often than they are written. The normal situation when a developer comes onto a project is that anything from a couple of weeks to several months is requried to come “up to speed” on the code base. Making the efforts required for readability of the code is important, and I spend a ton of time up front to ensure my applications are understandable without needing an in-depth lesson from me on how it works. Let’s take an application I am starting (today actually). I...

Centrally managing dependencies in your C# solutions

August 15, 2024  3 minute read  

Today, I’d like to talk about the best way to centrally manage dependencies in your dotNET solutions. It’s common for a single solution to comprise multiple projects. The happy path for maintaining dependencies in Visual Studio involves right-clicking on the project and selecting “Manage NuGet packages…”. Once you have a set of packages, you can keep them in sync by right-clicking on the solution and doing the same thing. By using “Manage NuGet packages” for the solution, you can update m...

Better data validation exceptions with C#

August 10, 2024  6 minute read  

There are times when I look at code I have written and think to myself “there has to be a better way.” When I start thinking like this, I start by looking at the documentation - the .NET official documentation is incredibly well written and simple to digest, and the fundamentals section is something I believe every language documentation should aspire to. Take exceptions, for example. When I started my career in software development, methods were written with a block of validations at the ...

Building Bootstrap apps from SASS with ASP.NET Core

August 08, 2024  6 minute read  

I’m building a new web application with ASP.NET Core, and I’m using Visual Studio Code with the C# Dev Kit so that I can really dive deep into the benefits and problems of using VS Code as a Visual Studio replacement. A frontend project is a good one to start with since I can check out the ways that the solution is presented while still having all the goodness of the VS Code development experience for JavaScript and TypeScript. As part of the application, I wanted to build a lean Bootstrap C...

Organizing service injection in ASP.NET Core Minimal APIs

August 07, 2024  4 minute read  

For the longest time, the Controller was the only way to introduce an API into your application. With the latest versions of ASP.NET Core, Minimal APIs became available. These offered the potential to write less code and be more efficient since they didn’t carry the baggage of the controller with them. That does come with some drawbacks, however. For me, one of the main ones is that it is so much easier to write unreadable code. WIth some basic practices, however, you can use minimal APIs ...

The State of JavaScript Testing Frameworks 2024

August 03, 2024  11 minute read  

This week, I am adding a test framework to my ESM module template. I use a testing framework for both unit testing and integration testing. Like everything, test frameworks have evolved, and no test framework is suitable for all situations. However, it is one of those things you have to do if your project is destined to be long-lived. You should get into the habit of adding tests even if your project is not going to be long-lived. It’s a good habit. The words you want to look for are “tes...

Enforcing code style with eslint, prettier, and husky

July 22, 2024  14 minute read  

You may have noticed that I am developing a new project from my last couple of articles: TypeScript, ES Modules, and root-relative imports Building TypeScript projects with the swc compiler The project is a command line tool written in TypeScript. Today, I’m continuing my tooling story. How do I enforce code style within my TypeScript application? The go to tools in this area are eslint, prettier, and husky. I’ve already gotten a good chunk of help in ensuring quality code by usin...

Building TypeScript projects with the swc compiler

July 11, 2024  5 minute read  

In my last article, I set up a small project that I’m going to use for TypeScript development using ES modules that are “root-relative” - i.e. I don’t have to provide a relative path. I can use a path like #root/relative/path.js instead so that the code doesn’t change if I decide to move the source file I’m working on. I want to switch from importing “.js” files to importing “.ts” files. To do that, I need to set allowImportingTsExtensions. The tsc tool says I can’t do that unless I also ...

TypeScript, ES Modules, and root-relative imports

July 10, 2024  5 minute read  

As you might have gathered from my last article, I’m currently working in the TypeScript world. My experience with converting from CommonJS to ES Modules got me thinking - what is state of the art right now? So I delved in. I want to build a CLI tool using TypeScript and ES Modules but I want to use non-relative roots. What are non-relative roots? Well, if you want to import a module within your project with ES Modules, you might write something like this: import { something } from '../...