Quote:Original post by Jaymar
Quote:Original post by jflanglois
The structure applies, but I really do think your example should be in one language or the other.
Yah, having C# and pseudo-code mixed when my original question was in C++ is a bit weird. But he's essentially selected the second example, as far as I can see.
What about you, jflanglois. Anything to contribute?
Even though I was nitpicky with his example, I actually agree with what ToohrVyk posted. To generalize, though, I would say that you should organize your sanity checking code in the least obtrusive way possible. So for example, in your first piece of code, you essentially repeat your conditions twice. If you check that someString is empty and that someResource is non-null before you do anything with them, then you can assume that ( !someString.empty() && someResource ) is true. The reverse is not true, however. What if you wanted to add another failure condition? Do you want to update that first if statement as well?