Skip to main content

Posts

Showing posts with the label programming

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.Instead of showcasing the issues that were being faced and yet not realized, let me state the alternate - how things in such cases can be better: Business has to realize or let known: When the engineering team accepts the authority of the business in deciding the priority of features, the business has to be prudent enough...

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 . 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 code 1  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 difference 2 . The expectation arises when ...

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: http://regexpal.com/ http://regex101.com http://rubular.com/ https://www.debuggex.com/ http://www.freeformatter.com/regex-tester.html In the above list, I like the last but not the least - freeformatter.com . The cool thing about freeformatter ...

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>(); erro...