Just
as you decide which shutter speed is depending on how fast the subject is moving,
you decide the aperture value depending on how much depth-of-field you want. Of course,
you don't always have much choice.
If you're shooting soccer or a hockey match, you have to use faster shutter speeds
-- and make do with less depth-of-field. If you're shooting a garden or landscape,
however, you will almost certainly want maximum depth-of-field.
Keep in mind that depth-of-field doesn't neatly extend the same distance in front
of and behind the point of focus. For any given amount of depth-of-field, roughly
one-third of it will fall in front of the point you've focused on and two-thirds
will be behind it.
Occasionally, you will come across a situation where all the elements in the scene
won't quite "fit" inside the amount of depth-of-field you can manage. By
focusing slightly behind the main element, you might just be able to get everything
in. There are two other techniques on how to maximize the depth-of-field in your
pictures. One is a proven method not many amateurs know of and the other is exclusive
only to EOS users. They are known as the HYPERFOCAL DISTANCE and DEPTH-of-FIELD AE
respectively.