The textbook definition is the correct way to start and then when doing calculations or measurements for real-life situations you are not dealing with infinitesimal mass elements but with greater volumes (say $V$) for which you calculate an (average) absorbed dose
$$
D=\frac{E}{M} = \frac{\int_V \text{d}E}{\int_V \text{d}M}\,.
$$
Note that this average dose is only a reasonable measure in a homogeneous radiation field. Say you were holding a radioactive source in your right hand, you could calculate an average absorbed dose for your body which would not be an appropriate measure for the radiation absorbed in your right hand, which would have a much higher absorbed dose.
Essentially the question you are facing is a quite general one, equivalent to the difference between average mass density and local mass density or local and average values for other quantities.