Git stash driven development

I’ve found myself using a pattern quite often recently, which I’ve been calling “git stash driven development” – that is, relying heavily on the magic of git stash as part of my development workflow. Normally I follow what I think of as a fairly typical TDD workflow: Write next test, watch it fail Write code to make it pass Commit Refactor ...

Read More »

Find the bug – The case of the degrading system – Answer

In my previous post I showed the following code, and asked what the bug was, and what the implications of that would be. class Program { private Timer nextcheck; public event EventHandler ServerSigFailed; static void Main(string[] args) { var program = new Program(); if(program.ValidateServerSig() == false) return; program.DoOtherStuff(); } public bool ValidateServerSig() { nextcheck = new Timer(state => ValidateServerSig()); var ...

Read More »

Find the bug – The case of the degrading system

The following code contains a bug, can you spot it? class Program { private Timer nextcheck; public event EventHandler ServerSigFailed; static void Main(string[] args) { var program = new Program(); if(program.ValidateServerSig() == false) return; program.DoOtherStuff(); } public bool ValidateServerSig() { nextcheck = new Timer(state => ValidateServerSig()); var response = DoRequest("http://remote-srv/signature"); if(response.Failed) { var copy = ServerSigFailed; if(copy!=null) copy(this, EventArgs.Empty); return ...

Read More »

WCF Is Dead and Web API Is Dying – Long Live MVC 6!

The time has come to say goodbye to Windows Communication Foundation (WCF).  Yes, there are plenty of WCF apps in the wild — and I’ve built a number of them.  But when it comes to selecting a web services stack for greenfield applications, you should no longer use WCF. WCF is dead There are many reasons why WCF has lost its ...

Read More »

Sorting and Grouping – organizing data with LINQ

Last week I introduced LINQ from the perspective of a C# game developer completely unfamiliar with the framework. Today I would like to continue exploration of LINQ by focussing on a particular set of its functionality: methods to arrange and organize data. In particular we will look into how we can sort and group our collections of items. Sorting with ...

Read More »

Code review challenge – The concurrent dictionary refactoring – answer

Here is the full method that we refactored: public void ReturnMemory(byte* pointer) { var memoryDataForPointer = GetMemoryDataForPointer(pointer); _freeSegments.AddOrUpdate(memoryDataForPointer.SizeInBytes, x => { var newQueue = new ConcurrentStack<AllocatedMemoryData>(); newQueue.Push(memoryDataForPointer); return newQueue; }, (x, queue) => { queue.Push(memoryDataForPointer); return queue; }); } And here is the allocation map for this method: public unsafe void ReturnMemory(byte* pointer) { <>c__DisplayClass9_0 CS$<>8__locals0 = new <>c__DisplayClass9_0(); CS$<>8__locals0.memoryDataForPointer ...

Read More »

Code review challenge – The concurrent dictionary refactoring

In a recent code review, I had modified the following code:   _freeSegments.AddOrUpdate(memoryDataForPointer.SizeInBytes, x => { var newQueue = new ConcurrentQueue<AllocatedMemoryData>>(); newQueue.Enqueue(memoryDataForPointer); return newQueue; }, (x, queue) => { queue.Enqueue(memoryDataForPointer); return queue; }); Into this code: var q = _freeSegments.GetOrAdd(memoryDataForPointer.SizeInBytes, size => new ConcurrentQueue<AllocatedMemoryData>()); q.Enqueue(memoryDataForPointer); Can you tell me why? Reference: Code review challenge – The concurrent dictionary refactoring from ...

Read More »

Hack the Remote Desktop .RDP file

Glad I found out about the string to add to a .RDP file to make it connect to the administrative console whenever your remote supports that:   connect to console:i:1 Reference: Hack the Remote Desktop .RDP file from our NCG partner Jeroen Pluimers at the The Wiert Corner blog.

Read More »