14

That moment when code reuse makes you reuse reused code and you actually reuse a BUG.

You decide to go for code reusing when your boss asks: "Can you add an edit popup besides that 'add customer' popup button?". You do some little tweaks to the "new customer" code and it allows that to save over an existing entry, cool.

However, after a lot of time spent on reviewing the resulting PR, turns out there was a dormant bug on the code you reused, and it woke up with its new use.

That code was a bad copy-pasta from another, bigger form, which included a whole bunch of optional fields. As it was only used to save new entries, those now missing fields were simply being saved as empty. But as you reused that to save existing entries, you were now cleaning up all those optional fields without noticing.

Comments
Add Comment