Intuitively, $\mathcal{D}$ can be seen as $\mathcal{X}$ with some very small "gaps", i.e. missing points. To extend $f$, you try to fill in the gaps. Here's the basic construction:
Let $x \in \mathcal{X}$. Since $\mathcal{D} \subset \mathcal{X}$ is dense there exists $(x_n)_{n=1}^\infty \subset \mathcal{D}$ such that $x_n \to x$ as $n \to \infty$. Since $x_n$ is convergent, it is Cauchy. Then, by uniform continuity of $f$, $(f(x_n))_{n=1}^\infty \subset \mathcal{Y}$ is Cauchy. (If you were unaware that a uniformly continuous function preserves Cauchy sequences, try to prove it yourself; it is not difficult). Since $\mathcal{Y}$ is complete, $f(x_n) \to y$ for some $y \in \mathcal{Y}$. Define $g$ by $g(x) = y$.
Its not hard to show $g$ and $f$ agree on $\mathcal{D}$, $g$ is uniformly continuous, and uniqueness (hint: if you have another map, they agree on a dense subset!). I'll leave these as an exercise for you. Showing $g$ is well-defined is actually not immediate. Given another sequence $(x_n')_{n=1}^\infty \subset \mathcal{D}$, $x_n' \to x' \in \mathcal{X}$, and $f(x') = y'$ you must show $x'=y'$. To do this my hint is to construct a new sequence out of subsequences of of $x_n$ and $x_n'$ and play with the convergence of that sequence. Good luck!