Designing methods with a focus on logging and exception handling is crucial for building maintainable and debuggable software. In this post, we’ll discuss some C# logging best practices about designing method in a way that gives us the most level of details. A lot of time we see that an error happens in our software, …
C#
Asp.Net Core Best Practices: A Summary
There are a lot of different small points to remember about Asp.Net Core best practices. This post intends to summarize the most important points in a way that makes it easy to preuse quickly. This post does not try to be a comprehensive guide, but a quick reference for many different points that exist on …
C# Entity Framework and LINQ Best Practices
There are a lot of points about best practices when using Entity Framework and LINQ. Sometimes we need to cipher through a lot of information. The goal of this article is to summarize some of the best practices when it comes to using LINQ and Entity Framework in a way that is easy to digest. …
C# Asynchronous and Parallel Programming Best Practices
I’ve already written about Asynchronous and Parallel programming before here and here. This is one of those subjects that can be tricky and is the source of a lot of bugs. But I feel the posts that I’ve written before might be too long or they are too specialized, hence not very approchable. In this …
Thread Affinity in Parallel Programming Using TPL
Thread affinity refers to the assignment of threads to specific processors or cores on a multi-core CPU. When a thread is bound to a specific processor or core, it is said to have affinity to that processor or core. This is in contrast to thread migration, where a thread can move between different processors or …
Inheritance in Programming: Best Practices and Valid Use Cases
Inheritance is a powerful concept in programming that allows classes to inherit properties and behavior from parent classes. When used correctly, it can improve code readability, reduce redundancy, and simplify software development. However, when used incorrectly, inheritance can lead to code that is difficult to understand, maintain, and modify. Unfortunately, inheritance is often misused in …
How to use ConfigBuilders for User Secrets Management in Asp.Net MVC 5
When it comes to storing our app secrets, Asp.Net Core has a built-in mechanism to do that out of the box. But this is not the case for Asp.Net MVC 5. For MVC 5, we need to install custom configBuilders packages in order to be able to have the same functionality. There are many other …
Integration Test In Asp.Net Core 6 Using SqlServer Image and TestContainers
This post is about writing integration tests and TestContainers. As you might know writing integration tests against the in-memory provider is a bad practice. Because it only works well with trivial solutions. Mostly because the in-memory API of IQueryProvider doesn’t match the LINQ query provider. Here’s a good article called “Avoid In-Memory Databases for Tests” …
Enum Serialization: System.Text.Json vs Utf8Json vs Jil vs Newtonsoft
I was reading about the new System.Text.Json in .net core 3 and comparing its speed to other libraries. You can read more about it here if you’re interested. To put it shortly, the new serializer is faster then Newtonsoft but not as fast as others. Also the enum serialization between different libraries can be inconsistent. …
Careful Model Binding JavaScript ISO Date Format to DateTime
It is agreed by the .Net community that DateTime should not be used when we develop .Net applications. You can read more about why that here. In short the least we can do is to use DateTimeOffset instead. But this post is not about the common problems associated with using DateTime. But rather it’s about …