Compiler aided overloading

I was playing with xUnit.net for a pet project of mine. I wasn’t writing test cases with xUnit rather I was using the underlying xUnit engine to discover test cases and invoke calls that execute desired test cases. Forget the details of what I was doing, let us talk about it in a different post. But for now, I was consuming xUnit’s backend library.

XunitFrontController is the gateway to xUnit’s world; AFAIK. You create an instance of the controller specifying the target assembly.

var xfc = new XunitFrontController(
  AppDomainSupport.IfAvailable,
  "{full path of the assembly where the test cases reside}"
);

Continue reading Compiler aided overloading

Problem Reduction

Problem Reduction is what I call when a given problem can be expressed in terms of or solved using a solution to an alternate problem.

Take for instance, the word distance problem: Find the shortest distance between two words in a given set of words. Following is an unanimous solution, I suppose:

Continue reading Problem Reduction

JINQ

In his talk at the CppCon 2014, Bjarne Stroustrup explained, politely and brilliantly, how to write succinct expressive yet intent-ful code. The task is especially hard when there are parties interested in trolling1 rather than contributing. Like Stroustrup explains back, it is difficult to find the real meaning out of a large block of (legacy) code.

Continue reading JINQ

.NET for the next generation

It was about a decade ago when Visual Studio .NET 2002 was launched. Having worked with Visual Studio 6 until then, the new interface was refreshing and powerful along with .NET and the suite of languages, tools and technologies. If you were there, you would have felt times were changing. Beyond the cool and modern interface, Visual Studio .NET 2002 had a lot more to offer compared to Visual Studio 6 — .NET. It was an exciting time for me back then.

Continue reading .NET for the next generation

An Unfair World of Tuples, Anons., var and auto

It all began when I wanted to return more than one value from one of the methods. Although my attempts ended futile, it was fun exploring and musing how things could have been.

There are at least a couple of options to return multiple values from a method:-

  1. return an instance of a class that holds the values
  2. return a tuple

Continue reading An Unfair World of Tuples, Anons., var and auto

Mutating Strings

Today, we question our beliefs! Is string really immutable?

string message = "Hello World!";

Console.WriteLine(message);        // Prints "Hello World!"

unsafe {  
    int length = message.Length;

    fixed (char *p = message) {
        for (int index = 0; index < length; ++index) {
            *(p + index) = '?';
        }
    }
}

Console.WriteLine(message);     // Prints what? See for yourself!

Continue reading Mutating Strings