Let $G$ be a connected graph with vertex set $V(G)$. For $u,v \in V(G)$, by $d(v)$ and $d(u,v)$ are denoted the degree of the vertex $v$ and the distance between the vertices $u$ and $v$. A much studied degree--and--distance--based graph invariant is the degree distance, defined as $DD=\sum_{\{u,v\}\subseteq V(G)} [d(u)+d(v)]\,d(u,v)$. A related such invariant is $ZZ=\sum_{\{u,v\}\subseteq V(G)} [d(u) \times d(v)]\,d(u,v)$. If $G$ is a tree, then both $DD$ and $ZZ$ are linearly related with the Wiener index $W = \sum_{\{u,v\}\subseteq V(G)} d(u,v)$. We show how these relations can be extended in the case when $d(u)$ and $d(v)$ are replaced by $f(u)$ and $f(v)$, where $f$ is any function of the corresponding vertex. We also give a few remarks concerning the discovery of $DD$ and $ZZ$.