Well, let's look at it like this. With a new Mac, you lose around 20% when reselling it after a year. So after 5 years, you have essentially bought your second new Mac. However, you always have an up-do-date machine that is covered by warranty, so you will never need to spend any money for repairs or service. If you are in Europe (2 years warranty), you could get a new Mac every 2.nd year (losing around 30% in resale) which would be a still better deal. In addition, replacing Macs becomes an amazingly good deal if you have access to edu discount.
To sum it up: with the benefit of having constant warranty and a current-gen machine, I'd always go the 'replace' route. But I also never keep the same computer for longer than 3 years. The performance difference becomes too much a factor.