Skip to main content


Showing posts from 2014

The Secret behind Bjarne and Herb's Papers on Unified Call Syntax !!!

A long time back, in one of my posts here, I had discussed about Extension Methods ... in C++; sorta! It seems that the grand daddy, Bjarne Stroustoup, had read my post, and was impressed. So he has published a paper - Call syntax: 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 Sutter, 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 Syntax. How is that?

Needless to say, I was completely kidding about the Herb and Bjarne about borrowing the idea of extension methods from my post. I wasn't even born when Bjarne invented C++. The papers are detailed and deep in considering various scenarios from a language standard perspective unlike my post where I just spotted the existing but unrealized …

PHP Savers - PropertyBag !!!

The ubiquitous and the universal data structure in PHP is the array. 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.
JavaScript would allow you to access an object property either obj.propName or obj["propName"]. That does come in handy for sure. Besides, accessing the property by [] tags is the only way if the property name contains characters like hyphen: obj["prop-Name"]. At the user code level, it is fair to see an object as a bag of key-value pairs.
Along the same lines, it is not wrong to expect the same in PHP between an object and an array; although there is a fundamental difference2. The expectation arises when there is a lot of code that ge…

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.
Ok, this is not a rant post about the Date class but actually share some sites that help you with regular expressions, of course at different levels. Here is a list of such sites:
In the above list, I like the last but not the least - The cool thing about freeformatter is that it lists a…

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:
// C# code Dictionary<string, object> CreateResponse(string msg) { return CreateResponse(ex.Message, 0, false); } Dictionary<string, object> CreateResponse(string msg, int code) { return CreateResponse(ex.Message, code, false); } Dictionary<string, object> CreateResponse(string msg, bool success) { return CreateResponse(ex.Message, 0, success); } Dictionary<string, object> CreateResponse(Exception ex) { return CreateResponse(ex.Message, ex.HResult, false); } Dictionary<string, object> CreateResponse(string msg, int code, bool success) { var errorInfo = new Dictionary<string, object>(); errorIn…

Getting reminded of the reminder !!!!

I have been using Android for quite some time now, and only recently I noticed that Android pops up a notification reminding you of a reminder. It says "Upcoming alarm - Buy Milk", where Buy Milk is the reminder I had set.

Is it smart enough to help a lazy volatile minded guy like me or is it trying to be my wife who would not rest until I buy milk? Don't know.

jqGrid: Handling array data !!!

This post is primarily a personal reference. I also consider this a tribute to Oleg, who was fundamental in improving my understanding of the jqGrid internals - the way it handles source data types, which if I may say led him in discovering a bug in jqGrid.

If you are working with local array data as the source for jqGrid, meaning you will get the data from the server but want the jqGrid not to talk to the server anymore, and want to have custom handling of the edit functionality/form and delete functionality, it is not going to be straightforward - you need to have a decent understanding of how jqGrid works, and you should be aware of the bug Oleg pointed in our discussion. I repeat this is all about using jqGrid to manage array data locally, no posting to server when you edit or delete, which is where the bug is.

$('#grid').jqGrid('navGrid', '#pager', { recreateForm: true, add: false, search: false, refresh: false, …

Clean Code

I received quite a lot of criticism for Dealing with Bad Code. The criticism was mostly along these lines - "There is no good or bad programmer. The good programmer thing is more of an illusion. When you place a programmer in a domain in which he has little or no experience (like a PHP web programmer writing C++ code), he will soon be seen as a bad programmer. What is branded good or bad is subjective."

Although it sounds to make sense, I don't completely agree with that. Maybe the topic of the discussion was ambiguous. It wasn't the programmer but the code. I am not willing to spend my energy to demotivate somebody by branding him a bad programmer. But I will in reviewing anybody's code, not just brand it bad code but ultimately clean it up.

I believe programming isn't restricted to language. Although the language used to program has its impact on the way a problem is solved, it doesn't limit the programmer from losing the basics. In other words, a prog…