Whenever we incorporate environment-specific feature flags or logic, we need to pay attention to the discrepancies introduced by these changes. Could the environment-dependant logic be tightened so that the bare minimum divergence is introduced? Should we isolate the newly introduced logic fork into a single module that takes care of as many aspects of the divergence as possible? Could the flags that are enabled as we’re developing features for an specific environment result in inadvertently introducing bugs into other environments where a different set of flags is enabled?

    Conversely, the opposite is true. Like with many things programming, creating these divergences is relatively easy, whereas deleting them might prove most challenging. This difficulty arises from the unknown situations we might not typically run into during development or unit testing, but which are still valid situations in our production environments.

    We swap the current component with the a new one from our company’s own component framework, so we know it’s battle-tested and works well in other production applications developed in house. We test things in our local development environment, and everything works as expected. Tests pass. Other developers review our code, test locally in their own environments as well, and find nothing wrong with it. We merge our code, and a couple weeks later deploy to production. Before long, we start getting support requests about the code editing feature being broken, and need to roll back the changeset which introduced the new code editor.

    What went wrong? We didn’t notice the fact that the new component doesn’t work unless is present. Given that we allow inline styles in development, catering to our convenient developer tools, this wasn’t a problem during development or local testing performed by our team mates. However when we deploy to production, which follows a more strict set of CSP rules, the rule is not served, and the component breaks down.

    As much as possible, we should strive to keep these kinds of divergences to a minimum, because if we don’t, bugs might find their way to production, and a customer might end up reporting the bug to us. Merely being aware of discrepancies like this is not enough, because it’s not practical nor effective to keep these logic gates in your head so that whenever you’re implementing a change you mentally go through the motions of how the change would differ if your code was running in production instead.

    Proper integration testing might catch many of these kinds of mistakes, but that won’t always be the case.