Calculating entropy: why consider a reversible path? I am reading up on entropy in a textbook and I got confused by this:

It says that to calculate the entropy for an irreversible process using heat flow, one must imagine the reversible process in which the initial and final states are the same as for the irreversible process. Why is this so and why do we need to think of it in the reversible way?
There are two parts to this answer.  The first is that the entropy change is defined only for reversible processes.  The second is that the entropy is a state function.  Many, but not all, the functions in thermodynamics (including the internal energy) are state functions.

A state function is one that is independent of path.  That is, if one goes from state $A$ to state $B$, the change in internal energy is independent of how the change takes place.  The same is true for the entropy.

So the entropy change in going from state $A$ to state $B$ is independent of how the change takes place.  But we can calculate the change ONLY for reversible changes.

So we mentally find a reversible path from state $A$ to state $B$ and calculate the entropy change.  Since entropy is a state function, that must also be the change for a non-reversible path.