If I have a variable that I want to vary by environment, what is the best way to implement this in Salesforce?
For example, in dev I want to point to one external server, in test different one, and in production another.
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It only takes a minute to sign up.Sign up to join this community
I would recommend using Custom Settings (read more at http://na1.salesforce.com/help/doc/en/cs_about.htm). They basically work as global variables for your orgs and can be set independently in production and in sandboxes.
Custom settings come in two flavors: a list and hierarchical. If you need to vary the setting by role or profile you would want to use the hierarchy option otherwise the list option is very straight-forward.
Custom Metadata types have an advantage over custom settings in that the values can be defined as metadata and migrated between instances.
I've created a Free/Open Source package that allows you to define "environmental variables" a as Key -> Value pairs.