Breaking from linear thinking in development

I am working on an application that creates financial fiels. The basic format is like this:
Transmission Header
  Batch Header
    Merchant Header … Merchant Header N
       Financial Record … Financial Record N
  Batch Trailer
Transmission Trailer
Examining the file, the original programmer saw this:
Transmission Header Line
Batch Header Line
Merchant Header Line
   Financial Line
   Extension Line
Batch Trailer Line
Transmission 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,

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: