Information Technology Reference
In-Depth Information
14. Programming creativity
That last challenge with the pills was meant for two purposes: first to keep the
creative juices flowing and second to point out the fact that sometimes the normal way of
doing things may not always work. We may have to find a different way of accomplishing
a task. Even as we progress from day to day you will note that methods of getting a task
done on the computer will change from what they were. It's true that the technique of
yesterday may still work today, but it may be beneficial to improve on the method just as
the technology itself has been improved.
The obvious reference here is to the days when we had more limits on what we
could do as computer programmers. We may have had space limitations, which forced us
to think in a different way, or there may have been a limit on the number of variables in a
program or the size of a table, which meant that the approach we thought about couldn't
be used. We would have to come up with an alternative method. A particular situation
could be handled in two or three ways but perhaps only one of these would allow us to get
certain tasks finished in a required timeframe. Many of these early restrictions are gone
now, but some are still with us.
I recall a specific instance when I was working on a modification to a program to
add checking for a new transaction. Unfortunately the software wouldn't let me do this by
increasing the table to accommodate the additional three characters. It seems there was a
limit on the size of this field and it had been reached. Fortunately there was no
repercussion if I added more lines of code, but there could have been. The way the
program worked before with this table was that it started at some position in the string of
values and obtained that number and the next two. If the string was
001002003004,
a pointer would start at position 1 for a length of 3, with the result being
001.
This value would represent a transaction number. We could then bump up the pointer by
3 to get 4 and then take the string starting at position 4 for a length of 3 and the result
would be
002.
These three position fields would represent transaction numbers and by looping through
the values in the same fashion, we could check to see if the three digit number we had
was a valid transaction.
My task was to add another three-digit number that represented a new transaction
to this string. Unfortunately the limit on the size of this variable had been reached. Since
my new transaction was
010,
what I did was to add a slight modification to the program that checked the value of the
pointer and if it was 1, I would only increase it by 1 rather than by 3. Then from that point
in the string if I took the next three digits I would get
010,
Search WWH ::




Custom Search