Task Summary
There are a couple of ways to ascertain the correct cable housing length. Its possible to keep the old cable housing length and to use it as a template for the new one. The most reliable way however, is to insert the housing into the lever end, then run it across the bars and down, curving it back towards the first boss on the top tube of the frame as shown here (we are looking at the housing with the mechanic's thumb on it.). After you have measured the lengths, go to cable housing preparation for tips on how to cut and prepare the housing for fitting.
Front Brake

You are looking to create a nice even curve - do not kink the housing at all.

Cable Too Short?
Place the housing in the lever and the frame boss and give it another test - turn the handlebars to their extreme opposite as shown above. There should still be a very small amount of slack in the cable. If the cable is pulling (or too short) you will restrict the movement of the bars.
Cable Too Long?
If you leave the cable housing too long you will get a nasty, flabby effect where the housing flaps around.
WORKSHOP TIP: Bikes that are set up in the factory can often come with the cable housing too loose. This means that you will have to correct them in the workshop before selling on.
Rear Brake

The same principles apply - cut a length that follows the curve nicely as shown here that is neither too flabby or to tight.




