CodeSOD: An Annual Report Note

CodeSOD: An Annual Report

Michael was tasked with modernizing mainframe reports, which involved deciphering old Intelligent Query code. The project's goal was to replicate the exact behavior of the old system with a new one, with testing based on output comparisons. After converting one report, the results didn't match the original. Michael discovered a discrepancy in a variable named TODAYS-365, used in a report titled "Annual." While the upgraded report correctly pulled one year of data, the original code contained a peculiar line: SUBTRACT TODAYS-DATE MINUS 426 GIVING TODAYS-365. This calculation meant the original report actually captured data from the past year plus approximately two months. It's speculated that a change in reporting requirements, perhaps related to fiscal years, led to this misleading variable name and calculation, which went unnoticed for years. The fix was straightforward, but the underlying issue was the accumulation of unclear and misleading code over time. This highlights that the real challenge with legacy systems isn't the programming languages themselves, but the layers of accumulated, often poorly documented, "kruft."