When we are developing applications we will often have a number of different number of environments in which our code needs to run in. For example, we may have a development environment, a staging environment and a live production environment.
There are various techniques for handling this but let’s take a look at how we might solve this using an object oriented approach.
Continued here: Managing Mutiple Environment Configurations
Feedback is always welcome, so if you see any problems or if something is not clear feel free to leave a comment on how these entries could be improved. Thanks.

Andrew Kamphuis · October 25, 2009 at 5:08 am
Great little article. Right now we sometimes detect the environment via cgi.REMOTE_ADDR which always bothers me, or we use the machine name createObject(“java”, “java.net.InetAddress”).localhost.getCanonicalHostName() and then we use flags throughout our app. I like the whole ‘environment object’ rather than the flags we use. Thx.
Jim Priest · October 25, 2009 at 3:40 pm
Seems like a tremendous amount of overhead to deal with a fairly simply problem? I use an Ant script to deploy my apps and simply set all this on the fly during deployment to the server.
Kevan Stannard · October 25, 2009 at 11:07 pm
@Andew, thanks.
@Jim, using automation is a great approach that all teams should embrace, however the effort required to get a team on the road to automation without guidance is not easy; resistance to change, understanding what can be automated and the capabilities of Ant, learning a new script language and the subtle challenges that arise, changing the process of all team members. I think once you have a team in favour of automation and the basics are understood then it’s simplicity and benefits can be seen, but until then it seems more a mountain for many.
The approach presented here is actually very lightweight and demonstrates a nice way to encapsulate environment properties rather than the common “if” statement approach which sets environment properties directly in the application scope. Perhaps the length of the wiki entry overshadowed the simplicity of this approach?
For anyone reading, Jim has an awesome wiki on Ant information:
http://www.thecrumb.com/wiki/ant
Tony Nelson · November 5, 2009 at 1:40 am
Have you checked out the Environment Config project on RIAForge? It’s pretty similar to yours. I’ve been using it for quite awhile and it has saved quite a few headaches.
http://environmentconfig.riaforge.org/
Kevan Stannard · November 5, 2009 at 2:07 am
Thanks Tony, yes that’s an excellent utility. I actually have a link to it in the References section of the wiki page.