What am I doing when I separate the variables of a differential equation? I see an equation like this:

$$y\frac{\textrm{d}y}{\textrm{d}x} = e^x$$

and solve it by "separating variables" like this:

$$y\textrm{d}y = e^x\textrm{d}x$$
$$\int y\textrm{d}y = \int e^x\textrm{d}x$$
$$y^2/2  = e^x + c$$

What am I doing when I solve an equation this way?  Because $\textrm{d}y/\textrm{d}x$ actually means

$$\lim_{\Delta x \to 0} \frac{\Delta y}{\Delta x}$$

they are not really separate entities I can multiply around algebraically.  

I can check the solution when I'm done this procedure, and I've never run into problems with it.  Nonetheless, what is the justification behind it?

What I thought of to do in this particular case is write

$$\int y \frac{\textrm{d}y}{\textrm{d}x}\textrm{d}x = \int e^x\textrm{d}x$$
$$\int \frac{\textrm{d}}{\textrm{d}x}(y^2/2)\textrm{d}x = e^x + c$$

then by the fundamental theorem of calculus

$$y^2/2 = e^x + c$$

Is this correct?  Will such a procedure work every time I can find a way to separate variables?
The basic justification is that integration by substitution works, which in turn is justified by the chain rule and the fundamental theorem of calculus.

More specifically, suppose you have: $$\frac{dy}{dx} = g(x) h(y)$$
Rewrite as:
$$\frac{1}{h(y)} \frac{dy}{dx} = g(x)$$  Add the implicit dependency of $y$ on $x$ to obtain
$$\frac{1}{h(y(x))} \frac{dy}{dx} = g(x)$$

Now, integrate both sides with respect to $x$:
$$\int \frac{1}{h(y(x))} \frac{dy}{dx} \, dx = \int g(x) \, dx$$ If we do a variable substitution of $y$ for $x$ on the left-hand side (i.e., use the integration by substitution technique), we replace $\frac{dy}{dx} dx$ with $dy$. Thus we have $$\int \frac{1}{h(y)}\, dy = \int g(x) \, dx,$$
which is the separation of variables formula.

So if you believe integration by substitution, then separation of variables is valid.
Seperation of variables involves manipulating the differentials (the $dx$'s and $dy$'s in your equation). A differential is the infinitesimal change in a variable, and can be treated as a variable in its own right in many applications. With this perspective, $dy$ is a function of $x$ and $dx$, and the derivative $dy/dx$ is the ratio of these two differentials, which is a function of $x$. What you are doing is simply performing an algebraic manipulation of these variables and then using calculus to remove the differential terms.