Let $T: \operatorname{dom}(T) \to \mathcal H$ a linear operator such that $\operatorname{dom}(T)$ is densely defined, i.e. $\overline{\operatorname{dom}(T)} = \mathcal H$ ($\ast$).
Define $\operatorname{dom}(T^*) : = \{y \in \mathcal H: x \mapsto \langle Tx,y \rangle $is continuous on $\operatorname{dom}(T)\}$. For $y \in \operatorname{dom}(T^*)$, we can extend $x \mapsto \langle Tx,y \rangle$ to a continuous mapping on $\mathcal H$ by Riesz in the form of $x \mapsto \langle x,z \rangle$ for some $z \in \mathcal H$. Here it says, that we need the densely definedness of $\operatorname{dom}(T)$ for $z$ to be unique. Set $T^{*}y := z$ to define the adjoint operator for T.
Q: I actually don't see why we need ($\ast$) for $z$ to be unique because there is a Hahn-Banach version for Hilbert spaces: Let $L \subset \mathcal H$ be a linear subspace $g \in L^*$ $\Rightarrow$ there exists a unique $f \in \mathcal H^*$: $f|_{L} = g$ and $\|f\|= \|g\|$. Since $\operatorname{dom}(T) \subset \mathcal H$ is linear space and $y \in (\operatorname{dom}(T))^*$ I don't see why the preconditions aren't fulfilled.
Denseness is necessary for $T^*y$ to be unique. Suppose the domain is not dense, that means there must exist a non-zero vector $z$ orthogonal to the entire domain.
If $y\in\mathrm{dom}(T^*)$ and $f\in H^*$ is an extension of $x\mapsto \langle Tx,y\rangle$ you have $f+\langle\cdot,z\rangle$ also is an extension of the above mapping (as $\langle x,z\rangle=0$ for all $x\in \mathrm{dom}(T)$). These two extensions are not the same, and so uniqueness fails.