First Rule -- Hold It Steady!
Before anything else, it is worth pondering the point that image sharpness in common practice is more likely to be degraded by camera movement than anything else.
You can fettle f/stop and focus to maximize depth of field ((DOF) and ISO to minimize grain or image noise until the cows come home, but if the camera moves during exposure it all goes for naught.
This leads me to advise, right up front that you worry little about sharpness decline due to diffraction at small f/stops, and worry a lot about the law of reciprocity as applied to exposure.
In a nutshell in this context, the reciprocity law says smaller f/stops mean slower shutter speeds at any given ISO, and slower shutter speeds aggravate the effect of camera movement on image sharpness. This is one of the few immutable laws or rules in photography – an honest-to-goodness verity.
In general, I focus on what my judgment says is the main point of interest or a dominant feature in the frame, and choose an f/stop that will either extend or contract the depth of field (DOF) to suit my fancy and capacity to keep the camera steady during exposure. I may adjust ISO to achieve the desired result.
It is a juggling act with three balls in the air at all times.
But, since the discussion here has centered on focus and f/stop …
Finding the right f/stop comes of experience and experimentation, once you understand the basic rule: the smaller the f/stop, the greater the DOF at any given focusing distance (and vice-versa). I don’t think there is any magic formula. The advice already dispensed here about hyperfocal distance (HD) and focusing 1/3 (or 2/5) of the way into the scene to maximize apparent front-to-back sharpness is a good starting point, but it isn’t the ending point by any means.
This may be saying the very obvious, but in this age of automated-everything in our cameras, one of the great “problems” lies in overriding the autofocus system to lock the focus where we want it when we compose in the viewfinder. Without the ability to do that, all chit-chat about things like hyperfocal distance becomes moot.
I generally do not use the shutter release activated autofocus option on my cameras, except when shooting sports or other fast-moving action. Instead, I use a separate button on the camera body to activate the autofocus: this allows for locking the focus by letting up on the button, and reframing, all in an instant before releasing the shutter.
Sometimes, manual focus is the better way to go, provided the focusing screen actually allows for doing it accurately. Plain ground glass focusing screens – some etched with vertical and horizontal lines to help keep horizons level and verticals (reasonably) vertical – always were my favorites on manual focus 35mm film SLRs. In more recent years I haven’t found the screens on autofocus SLRs to be that great for manual focusing, but then, I’m also not getting any younger and my eyes aren’t getting any sharper, either.
One other point to remember is that some of the wonderful apparent sharpness and sharpness-in-depth we see in images these days results from skillful use of “sharpening” technique in post-shoot image processing. That is a whole ‘nother topic, really, but it does introduce a pertinent concept.
What we are discussing, in the end, is not so much absolute image sharpness as it is perceived image sharpness.
We want to trick the eye/brain into believeing that every detail is rendered in crisp focus, even if it isn’t. That is where the sharpening tools in processing programs like Photoshop work their magic.
In the old days, we used to make sure our prints were “grain sharp,” i.e., when inspected under magnification, the actual grain of the film was crisply focused on the print. Even grainy film images that were quite “fuzzy” in reality (due to misfocus or camera/subject movement) could achieve an exciting visual crispness by being printed “grain sharp.”
Our eye/brain really appreciates what is known as acutance, or “edge sharpness” in an image.
Pay attention to all the advice here, of course. But in the end, just keep shooting and experimenting to find your own way on this, always remembering first and foremost to “hold ‘er steady.”
G.