Computer-implemented method of preoperatively determining the optimized external shape of a prosthetic femoral hip stem for use in partial cementing hip replacement procedures and of a reamer for reaming a cavity in the femur of a patient for implanting the prosthetic femoral hip stem, comprising: a) setting an initial external shape of the prosthetic femoral hip stem based on the reconstructed femur anatomy of a patient, b) generating an associated initial reamer by negatively offsetting the initial external shape of the prosthetic femoral hip stem by an uniform offset value δ, c) calculating contact stresses at the interface of the prosthetic femoral hip stem and the patients femur when reamed by the initial reamer and d) optimizing the offset value δ, so that the contact stresses are within a predetermined acceptable range.