Refactoring: Replace Exception with Test
Exceptions are mechanism to transport information about errors in object-oriented code. But they come with performance hit when not used carefully. Still we find a lot of code when exceptions are not avoided but used as a control mechanism in code flow. This post introduces replace exception with test refactoring that helps us to avoid at least some exceptions.
New expression bodied members in C# 7.0
Although expression bodied members have been supported in C# few years there were still room for some new ones. C# 7.0 introduces expression bodied constructors, destructors, getters and setters. This blog bpost goes through all these new expression bodied members and shows how to use them. Also a little peek behind the compilator curtains is made.
Internals of tuple literals
My last post about tuple literals gave brief intorduction to these. This post goes to internals of tuple literals, peeks behind the compiler and shows what happens with tuple literals internally. This post is for developers who are new to tuple literals and want to gain more deep understanding of these.
Refactoring: Improving the Design of Existing Code
Although I bought refactoring book by Martin Fowler years ago it is still valid. I call it one of the timeless books about coding and I consider it as a mandatory reading specially for novice programmers who are entering the field. Of course it is also useful handbook for those already in business. This refactoring book covers and organizes most of changes we are doing to source code every day and it greatly helps us to understand the nature of those changes at crafting level.
Performance of compiled queries in Entity Framework Core 2.0
Before applying any optimizations to our code we have to ask one question: what is the cost of improvement and is it really improvement? Compiled queries in Entity Framework 2.0 are categorized as high-availability feature but before making any decisions we need to know what is the actual win. This blog post introduces the measurements I made with simple database context to compare compiled and uncompiled queries in Entity Framework Core 2.0.
Writing IL code on Visual Studio
Microsoft Intermedia Language (MSIL) is .NET assembly language that is standardized under name Common Intermediate Language (CIL). All .NET compilers turn source code to this language. Although we hardly have a situation where we have to write intermedia language (IL) code directly it is still good to know how it works and how it is supported on Visual Studio. This blog post fills the gap and shows how to write IL code on Visual Studio.
Real-time talk between Windows 10 IoT Core background task and ASP.NET Core web application
My previous blog post introduced how to make ASP.NET Core 2 web application run on Windows 10 IoT Core. It was default web application created on Visual Studio and published as an executable. But this is not enough for IoT scenarios. When we build web application that runs on IoT board we need this application to do something. Be it displaying sensor data or controlling some hardware. This blog post shows how to make Windows 10 IoT background task talk with web application using WebSocket.
How to avoid overlapping timer calls?
Timers are useful .NET feature. With timers we can execute code with specified interval. With real scenarios we can easily face situations where timer calls its callback again but previous call is not finished yet. It may end up with loading some external system too much. It may also end up by making unexpected parallel data processing that distorts the results. This post introduces some options to avoid overlapping timer calls.
Are lock and Monitor the same in C#?
Working on some threading stuff I stumbled upon some discussions about lock and Monitor. Some say they are different and some say they are the same. I took few minutes of time to make some simple experiments with both of these. This blog post shows what C# compiler does with lock statement. As I had to use also Monitor class I added one example here how to use it instead of lock.