|
Last
week I initiated a series called Hype v/s Reality.
Earlier I had started another series called Learning
from (others) mistakes. Today I am initiating
another one called Hidden Opportunities. These
are not series in the traditional sense. Traditional series
appear regularly in consecutive issues. In case of the series
mentioned above, they will appear sporadically and not in
any particular order. For example, in a particular week, Tech
Forum may contain one snippet of Hype v/s Reality
and another of Learning from others mistakes.
As you know, the purpose of Tech Forum is to stimulate innovation,
impart highly usable knowledge and broaden the horizons of
IT as an industry by capitalising upon technology-based value
addition. These series are some of the tools I will use to
achieve these goals.
Hidden opportunities are areas of technology that are not
often known but are nevertheless very useful. Due to lack
of awareness, some of the greatest functionality provided
by various technologies is simply not used. If you do use
them, you are actually opening up many hitherto untapped opportunities.
In a business context, opportunity means a potential sale.
In case of technology, the opportunities by themselves may
not be directly linked to increased sales. By knowing about
these hidden treasures, you can achieve one or more of the
following, each of which will definitely translate into more
revenue ultimately:
-
Better utilisation of available features, leading to reduced
coding.
-
Ability to offer more functionality and features to the
end customer.
-
Evolution of a more efficient solution architecture.
-
Improved reuse.
-
Elimination of coding in some cases (where you had written
code to achieve something that was already available but
not known to you).
It is not Undocumented <something>
Please do not mistake hidden opportunities with
something like Undocumented VB.NET or any similar
series of books and sites. In fact, whatever I highlight in
hidden opportunities is very much documented even
today. It has always been documented and yet hardly anyone
knows about it; or very few people end up using it; or even
fewer people end up using it the right way.
Another issue needs explanation here. Most documentation and
content available about a particular technology focuses on
the syntax level usage and explanation. However, how to use
a feature in a real-life scenario is simply left to the imagination
of the software architect (who?!!). Due to this, it is not
enough to just know that a feature exists, it is much more
important to have the ability to map it to some business scenario
or need. Unfortunately, this education is not provided anywhere.
Most training programmes, books, seminars, events and Web
content take routine, mundane examples and do not delve on
how and why a particular feature was used the way it was.
In the Hidden Opportunities series, I will show useful examples
of feature usage mapping to business needs. So much for an
introduction. Now let us actually explore some hidden opportunities.
Split function in VB
Technical explanation
Let us start with something small but useful. It is just a
nice little function in VB (and VBscript).
Function Split(
ByVal Expression As String,
Optional ByVal Delimiter As String = ,
Optional ByVal Limit As Integer = -1,
Optional ByVal Compare As CompareMethod = CompareMethod.Binary
) As String()
The function is simple. Give it a delimited string and it
will return an array containing individual strings. The delimiter
is user definable - default is SPACE - chr(32).
Dim arrsubstring() As String = Split(one two three)
The arrsubstring will now contain three elements containing
one two and three as separate
elements.
Of course, there is a reverse function called JOIN, which
when passed an array and a delimiter, returns a string combined
with the delimiter.
In .NET too there is a similar function. This time you can
pass multiple delimiters as an array.
Using the function effectively
While searching through the MSDN library, I found this (PSS
ID Number: Q266289). It is very revealing and reinforces my
thinking that every feature needs to be used in the right
context: This article illustrates how to use the Split
function to separate a delimited string into a string array.
Although the Microsoft Visual Basic product documentation
describes how to use the Split function, the product documentation
does not contain an example that uses the Split function.
Funnily enough, this article in MSDN goes on to give an example
of a string that is delimited by ampersand (&). The string
used is
strTest = Fred & Wilma & Barney & Betty
A simple illustrative example exists in .NET documentation
also.
Now, from a usage perspective, just think of some scenario
you know where you have to split a string (with a known delimiter)
into pieces. You dont even need to thinkall of
us have used (or are still using, although we may not like
to admit it) comma delimited files. Does that ring a bell?
Do you not need to parse a comma or tab delimited file and
put it into a cursor / a recordset or upload it to some table
in some database? The answer is very much yes. Now the question
is: How many times have you used the SPLIT function to do
CSV parsing? The answer is very rarely yes. Is it not a pity?
The pitiful situation does not end here. Here is how a typical
developer would parse the CSV file. Given below is the pseudocode:
-
Open file.
-
Read each line as string.
-
Count the number of delimiters.
-
Declare an array containing required no of empty elements.
-
Start a loop from 1 to length of the string.
-
Initialise an empty variable to accumulate the substring.
-
Check if each character is the delimiter (comma in this
case).
-
If yes, put the accumulated substring in the next available
element in the array.
-
If not, add the character to the variable.
-
Continue the loop till the end of the base string.
This means at least 10 lines of code (more, actually). Dont
believe that such things happen? Check out the code written
within your organisation which does this type of parsing and
you will be surprised (or depressed!). The SPLIT function
existed for years without usage! Sounds familiar? On many
occasions in Tech Forum I have been highlighting such ironic
and paradoxical situations that exist in technology utilisation.
The purpose is to make IT professionals aware that there is
so much they are not aware of (a diplomatic way of saying
that they are ignorant about; and sadly, completely comfortable
with this ignorance).
Now next time you need to parse strings, think of SPLIT. Actually,
I feel like making an ad:

I wonder how the developer within Microsoft who thought of
and implemented this function would be feeling!
Continued ...
You may think that this is going into too much of the nitty-gritty
of development, and harping on faults. But look at it this
way. Combine all the commands and functions in Visual Studio
/ .NET platform / database level SQL languages and you have
a mammoth but unfortunately hidden potential. Next week I
will highlight a non-syntax based example. This example will
show how potential that exists to achieve phenomenal functionality
is often completely ignorednot because of lack of simple
thinking.
Feedback
Your feedback, suggestions, requests for covering specific
topics or issues are welcome. Please send feedback to techforum@mediline.co.in
 |
About
the Author Dr Nitin Paranjape is the Chairman and MD of
Maestros (Mediline). He is a consultant with many organisations,
covering appropriate technology utilisation, business
application of relevant technology, application architecture
and audit as well as knowledge transfer. He has authored
more than 650 articles on various technology-related subjects.
He can be contacted at nitin@mediline.co.in |
|