Downsizing Jumbo Sized Routines

Our state has a funny law which allows municipalities to take unpaid water bills and “lien” them onto the owner’s real-estate bill. Only a handful of communities enact the law; ours is one of those communities.

About six years ago I started re-writing a program in Informix 4GL to perform a series of reporting tasks, including a master report, notices to be mailed out, and eventually “throwing the switch”, in which the program pays each overdue account’s balance by transferring it to the real-estate bill as a betterment, like a new sidewalk. This switch throwing also had to be made reversible.

I know a lot more about water use calculations and billing now than I did then, and, as tends to happen with data driven software, some problems cropped up this week. The selection routine — that routine that corrals the water accounts to be liened – was filled with special cases and too many “flag” variables. I rewrote it, making it considerably smaller and simpler. One of the reasons it shrunk was taking greater advantage of SQL, specifically the sum function.

Long routines (functions) are something I have to watch for, especially in languages like Python, which, at least for me, lends itself to just solving the problem linearly instead of thinking in a modular way.

So, my motto is if the function is big with lots of conditional flags, watch out.

Advertisements

Leave a comment

Filed under Programming

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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