Wednesday, August 5, 2015

My favorite Visual Studio 2015 feature–PerfTips

If there is one feature I have to pick from the long list of new things added to Visual Studio 2015, it’s the PerfTips feature. Gone are all the stopwatches in your code, without the need of separate tools you get a simple performance measurement. No excuse any more to ignore the performance characteristics of your code…

If you are using the debugger in Visual Studio 2015, you’ll notice a small tooltip in the editor at the end of the code line indicating how long the program was running since the previous step:


You can click on this tooltip which will bring you to the Diagnostic Tools window where you can see the history of PerfTip values on the Debugger Events break track:


More information here:

Tuesday, August 4, 2015

Decompile F# into C#

Let’s continue our journey in F# land that we started last week. On the I found a great blog post where language concepts were implemented in F#, decompiled to IL and compiled again to C#. This gives you a great insight(if you are a C# developer) in how the F# language works behind the scenes and all the work the compiler is doing for you.

When you look at the results, the biggest differences can be found when looking at F# specific features like Record types and Pattern Matching. Generally, the F# code is much shorter than the equivalent C# code.

It’s almost painful to see how much code you need to write in C#… Verwarde emoticon

Monday, August 3, 2015

Generating unique identifiers across a set of server nodes

Distributed systems come with their own set of problems. One of these problems is the generation of unique identifiers across multiple nodes. You can rely on the database to generate a sequential guid, but this hinders scalability and makes your systems error-prone.

While browsing through the MassTransit code base, I noticed they were using a separate NuGet package called NewId. NewId is a unique id generator with 2 important characteristics:

  • Unique Id generation at a specific server can happen without interaction with other servers
  • Id’s should be ordered(important for database optimization)

It’s inspired by (the retired) Twitter Snowflake and Boundary Flake implementations.

Certainly useful if you need to build scalable solutions…

Friday, July 31, 2015

Continuous Delivery: Decouple release from deployment

For most organizations releasing and deploying are the same thing while in fact these are 2 separate things:

  • Deployment: A technical handling where a new version of the software is deployed to a specific environment
  • Release: A business handling where the customers are informed that a new version of the software is available and can be used

As you combine these 2 handlings in one, releasing becomes a risky business. The same moment you roll out the code on production, your users are eagerly waiting to start using these new features they so desperately needed.  At that moment, you don’t want that things go wrong.

So what do most organizations do? They introduce long release cycles where an application has to go through multiple environments and test cycles before finally reaching production.And they try to reduce the risk by only going through this cycle one or 2 times a year.

But while they are thinking that this limit the risk, it actually has an opposite effect. The moment Murphy kicks in (and it will) you’re into trouble. Why? Because you have to go step by step through this really long release cycle again before you can apply your patch or hot fix to production. By then this fix is not so ‘hot’ any more. And in the meanwhile error reports keep coming in…

Now this is the theory, what I see in practice (a lot!), is that when there is really something wrong on production, the whole process is thrown out of the window and the solution is deployed immediately  to production. Wooops, maybe not the best idea either?!

Could there be a better solution?

Of course! Otherwise I shouldn’t be writing this blog post. First of all, let these 2 handlings(deployment and release) remain separate things. Deploy your feature to production as soon it’s ready but hide it from the users. Later on, you can do a ‘release’ and enable the feature on production just by toggling a configuration switch. Even better is that you can gradually enable a feature for a subset of your users. The moment you notice that performance is going down or exceptions start appear, you can easily disable the feature again and fix it without impacting the users. This is exactly the approach that companies like Facebook and Amazon are using.

Now one important recommendation I want to make is to go one step further and split out the deployment itself in multiple steps:

  • In step 1, you deploy your database changes. No code changes are deployed yet. Of course this means that database changes should happen in a non breaking fashion. For example, if you add a new required database column, make it nullable first or provide a sensible default.
  • In step 2, deploy your application change.  When you’re ready announce the release and enable the feature.
  • If everything is working as expected, you can continue to the last (optional) step and update the database again. For example, for the new column you created before, you can now make it not nullable and remove the default value.

This provides a fault tolerant approach in handling releases and is a first step towards continuous delivery.

Thursday, July 30, 2015

Software testers…

I had to smile while reading following tweet… :-)

Wednesday, July 29, 2015

Why I’m an F# fan…

If you are still in doubt if you should try F# or not; read the following blog post In this post Simon Cousins built the same application once using C# and a second time using F#.

The results speak for themselves…


Tuesday, July 28, 2015

Entity Framework Connection Management

Some developers asked me to look into an issue they had with Entity Framework. A query that took milliseconds in SQL Server Management Studio, took minutes to execute when called through Entity Framework.

I had no clue what was the issue, but the following blog post brought some insights: This post brought me to the following MSDN article where I saw the following note:


The trick is to call Entity Framework and materialize the results as quick as possible so the connection gets closed.