Determine the cage length by determining the total capacity you need. The measurement is the sum of the difference of the highest and lowest crank gears (e.g. on my bike that's 52-30) and the difference of highest and lowest cassette gears (26-12)
My formula would be this: (52-30)+(26-12)
My derailleur needs to have a total capacity of 36. My touring bike, with its 50-36-24 chainrings and 11-32 cassette needs a long cage MTB derailleur.
At any rate, pick the cage based on total capacity, and the shorter cage derailleurs give better shifting performance, so if you can use one and still be within your needs, do it.