How to create well-aligned, clean structure to define a function (mathematics)?

I want the \mathcal{D} to be just in line with the start of the limit in the \mapsto row.

I would use a top-aligned aligned (pun intended...) environment:

enter image description here

\documentclass{article} % or some other suitable document class
\usepackage{mathtools}  % for "\smashoperator" macro
\begin{document}
\[
X \colon \begin{aligned}[t]
          &T\rightarrow \mathcal{D} \\
          &t\mapsto \lim_{n \to \infty}
             \smashoperator[r]{\sum_{i = 0,\dots,m}}
             (f(t_{i,n})-f(t_{i-1,n}))\cdot
             (f(t_{i,n})-f(t_{i-1,n}))
         \end{aligned}          
\]
\end{document}

Addendum: Here's a solution that implements @barbarabeeton's suggestion that the \rightarrow and \mapsto symbols should be aligned as well.

enter image description here

\documentclass{article}
\usepackage{array,mathtools}
\begin{document}
\[
\setlength\arraycolsep{0pt}
X \colon \begin{array}[t]{ r >{{}}c<{{}} >{\displaystyle}l }
          T &\rightarrow &\mathcal{D} \\[0.5ex]
          t & \mapsto    & 
             \smashoperator[l]{\lim_{n \to \infty}}
             \smashoperator[r]{\sum_{i = 0,\dots,m}}
             \bigl(f(t_{i,n})-f(t_{i-1,n})\bigr)
             \bigl(f(t_{i,n})-f(t_{i-1,n})\bigr)
         \end{array}          
\]
\end{document}

Using Vincent's idea of an array, but with some more tricks to keep barbara beeton happy:

\documentclass{article}
\usepackage{amsmath,mathtools,calc}
\usepackage{array}

\begin{document}

\[
\begin{array}{
  @{}
  r
  @{}
  c
  @{}
  >{\displaystyle{}}l
  @{}
}
X \colon{} & T & \to \mathop{\mathmakebox[\widthof{$\lim$}][l]{\mathcal{D}}}_{\hphantom{n\to\infty}} \\[1ex]
           & t & \mapsto 
               \lim_{n \to \infty}\sum_{i=0,\dots,m} \mspace{-9mu}
                  \bigl(f(t_{i,n})-f(t_{i-1,n})\bigr)\cdot\bigl(f(t_{i,n})-f(t_{i-1,n})\bigr)
\end{array}
\]

\end{document}

enter image description here

On the other hand, I'd simply do

We can define the map $X\colon T\to\mathcal{D}$ by
\begin{equation*}
X(t)=\lim_{n \to \infty}\sum_{i=0,\dots,m} \mspace{-9mu}
      \bigl(f(t_{i,n})-f(t_{i-1,n})\bigr)\cdot\bigl(f(t_{i,n})-f(t_{i-1,n})\bigr)
\end{equation*}

enter image description here


After seeing the other answers... I really would like to reiterate my comment and use align here, with all the explanations being contained in barbara's comment (sorry, Mico ;-).

\documentclass{article}
\usepackage{mathtools}
\begin{document}
\begin{align*}
X \colon T &\rightarrow \mathcal{D} \\
           t&\mapsto \lim\limits_{n \to \infty}
            \sum_{\substack{i =0,\dots,m}}
            (f(t_{i,n})-f(t_{i-1,n})\cdot(f(t_{i,n})-f(t_{i-1,n}))
\end{align*}

\emph{Maybe} one could use \verb|\mathclap| to align the $\mathcal{D}$ with
$\lim$ (but I am not coninced).
\begin{align*}
X \colon T &\rightarrow \mathcal{D} \\
           t&\mapsto \lim\limits_{\mathclap{n \to \infty}}\;
            \sum_{\substack{i =0,\dots,m}}
            (f(t_{i,n})-f(t_{i-1,n})\cdot(f(t_{i,n})-f(t_{i-1,n}))
\end{align*}
Or, in the spirit of barbara beeton's comment.
\begin{align*}
X \colon T &\rightarrow\setbox0\hbox{$\lim\limits_{n \to \infty}$}%
\setbox1\hbox{$\lim$}%
\hspace{\the\dimexpr0.5\wd0-0.5\wd1}\mathcal{D} \\
           t&\mapsto \lim\limits_{n \to \infty}\;
            \sum_{\substack{i =0,\dots,m}}
            (f(t_{i,n})-f(t_{i-1,n})\cdot(f(t_{i,n})-f(t_{i-1,n}))
\end{align*}
\end{document}

enter image description here