Haunted legacy: a Halloween code story

Photo credit: Neven Krcmarek via Unsplash

It was 17:55 on the 31st October. Five minutes before the programmer’s shift ended and the night shift took over. The time when you hope that no new bugs will be reported and no new tickets will be raised.

Ping!

The ticketing system sounded an alert, and the notification bubble popped back into existence, a bright little ‘1’ in the middle of its red circle.

For a moment, the programmer pretended that they hadn’t seen it. But it was no use. There was no hiding from tickets these days. The system knew that the programmer was working, and it knew that they hadn’t logged off. It might even be watching through the camera.

The programme opened the ticket, and their heart sank even lower. It was a bug in that system. The system that had been written in the last century, before any of the current technology team has even joined the company. The system that bore the scars of decades of maintenance, that no-one understood and everyone was afraid to change.

But somebody had to do it.

The programmer sighed and scanned the details of the ticket. It sounded straightforward enough. The program ran the company’s billing system and, for some unknown reason, it was aligned to a yearly cycle which ended on 31st October. Every year, somebody needed to check that the parameters were set up correctly. This year it was the programmer’s turn. They simply needed to finish the check before the code made its next batch run, at midnight. 31st October was a strange and spooky date for year end processing, and it was irritating that this work hadn’t been done a week or a month ago. But it sounded like a quick review, ideally with no code changes. How hard could it be?

And then the programmer opened up the program and started reading it.

It was like walking into a derelict and decaying castle, a castle which had been occupied by generations of neglectful and profligate children, each of which had added extensions and wings, without regard to the original structure.

Branches of code ran off in different directions, zigging and zagging under the control of complex conditions. Some of the branches were blocked off with the equivalent of police tape, rope and barricades, comments blaring warnings such as ‘Function deprecated: do not use!!!’. Others carried even more alarming text: ‘Do not change!’ ‘NEVER update this parameter.’ ‘I don’t know why this works, but it does – leave it alone!’

Occasionally, the layers of code acquired a strange charm, like a corner of a city which has been built and rebuilt many times, where every layer of history is still visible. Here was the work on the millennium bug. There was the first sign of a shift to object orientation. And this function must have been built when the system was connected to the Internet.

More often, though, the switches between eras were harsh and jarring, and the twisted logic defied comprehension. Variable names shrank to single, cryptic letters, as if they represented something that should not be named. Conditions were crushed under the weight of double, triple and quadruple negatives, held in place by ranks of parentheses.

Focus on the task, the programmer told themselves. Do not try to fix all this code. Don’t even look at it. You are here to do one job, and that job must be done by midnight.

Midnight. What was the time now? The programmer looked at the clock in the corner of their screen. 22:20. How could that be? It seemed that they had only just accepted the ticket. The convoluted and sprawling code was like a black hole that drank time and attention.

Focus, the programmer told themselves again, fearing that they would run out of time before they had even found whatever they were supposed to be looking at. And then they spotted it. Deep in the heart of the billing function, buried between multiplying date functions, holiday calendars and time zone checkers, there were a few lines of code that read a data file.

The programmer found and opened the file. They could not believe their eyes. There, pre-calculated and hard coded, were the billing rates for every month of the current year. Someone, years ago, perhaps decades ago, had despaired of making this code make sense, and had worked out the rate for each month by hand. But it would only work for a year at a time.

The programmer snorted. They could never bring themselves to perpetuate such an obvious bodge. Such a kludge. Such a terrible hack. Then they looked back at their clock – 23:00 – and at the tangled, impenetrable code. And they realised that they would have to suspend their principles, put aside all their best instincts, and do the one thing that would make the programme work in time.

Fifty minutes later, after some Excel formulae and a couple of quick Python scripts, the programmer had created a new file with new values, valid from midnight. They did not have time to do any testing. Given the thicket of logic contained in the code, they doubted that anyone would even know whether the tests were right or not. They put the file live, using the emergency authorisation that bypassed checks and controls. They told themselves that it was because the release was so urgent, but they knew that they didn’t want anybody else to see their work.

And then they got ready to write their release notes. This would be the time to come clean, to add the necessary code refactoring to the backlog, to plan the tasks that would tidy up this horrible piece of code once and for all.

But then they looked at the change log for the programme. And saw that, there, among the despairing words of other poor programmers who had been asked to work on this beast of a system, was their own name. On 31st October last year. And the year before that. And the year before that. Every year: I made the fix, time to clean up. I made the fix, time to clean up.

The programmer’s vision blurred, and their forehead prickled with sweat. How was this possible? They had no memory of any of those changes. Perhaps there was someone else with the same name. Perhaps someone is playing a joke. That must be it: a Halloween prank. There was no way that they could completely forget about this, year after year. Was there?

They blinked and updated the change log. I made the fix, time to clean up. And shut their laptop and went home. Plenty of time to figure things out in the morning.

That night, while asleep, the programmer dreamed of code. They were walking through the logic branches as if they were corridors, climbing the jagged indented steps of if statements, opening doors into functions. And, as they walked, the castle of code dissolved into fog, fading into the place where the memory of all legacy code goes.

Until next year.

Previous
Previous

How many placebos do you have in your diary?

Next
Next

Return of the spec