There is a formula to determine twist rate.
www.z-hat.com/twistrate.htm
No such thing I know of for barrel length, just guidelines. Largely depends on case capacity, caliber and how much you want to maximize performance of the powder used, velocity desired etc.