02 August 2006

Coding Hell #5

No matter how bad the situation...

We have Rv_133 (name disguised to protect the guilty) that sets environment variables on a database server (running Oracle 5). That program is loosely similar to regedit.

One day, I ran a function that displays all possible variables that can be changed. I was curious as to where the data came from, so logically I started in the database. Finding nothing significant, I traced the code back and found this in a 7,300 line file:

static const TYP_R133ENVPROJ astProjEnvVar[] =
{
{"MED ALLG", {"Med Allg",
NULL},
""},

{"MEDNET", {"Medical Net",
NULL},
"02-05-1995"},

{"MED_NO_DOC", {"RK-1/RK-2/RK-3 Canon Autorefrakto/Keratometer",
NULL},
""},

/** SNIP (6200 lines) **/

{NULL, { NULL
},
NULL }
};

I imagine it goes without saying that there were no good comments or worthwhile documentation for the system.

Back then, when that program was created, the term 'modular programming' meant: 'Create a module by copying existing functions into a new file, alter a few lines, and do the rest by changing some of the 73 global variables and structures. And because you'll run out of module names pretty soon, name them like 'Fb_421', 'Cx_117', 'Cm_515' etc.


No comments: