How engineers think about the choice
There is no universally best shaft form. A designer considers the whole application: the torque and other loads, rotational speed, required stiffness, available space, connections to neighboring components, operating environment, and manufacturing needs. A form that solves one problem may introduce another. A hollow design, for instance, changes the distribution of material; a flexible design allows bending but is not interchangeable with a rigid shaft; a spline provides a particular kind of engagement but requires a compatible mating part.
Manufacturing is part of the picture, too. Turning, forging, heat treatment, and finishing can shape the geometry and properties of a component. The route depends on the part and its intended service. Read more in How Mechanical Shafts Are Made.
Learning note: This overview explains common forms, not how to specify or approve a shaft for service. Actual selection and design require application-specific calculations, standards, manufacturer information, and qualified engineering review.