system
Given the following post, respond as if you're commenting on Reddit:
human
Is server specific code a bad idea ?

So today I made a bad mistake at work. I migrated some code from the testing environment to production, however at some point the code in production had diverged from that elsewhere in source control, so I overwrote the production approach with the approach that was used in dev and testing which didn't work properly in the production environment.

Yes it is confusing to have it set up this way. In some ways it is as much a systems failure as it is my mistake, but I probably should have checked everything more carefully.

Discussing this with one of the managers he said, "elsewhere we deal with this problem of diverging code bases by having logic of the form if code is running on server A do this, else if it is running on server B do that". Just to be clear the servers aren't different operating systems or anything. This just seems like a bad idea, as it makes it impossible to test properly, and what if you want to migrate the code to a different production server ? For lack of a better term it seems like a code smell.

Some of the managers are a bit surly and I hope this doesn't turn into a drama, but I think I will make the case that we need to just sort out the reasons for having different code running on the different servers.

What do people think of this situation ? Thanks for any advice.
gpt
> however at some point the code in production had diverged from that elsewhere in source control

Just that sentence alone makes me cringe. Directly modifying code on prod without going through SC is ... yikes.