Common Absolute Paths Anti-Pattern
Some projects I’ve worked on in the past assume that certain files can always be found at an absolute path, eg ‘c:\program files\some cool library\library.dll’. Such files may be dependencies, or deployment target locations. This is a situation to be avoided!
The main reason this is so bad is that you may not actually have control over such paths when your application gets deployed. For example, many IT operations departments use ‘C:’ just for the Windows O/S, and put all other files on a secondary drive (e.g. for backup purposes). If your project assumes absolute paths, such problems may not arise until you finally reach production.
However there are other problems, like what happens when you want to work on 2 versions of the app at the same time (e.g. trunk, and branch)?
But there is good news – you don’t need to hard code absolute paths into your system! Alternatives are:
- Use relative paths. As an example, setup your source control directory structure such that you always know where your dependencies can be found relative to your project’s source code. (This may mean you save third-party binaries in source-control but this is not a sin!)
- Use deploy-time configuration. Get your build environment to generate environment-specific distribution files where parameterised paths are expanded to absolute paths at the last moment.
- Use environment variables, like path. This is a ‘last-chance’ option since it is system-wide, rather than application-wide in scope, but stops you having to hard code paths in your application at least.
To check that a project I’m working on isn’t using absolute paths, I tend to do one of the following things
- Have 2 copies of the development tree checked out on my machine. Switch between them occasionally and check nothing breaks.
- Have my continuous integration and ‘development test’ environments specifically use different paths to that of the development team.
Permalink Comments Off
My XP 2004
A couple of weeks ago I was at XP 2004. Due to my goldfish-like memory I’ve already started forgetting what happened, but here’s some things I do remember:
- It was good to meet new people, like Angela Martin, Rick Mugridge, Charlie Poole and the Exoftware folk
- It was good to catch up with people I’ve met before like Josh Kerievsky and hang out with my fellow Fowlbots Chris Stevenson, Chris Matts, Ivan Moore, Martin Fowler, Owen Rogers and Steve Freeman
- Hot Topic number 1 – the customer role (including a great panel.) Chris Matts has blogged a tonne about this so go read it!
- Hot Topic number 2 – acceptance tests. There’s a still a huge amount of debate about what an acceptance test is, and how to implement them (e.g. Fit is not a panacea).
- Talked with Charlie (NUnit) and Owen (fellow CruiseControl.NET project lead) and others about .NET tools. We’re going to work more on Mono compatibility if we get some time
- I presented my paper on Enterprise Continuous Integration. The demo I gave is available here, the paper is available here.
Permalink Comments Off


