If we have
$$\frac{dy(x)}{dx}=f(x)g(y(x)),$$
then the careful way of solving this equation (assuming $g(y) \neq 0$) is to divide by $g(y)$ in order to get
$$\frac{1}{g(y(x))} \frac{dy(x)}{dx}=f(x).$$
Replace $x$ with $t$ and integrate each side from an arbitrary lower bound $a$ to $x$:
$$\int_a^{x} \frac{1}{g(y(t))} \frac{dy(t)}{dt} dt= \int_a^{x} f(t) dt$$
Now note that on the LHS we can do the substitution $w=y(t)$, which gives $dw=y'(t) dt$ so that the above becomes
$$\int^{y(x)}_{y(a)} \frac{1}{g(w)} dw =\int_a^x f(t) dt.$$
Now be sloppy with notation and replace $t$ with $x$, $w$ with $y$ and write $y(x)$ as $x$ and $b=y(a)$ so that we have
$$\int^{y}_{b} \frac{1}{g(y)} dy =\int_a^x f(x) dx$$
or
$$\int \frac{1}{g(y)} dy =\int f(x) dx + C.$$
You'll get the exact same thing as if you split up the $dy/dx$, even though it isn't rigorous, so why spend all that time doing it the long way?