Skip to main content

Posts

The hub-and- spoke network topology for developers

A common network topology used when building cloud infrastructures is the hub-and-spoke model. As I noticed that this model is not always well understood by developers, here is my attempt to describe this model from a developers viewpoint. What Is a Hub-and-Spoke Network Topology? A hub-and-spoke network topology is a type of network architecture where all devices are connected to a central hub. This central hub acts as a focal point for communication, and all the spokes (devices) communicate through this central hub. Think of it as the hub being the center of a wheel, with spokes radiating outward to various endpoints. This topology is also commonly referred to as a star topology. As the name suggest, this topology has 2 key components: Hub : The central hub is a device that serves as the core of the network. It can be a physical device like a switch or a logical point in the network. The hub is responsible for managing and directing the flow of data between all connec...

Add custom properties to ILogger

By default when logging messages through ILogger only objects that have a placeholder in the message template are logged. For example, when executing the following line of code: the following information is logged: This is something that you can also notice when you check the warning you get when hovering over the message:   But what if you want to log these extra properties? One way to get this done is by using scopes to add custom properties. Typically this is used for multiple log entries, but it also works for single log statements:   More information: Logging in C# - .NET | Microsoft Learn

Property based testing in C#–How to change the number of runs?

After gaving my talk about Property Based Testing , I was contacted by one of the participants with the following question: How to change the number of test runs? In case you have no idea what I’m talking about; by default the property based testing library( FSCheck in my case) will generate a number of inputs and run the tests  for all these inputs. By default 100 inputs are generated and tested:   You can change the number of test runs either by setting the MaxTest property on the [Property] attribute: Or by passing a configuration object when calling Prop.ForAll

VISUG Property based testing in C#–Slides and demos

Yesterday I gave a presentation at the Belgian Visual Studio user group( VISUG ). In case you couldn't be there or you would like to have my slides and demos, here is all the material: Slides: https://github.com/wullemsb/presentations/blob/main/VISUG%20-%202023/Property%20based%20testing%20in%20C%23.pdf Demos: wullemsb/propertybasedtestingdemo: Demo's for the property based testing presentation (github.com)   Also check out my blog series about Property Based Testing: Part 1 – Introduction Part 2 – An example Part 3 – Finding edge cases Part 4 – Writing your own generators Part 5 – Locking input

NuGet.CommandLine.CommandLineException: Error parsing solution file

You have to love these days when everything seems to go haywire at the same time. Your code no longer compiles, your CI build status turns red and your unit tests become flaky. Today turned out to be one of such days as our build started to fail with the following error message: System.AggregateException: One or more errors occurred. ---> NuGet.CommandLine.CommandLineException: Error parsing solution file at D:\b\3\_work\154\s\Source\MyApp\MyApp.sln: Exception has been thrown by the target of an invocation. In our pipeline we were using the NuGetToolnstaller task: - task: NuGetToolInstaller@1 inputs: versionSpec: '4.x' We had just installed the latest version of the Visual Studio Build tools on our build server. This new version has a breaking change with regard to older versions of NuGet. As a fix, we switched to a newer NuGet version: - task: NuGetToolInstaller@1 inputs: versionSpec: '5.x' That’s it!

Rearchitecture is a sign of success not failure

An important lesson for a software architect is to design the system for the requirements you have today not for what a possible future could look like. Generated by Dall-E 2 A lot of systems are built with accidental complexity that could have been avoided. I’ve seen really complex high performant code for a system that is used by 10 users, a microservices solution containing 40+ services all maintained by one small team, a real-time event source setup for a system that is mostly CRUD and I can keep going… There is a reason that Martin Fowler talks about a monolith first approach . So if you need to built a system that should support 50 customers, don’t build one that can support 50.000 customers. Start small and wait until you have that many customers that they start to overload your system.  And that is great news because it means that you are successful! The truth is the majority of applications are never going to reach that stage. And even if you do start to get overload...

.NET 6 - Parallel.ForEachAsync

You maybe used Parallel.ForEach() before. It allows to iterate over a collection in a parallel way. It works similar to a Parallel.For loop. The loop partitions the source collection and schedules the work on multiple threads based  on the available processors in a system. Unfortunately the Parallel.ForEach() cannot be used for asynchronous work. Async vs parallel It is important to understand that "async" and "parallel" are two different concepts. Although they are both related to concurrent programming, they serve different purposes and are used in different contexts. Async is used to make non-blocking I/O operations and asynchronous code execution. It is primarily used for tasks that may take some time to complete, like reading from a file, making a network request, or performing database operations. Parallel however refers to parallel programming, which is about executing multiple tasks or operations simultaneously to improve performance and ...