Posts

A funny moment of IoC

IoC - Inversion of control, is a design that enables fluid flow of control by decoupling tight dependencies between the portion of a code that exhibits behavior and another portion of code that provides required functionality. One form of IoC, as we know, is Dependency Injection (DI). For instance, a TextEditor could refer an ISpellChecker instead of direct coupling to a specific implementation of spell checker thereby enabling the text editor to switch spell checker or even use more than one. More ...

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!
More ...

A time when time did not exist …

Those of us, non-physicists, we do seem to realize that time is eternal. Yet there was a time when time did not exist; tough to comprehend? For us, time is something running on a clock or tracked on a calendar. Let me share what I think about when time did not exist. More ...

Quiz: Choosing an array of integers !!!

In the recent interviews, I asked the candidates the following question:

Is there a difference that I need to consider in the following declarations? Both allocate fixed size array to store integers:

int[] na1 = new int[10];
Integer[] na2 = new Integer[10];
More ...

A-Team Library

A short while ago, I had to write a compelling document for a client about a library that I had developed during my tenure, call it A-Team Library or ATL. Having to learn the β€œeyes-wide-shut” culture to maintain the couples-of-decades old code and simultaneously develop on the top of it was very disheartening. It was time a lot of things were given fresh thoughts. Not the least of all duplication of code and functionality. But not just that. Like in a programming language, when there is more than one way of doing something, when those ways are opposing, it causes nothing but confusion. So was the case. The business seemed to be far from realizing it. More ...

The Secret behind Bjarne and Herb’s Papers on Unified Syntax

A long time back, in one of my posts here1, I had discussed about Extension Methods2 … in C++; sorta! It seems that the grand daddy, Bjarne Stroustoup3, had read my post, and was impressed. So he has published a paper – Call syntax4: x.f(y) vs. f(x,y). Good thing except I don’t like the idea of assuming x.f(y) for f(x, y) while the reverse is the actual idea of extension methods. You will know when you read his paper. It seems the commander, Herb Sutter5, also was impressed with my post. Not only that he too doesn’t seem to like the x.f(y) for f(x, y) idea. Great men think alike. LOL! So he published his paper – Unified Syntax6. How is that? More ...

A Simple Tree List View

Digging up stash is one of the best pass times. You know you never know what you will find. I had an article written quite some time back but had not posted it anywhere. Not sure why. I posted it at CodeProject – A Simple Tree List View.

PHP Savers – PropertyBag

The ubiquitous and the universal data structure in PHP is the [array][1]. It is an amalgamation of commonly used data structures – list, map etc. In the recent times, PHP has also adopted object orientation and introduced classes. The syntactic difference in the way a property of an array and object poses an inconvenience in the user code1 specifically when there is a need to interact with code that is not open for change; legacy or not. More ...

Cool Regex Testers

Anytime I have to play with regular expressions, I use one of the online regex testing web sites to come up with the regex I need. Last couple of times I had to come up with a regex for most common everyday stuff like dates and such. Oh yeah, last time it was date actually. I had a server response that had a date in the format yyyy-mm-dd, ISO format. I was working with JavaScript, and initially I was naive to use the Date class to parse the date in the response. Turned that there is difference in the way the date is interpreted by Firefox and other browsers. More ...

Overloading vs Variable Arguments !!!

In a statically typed (object oriented?) language, function overloading offers the facility of organizing your code into two or more functions with different types and/or number of arguments. This is highly useful when the functionality offered by the function can be invoked in different scenarios. For instance, let us consider the function(s) below: More ...