The Park Tool site has a good section on this. They recommend the same method as the above two posts, and also have a way to calculate the length using the number of teeth on the largest ring and cog, and the distance from the crank axis to the rear axle.
I'm working on installing a new drivetrain, including the chain of course, so just for fun I'll see how the calculation compares to the fit + 2 method.