I think an important part is to stop the thinking that says "Uh-oh I just ate a whole pile of cake which blows the diet for today... better start tomorrow" Instead think "Well I ate some cake which was probably not the best choice, but for the rest of the day I am going to continuing with my healthy eating" or something similar.

The first thoughts are negative and make us feel worse about ourselves, while the second is a bit more positive IYKWIM. I really believe that the thoughts we have about what we are doing h=makes such a big contribution.