JS Programming in C# – Local Functions

Functional programs treat functions and data alike. No discrimination, if you will. That means, you can declare and use functions – assign to variables, pass to other functions etc., the same way you would play with variables.

A canonical example of a functional program would show how to pass functions as parameters to other functions (higher order functions). It would also show how one can create functions on the fly (lambdas or anonymous functions) and also assign it to a variable, which is of a predefined function type; either the compiler deduces or aligns to the calling context.

There is one important attribute of data that is mostly forgotten. It can be declared almost anywhere, particularly within functions. Local variables, remember? If we agree to treat data and functions alike then we should be able to declare a function inside another. Errrk! Why would anyone want to do that? Seems like JavaScript.

Continue reading JS Programming in C# – Local Functions


JS Programming in C# – Objects on the fly

Creating objects without defining types is considered a great flexibility in JavaScript. JavaScript treats objects nothing more than key-value pairs. Yeah, you can declare functions in the object but they are still part of the key-value philosophy. Bottomline: JavaScript did not start out as an object oriented language.

Typically, objects are created on the fly1 using the object literal syntax:

let obj = {
   name: "Will",
   age: 26

There are scenarios when creating objects on the fly is indeed a flexibility.

Continue reading JS Programming in C# – Objects on the fly

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(
  "{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


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