← Back to context

Comment by solardev

1 day ago

The "why" can be so important... like you said, I can read the code, but I can't always divine the original author's intents...

Anecdote:

I once (well, many times, but especially this one time) inherited a completely undocumented codebase from a previous "lone wolf", mad genius type of programmer. Most of the stuff he wrote was completely inscrutable at first but really kinda genius once you figured it out.

But one day I was tweaking one of his heatmaps showing solar production on a rooftop from "off" to "a little" to "a lot" to "this is broken", and his color gradient code was a magical one-liner doing strange math as hex operations. It usually went from blue to red to yellow, but would sometimes "overflow" into other strange colors that made no sense. I spent a few hours simulating different edge cases and getting back colors I could not reasonably explain — and which would confuse our users. I talked to my coworkers about it, who mostly insisted "Well, I don't know, but he was a very smart guy, so we should probably just trust him and move on". That was unsatisfying, and didn't really help me close the customer ticket that I was trying to solve.

I kept bugging my boss about it, and after a few days of back and forths and seeing my simulation, he finally agreed to let me reach out to the original programmer (who had long since left the team). I finally got my answer a few hours later. He said, "Oh... that was just some random throwaway gradient I thought looked pretty, lol. I was lazy and wrote it in a hurry and, yeah, it probably bugs out on all but the simplest cases, and doesn't conform to any color standards... glad he caught it."

Sigh, lol... that took several person-days to resolve, when it could've been a simple // #TODO: Use a better gradient system someday