On Thursday, January 19, 2012 17:29:28 bearophile wrote: > If I am mistaken please I'd like to know why the current design is better > (or maybe why it's just equally good). Thank you :-)
Honestly, I don't think that the order is all that critical, since all of the same assertions are run in either case. But conceptually, the invariant is for verifying the state of the object, whereas the post-condition is for verifying the state of the return value. And the return value doesn't really matter if the object itself just got fried by the function call. Not to mention, if your tests of the return value in the post-condition rely on the state of the object itself being correct, then your tests in the post-condition aren't necessarily going to do what you expect if the invariant would have failed. I have no idea what Walter's reasoning is though. - Jonathan M Davis
