As a followup to the earlier posts on taking photographs through windows and on focus stacking I will list some resources after a brief introduction. There are good explanations on the internet and in many books. There are quite a few apps that can be used in Android and Apple phones to quickly estimate the depth of field while taking photographs. However, for understanding the details, and for macro work, the Windows DOF simulator Barnack is, in my opinion, the best tool. Before listing some of these sources of information, it is important to explain that depth-of field is subjective as it is based on what on observer may consider sharp enough. Observers differ both in eyesight acuity and preferences… and we reproduce photographs at different sizes… and expect them to be looked at from different distances… and under different types of illumination… (see Ctein 2013, The Practical Side of Depth of Field). Consequently, most observers will agree that the region in focus is deeper at f/8 than at f/1, but they will in most cases disagree on where the limit between sharp enough focus and not sharp enough focus is. There is no clear transition from focus to blur, it is just a gradient and it is subjective where we consider that sharpness stops being enough.
The concept is still very useful, and allows us to control what will be sharp or blurred. Sometimes we will want to keep everything in focus, while at other times we will want to make sure that only the subject of interest is in focus and everything else out of focus. The extreme example being taking photographs through dirty windows.
Most SLR and mirrorless cameras have a depth-of-field preview button or function that closes the lens diaphragm from its normally fully open position during farming (of course it is always closed to its set value during digital image capture or film exposure). In general is it easier to visualise depth of field with electronic viewfinders which compensate for the decrease in brightness caused by a smaller aperture, thus making it easier to to see the change in depth of field or the extent of sharp and blurred regions (as long as their pixel resolution is good enough).
Warning. A lot has been written in recent years about depth of field and digital sensor sizes. Any such considerations are equally relevant to film sizes. Some sensor sizes as well as film sizes are preferable in some situations and others in other situations. Choice is always a compromise, but cameras are tools, and the best tools are always those you are an expert at using. Some of the arguments used when defending the virtues of different sensor sizes were not based on a solid foundation of optical principles. Mike Johnston and Ctein give very good explanations in posts published in The Online Photogarpher (1, 2, 3), and the program called Barnack will let you experiment, and learn how to control depth of field with whatever camera you have, as long as it allows you to set the aperture used. Whatever camera (or phone) you have, the most important thing is to learn how to use it in a mode in which you can take control.
A tutorial at Cambridge in Colour: concise and clear.
A free simulator for Windows: Barnack, do look at the help.
Photography books, usually in the chapter about lenses.