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!

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.

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];

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.

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.

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.

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: