I use the cable as a guide, sliding the housing out of the frame leaving the shift/brake cable intact then sliding the new housing up the cable. I don't worry about the length at that moment, only that it extends beyond both ends of the frame, then I remove the cable and size the housing cutting it to the correct length. I then install a new cable and voila I'm done.