Survey: Should file paths in development mirror production?

By Deane Barker on September 18, 2008

Quick survey time —

When developing Web apps, do you think the file paths to the root folder on your dev server should be the same as your production server?

So, if your Web root in production is at “/var/www/mysite/htdocs”, should that be duplicated in development? Or should it be purposely different?

  • Argument to make them the same: having your development environment mirror production leads to less potential problems when deploying.

  • Argument to make them different: having purposely different paths requires that your code is portable and not rely on hard-coded paths.

Anyone?

Gadgetopia

Comments

  1. Different. Use configuration files if necessary to specify full paths to certain directories/files, but limit those. If you code it “right” initially, you don’t have to worry much about how it will reactive in production with respect to paths.

    If you do hard code paths all over and production changes, you’re in trouble. Say you’re doing a site on a shared hosting box that you don’t run (obviously not an issue for Blend, but as a general example) and the company decides to redo their directory structure when they switch you to a new box, you’re hosed. You get to change them all then test everything. If you did everything relative with as few full paths (all in a global config file), you can be pretty sure without a full test that most will work. (Of course, you would do a full test, right?)

  2. Different. I’m assuming there’s at least one staging environment between dev and prod. It should be different from dev but identical to prod.

    If dev and prod must be identical, you may run into a harder time developing different versions in dev at the same time, such as creating a completely new version while supporting the old version.

    Eric

  3. For diagnostic purposes, it is essential for the staging and production servers to have the same path structure. Otherwise, when it works on one, but not the other, the path difference is an unnecessary variable. Similarly, the dev server should be the same. How many times have you heard “It works on my machine”? Having a test machine with a different path is beneficial to test for hard-coded paths, but as a matter of standard practice, it is better to keep as many things the same as possible.

  4. You should do both. You should avoid dependencies between development and production, but you should scrupulously ensure that your acceptance testing environment has exactly the same layout as your production environment.

  5. We store the server’s profile (dev, test, or prod) in an environment variable on our Java application server. We then load two configuration files: a fallback/default file and one specific for that profile.

    Developers, if needed, can modify their environment variable if they to test the server profile.

    I believe Ruby on Rails does something similar for their database connections.

Comments are closed. If you have something you really want to say, email editors@gadgetopia.com and we‘ll get it added for you.