Monday, January 30, 2012

What makes a good consultant?

I was implementing a certain business rule using a tool called Blaze Advisor. Nothing too complex just needed basic string handling functions to implement my rule. The tool's function library did not include a length function although it did have other string handling functions like substring, findstring, concatenate etc. I was mad that some advance functions were built-in but something as basic as the length function was missing.

I thought the tool was so useless. Why rules are implemented using Blaze? If this was a plain java implementation, we would have had so much flexibility. Hated and cursed the tool. No progress made, task was still open. Then did some research and found a simple trick to accomplish length function using substring and findstring functions. Here it is:

Let's say we want to find the length of String str1. Find a string str2 that will not occur within your original string str1. Append str2 to the end of str1 and assign the result to str3. At this point we have;

str1 = "..." // original string that you want to find the length
str2 = "..." // string that you know for sure will not occur in str1
str3 = str1 + str2


Now use findString() to locate str2 in str3. This should return the position of one character after str1 hence a minus one should give the length of str1.

str2pos = str3.findString(str2)
length = str2pos - 1 //length of str1


Pretty neat huh? This didn't need research, just some simple logical thinking. I told myself again: there is no such thing as a bug free product. Every product has bugs - known and unknown. Know your product; know the bugs, loop holes and most importantly your work arounds. That's what makes you a good product consultant.

No comments:

Post a Comment