When I was about 3 months into my programming career I performed a minor refactor to some code.
Unfortunately, the program was difficult to test (no unit tests) and very important, and difficult to verify correctness of output as well. (As in, you can't just look at it and say "yeah that's numbers lgtm").
Also unfortunately the previous author had not been very consistent in their programming style, so there was a lot of syntactic noise (some single line if statements used braces, some omitted them, etc)
Also unfortunately in my prior rewrite work in this, I had grafted the old UI onto my new backend to save time, but not brought the rigor there up to snuff (it's UI code, I had thought. It's well enough to have tests covering the business logic for now.)
Well anyway when I had rearranged some code, I hadn't realized there had been an extremely large block right underneath an if statement that wasn't using brackets, and I had accidentally split it into a few statements. N-1 of which were naturally now outside of the if statement.
The end result being that a bunch of code would run and the "is dirty" state worked fine, but if you clicked save on a "clean" state with no edits, it would blank the fields in the DB but not in the UI.
It didn't end up having any actual impact because we caught it in time, but god damn did it teach me something about "real" programming. I'm not sure exactly what all it taught me, but I think about that a lot as I do random other things now 8 years and 3 companies later.
Did that when I was younger, but with my own code :)
There was an if that didn't need brackets when I wrote it. 6 months later it needed more stuff on a branch but i was tired and in a hurry so I didn't notice adding extra lines needs brackets. New code compiled but wasn't part of the if. Turned a 5 minute fix into 2 days.
Of course, all my ifs have had brackets on both sides since then.
It is the thing I love about emacs, it autoindents everything, so if you got brackets/braces/parenthesis wrong you see something you don't expect. But obligatory braces work too.
Yeah maybe these days the smarter autoindent would prevent incidents like this. But it's too late for me, I'll add braces around 1 line branches till i die :)
Unfortunately, the program was difficult to test (no unit tests) and very important, and difficult to verify correctness of output as well. (As in, you can't just look at it and say "yeah that's numbers lgtm").
Also unfortunately the previous author had not been very consistent in their programming style, so there was a lot of syntactic noise (some single line if statements used braces, some omitted them, etc)
Also unfortunately in my prior rewrite work in this, I had grafted the old UI onto my new backend to save time, but not brought the rigor there up to snuff (it's UI code, I had thought. It's well enough to have tests covering the business logic for now.)
Well anyway when I had rearranged some code, I hadn't realized there had been an extremely large block right underneath an if statement that wasn't using brackets, and I had accidentally split it into a few statements. N-1 of which were naturally now outside of the if statement.
The end result being that a bunch of code would run and the "is dirty" state worked fine, but if you clicked save on a "clean" state with no edits, it would blank the fields in the DB but not in the UI.
It didn't end up having any actual impact because we caught it in time, but god damn did it teach me something about "real" programming. I'm not sure exactly what all it taught me, but I think about that a lot as I do random other things now 8 years and 3 companies later.