What a refrigerator does is the opposite of what a heat engine does. Therefore, a refrigerator takes in heat $Q_c$ from cold reservoir and throws heat $Q_h$ to hot reservoir. The work $W$ should be done to take the heat $Q_h$ to the hot reservoir. All natural processes are irreversible processes so the heat flow from a hotter region to a colder region across a finite temperature difference is an irreversible process (as already noted that a reversible process is an idealization that is takes place in infinitesimal steps). And some work must be done to take the heat from the cold reservoir to the hot reservoir. The Figure 1 shows the energy flow diagram of a refrigerator. The energy relationship for a refrigerator is

\[{Q_h} = W - {Q_c} \tag{1} \label{1} \]

Note that the heat $Q_c$ flows into the system so it is positive, and heat $Q_h$ flows out of the system and it is negative. The work $W$ is done on the system and therefore it is negative. Considering the sign conventions the above equation for the energy relationship of a refrigerator is valid. You can also understand the above equation in terms of absolute values, that is $\left| {{Q_h}} \right| = \left| W \right| + \left| {{Q_c}} \right|$.

The ratio $Q_c/W$ or the ratio of heat taken from the cold reservoir to the mechanical work done by external source is called the coefficient of performance or COP of a refrigerator. The same idea for the efficiency of a heat engine and the coefficient of performance of a refrigerator is to find the ratio of energy gained (what you gain) to expenditure of energy (what you lose).

\[{\rm{CO}}{{\rm{P}}_r} = \frac{{{Q_c}}}{{\left| W \right|}} \tag{2} \label{2}\]

The subscript $r$ in the above equation represents refrigerator and the Equation \eqref{2} gives the coefficient of performance of the refrigerator.