How to model supernovae in simulations of star and galaxy formation