David Fowler Profile picture
Distinguished Engineer at Microsoft on .NET, Creator of NuGet, SignalR and https://t.co/PiydKAsC8g Core, Barbadian 🇧🇧, Tennis Player, Father, other half @symonefowler
lexx Profile picture Vincent Bourdon Profile picture Kevin Miles Profile picture 5 subscribed
Jul 11, 2023 22 tweets 7 min read
Here's some code that is on the hot path on your application and you want to optimize it. This is what a typical C# developer would write (actually copilot wrote this). It's pretty clear, but suboptimal. How could you go about improving it? #dotnet #csharp There are lots of allocations here:
1. The string[] splitting up query string parts by &
2. Each key value pair string[] splitting each part by =
3. The List<string> of new results
4. The final string
Dec 31, 2022 6 tweets 2 min read
Discrete events masquerading as a workflow should be expressed as such. Consider the following event-based model: #dotnet The game has 3 events:
- GameStarted
- GameEnded
- OnQuestion

The order of execution should be obvious from the naming...
Dec 31, 2022 9 tweets 3 min read
Currently designing how this trivia game will work on multiple servers. I have 3 architectures in mind (Twitter can help me pick one, but I have a preferred one). Both clients are part of the same game. Games are ephemeral and last a maximum of 2 minutes. Architecture 1 - Using Redis as the game state storage and SignalR backplane.
Dec 17, 2022 9 tweets 2 min read
It's Friday so time for spicy opinions. Every single sample ASP.NET Core project I see uses CQRS and the mediator pattern or CLEAN architecture. I'm over the over engineering 🙃. #dotnet I lean very heavily towards YAGNI and readable code with minimal abstractions until needed. I appreciate that every situation is different, but like anything it's hard to appreciate the benefits when the "scale" problem isn't evident.
Dec 11, 2022 4 tweets 2 min read
Another cool tye feature is networking support between containers and processes on the host. This nginx configuration is referring the process running on the machine by host name "sample" but that application isn't running in a container. It manages all of the tricky ways to communicate between containers and local machine using (host.docker.internal) etc. This lets you run and debug your processes normally and run what needs to run as containers in your inner loop.
Dec 9, 2022 5 tweets 2 min read
Maybe I’ll try having chatgpt3 make code lock free Disappointed. It did a busy wait. Let me see if I can motivate it 😅 Image
Dec 6, 2022 7 tweets 1 min read
Structured logs via the stdout is *NOT* a good idea. Standard out is a single stream, and you should be using it for human readable logs. Push structured logs via another output stream in your application. Modern logging providers can push logs out to various sinks in the "right" target format. Loggers are just serializers at the end of the day. I can produce a log that has with the text "Hello World", that gets packed and shipped differently depending on the consumer.
Oct 20, 2022 17 tweets 6 min read
We're working on making ASP.NET Core and EntityFramework work with trimming and ahead of time compilation (.NET NativeAOT). One of the big challenges is moving away from dynamic runtime code generation. Let's talk about what that means👇🏾 #dotnet #aspnetcore Why do we care about trimming and NativeAOT? Faster startup and smaller output. This is useful for reducing the size of your output, which can be impactful for things like smaller container images.
Sep 22, 2022 4 tweets 2 min read
OK C# coding challenge from today's discussion. This came up today in the context of "async and concurrency is *HARD* even for very experienced developers". I will share some techniques after seeing some answers. #dotnet #csharp First version is using a CancellationToken
Sep 20, 2022 4 tweets 2 min read
Declarative VS imperative, which do you prefer and why? #dotnet #aspnetcore ImageImage What about now? ImageImage
Jul 8, 2022 10 tweets 3 min read
Here’s another “auth is hard in .NET” thread reddit.com/r/dotnet/comme… #dotnet #aspnetcore To help the team contextualize why it is hard outside of the domain itself being hard, it would be great to see some code samples. Samples from other frameworks that are runnable. Most of these threads conflate everything under the auth banner and require 20 questions understand
Jun 27, 2022 5 tweets 1 min read
COVID will be “over” when people stop posting tests results on Twitter. It’s not “normal” or “endemic” yet socially. It feels pretty inevitable at this point, there’s still a guilt associated with having it (you could have spread it unknowingly). It’ll be “like the flu” and “normalized” socially when people stop doing that. So, IMHO Covid isn’t “over” yet…
Jun 27, 2022 11 tweets 3 min read
This thread was good because it helped clarify my thinking. There are 2 phases (for simplicity) where ClaimsPrincipal shows up:
- The authentication flow
- The authorization flow

Claims are typically used to store authentication data. #dotnet #aspnetcore 🧵👇🏾 That data is then used to look up more user information (profile data) usually store in a database/cache. This profile data usually also contains permissions and authorization rules are then run over this user for different types of application "resources".
Jun 26, 2022 4 tweets 2 min read
The oral history of Dave Cutler is a real gem:
Part 1:
Part 2:
Windows NT is a marvel of an operating system and his work has been immensely impactful on the industry at large. I also love that he's an engineer through and through. Some gems:
- Engineers should care *deeply* about the quality of the code they write (he hated when he had bugs assigned to him).
- Coding != Software engineering. They brought strong engineering culture to Microsoft from DEC.
- Go interview elsewhere to know your worth😉.
Jun 15, 2022 5 tweets 2 min read
New feature that came out with minimal APIs in .NET 7 preview 5 (devblogs.microsoft.com/dotnet/asp-net…), the ability to declare parameter list surrogates: #dotnet #aspnetcore You can refactor long argument lists into structs as a "zero cost abstraction". The struct's members will be bound as if they were parameters declared on the method.
Jun 15, 2022 7 tweets 3 min read
Let me take you on my @msftorleans journey. Let's say you wanted to define a class that let callers subscribe to an event C#. It could look like this: #dotnet This implementation uses C# events, but let's be a little more verbose and define the contract for subscribing and unsubscribing callbacks:
Jun 14, 2022 4 tweets 2 min read
I thought this was common knowledge by now, but software engineers at “big tech” and in some of the major tech hubs in the US makes lots of money. I’d encourage you to look at levels.fyi to see the potential earnings at these companies. #techtwitter #BlackTechTwitter That said this is about potential. This site doesn’t show how many people exists at these levels, let alone how many underrepresented people exist at some of these levels.
Jun 12, 2022 4 tweets 2 min read
Weekend tennis, opponent was too good today. Gotta put in more work, tournament season is coming up #tennis Ran down this drop shot 💨
Jun 4, 2022 14 tweets 4 min read
Today we had a meeting about experimenting with a green threads implementation in .NET. More info to come soon, exciting times! #dotnet For clarity, these are threads managed by the runtime instead of the operating system. The net effect is that you can write synchronous looking code that scales as well as async/await does today.
Feb 12, 2022 5 tweets 1 min read
I'm not sure about using redis as a queue, seems like blocking operations block the connection? Also, when using BROP to monitor multiple queues, you end up shuffling the queue names so the queue at the front of this list doesn't take priority (round robin?) Or do you spin up multiple connections and balance the queues across them? It's a multiplexing problem (reminds me of HTTP/2).
Feb 6, 2022 18 tweets 6 min read
Lets talk about events. We want to write some code that reacts when something happens. This pattern exists in many domains from UI programming to IoT to serverless. What do the programming patterns for this look like today in #dotnet and #csharp? We create a button (imagine this was referenced by a form or some UI component), then hook up an event handler and write to the console when a button click event happens. This is the one of the most popular and idiomatic event handling paradigms in .NET today.