Breaking from linear thinking in development
March 23, 2009 Leave a comment
I am working on an application that creates financial fiels. The basic format is like this:
Merchant Header … Merchant Header N
Financial Record … Financial Record N
Examining the file, the original programmer saw this:
Transmission Header Line
Batch Header Line
Merchant Header Line
Batch Trailer Line
This is a very linear way of thinking. Start from the top of the file and continue until you reach the last line. The problem with thinking like this is it completely ignores the containers. If there are no totals, this is not a big deal, but the reason for headers and trailers in the file is the trailers generally have some sort of summary information.
In this case, there is summary information, with comments like:
TODO: Calculate total
strRecord = strRecord + strDebitTotal.Replace(".", ‘").Replace("-","").PadLeft(12, ‘0’);
Unfortunately, you can’t get there from here, as the total is dependent on the lines that have come before. It can be kludged, perhaps, by running a large number of totals as you add records and using these global variables to output the lines. But, it is much easier if you think of the containers and stop thinking only of the output. The container is Transmission. The Transmission contains a header and a trailer. When done in this manner, you can actually test whether the output is correct.
Peace and Grace,