Writing detailed commit notes can be useful in the same way. I have backed out of a commit during the write up more times than I would like to admit because I realized that I hadn't covered some edge case or I completely forgot about something (like the effect of the change on a report or other sub-system). Writing things out in a way that someone else can understand forces you to re-think through the task in different ways.