3 ms·
Not to give it away, but another example is when Joel says that, to know whether dosomething() might throw an exception, you have to read all down through its c
by ncmncm 4y ago
Not to give it away, but another example is when Joel says that, to know whether dosomething() might throw an exception, you have to read all down through its call tree, you know you are off in the weeds. Obviously it might throw. Even if it doesn't today, it might tomorrow. So you don't need to guess or explore whether cleanup(), there, is wrong. You already know it's wrong. Cleanup code goes in destructors. Period. Destructors always run.
Other people posting here have noted that using our language's type system intelligently is how we make trouble fail to compile. Counting on our and our colleagues' finely-tuned sense of rightness to keep out bad code is a recipe for having Bad Code. It suffices to explain Microsoft.