I remember once hearing about a project in which they hard-coded some paths in a javascript program. When testing the program in the test environment, those paths had to be changed for the test server.
When the program would be approved for production, they would change the hard-coded paths for the production server before deploying the program to the production server.
And then everybody, I.T. and users, were confused when one day the production system no longer had a whole bunch of records. They had, of course, forgotten to change the paths in the source code before deploying to production, so the production application was hard-coded to look for things on the test server.
Dumb.
First, do not hard-code. But if you must (or if for any reason a part of a program ought to behave one way in one environment and a different way in the other, the best thing to have is all of that being in the one file, and have the behaviour of the file change depending on the current environment.
A bit in that spirit:
When the program would be approved for production, they would change the hard-coded paths for the production server before deploying the program to the production server.
And then everybody, I.T. and users, were confused when one day the production system no longer had a whole bunch of records. They had, of course, forgotten to change the paths in the source code before deploying to production, so the production application was hard-coded to look for things on the test server.
Dumb.
First, do not hard-code. But if you must (or if for any reason a part of a program ought to behave one way in one environment and a different way in the other, the best thing to have is all of that being in the one file, and have the behaviour of the file change depending on the current environment.
A bit in that spirit: