AD HOC VS. PLANNED SOFTWARE MAINTENANCE Warren Harrison Portland State University Portland, OR 97207-0751
[email protected]
INTRODUCTION In a series of papers, Belady and Lehman [Belady & Lehman, 1976] pioneered the study of the evolution of software. They observed that over time, programs exhibit increasing entropy. As a program evolves, its structure degrades and its size increases, resulting in increased complexity. The increase in program entropy as it evolves makes program maintenance increasingly more difficult, and will ultimately result in the program dying and being replaced by another program, or the program undergoing a major and expensive overhaul. When making a modification to a piece of production software, a maintenance programmer must give some thought to the impact their changes will have on the entropy of the module.
AD HOC PATCHES AND PLANNED, STRUCTURE PRESERVING MODIFICATIONS When changing a piece of code, a programmer may apply a "patch" that effects the desired change in program behavior, or alternatively restructure (perhaps even rewrite) the module in order to preserve the structure and maintainability of the code. For instance, consider the somewhat contrived and simplified example in Figure 1. A programmer writes a program to count logical source statements in C, based on a simple count of semi-colons. #include char line_char; // a character from the program int in_code=0; // 0 if not in {...}, >0 otherwise int lss=0; // count of logical source statements void main(void) { cin.get(line_char); while(!cin.eof()) { if(line_char==’{’) in_code++; if(line_char==’}’) in_code--; if((in_code > 0)&&(line_char==’;’)) lss++; cin.get(line_char); } cout 0 if in char const, 0 otherwise int lss=0; // count of logical source statements void main(void) { cin.get(line_char); while(!cin.eof()) { if((line_char==’"’)&&(in_char==0)) { if(in_string==0) in_string++; else in_string--; } if((line_char==’\’’)&&(in_string==0)) { if(in_char==0) in_char++; else in_char--; } if((in_string==0)&&(in_char==0)) { if(line_char==’{’) in_code++; if(line_char==’}’) in_code--; } if((in_code > 0)&&(in_string==0)&&(in_char==0)) { if(line_char==’;’) lss++; } cin.get(line_char); } cout