there wouldn't be a problem if they don't indent manually. |
Ah, sorry, I guess the snippet I posted didn't really show the point I was making. This probably makes it clearer:
I was talking about the sort of bug that can be introduced by somebody adding a line to:
1 2 3 4 5 6 7 8
|
bSuccess = myFunc();
if (!bSuccess)
return;
// Successful, so carry on doing stuff
bSuccess = myOtherFunc();
// etc...
|
to make this:
1 2 3 4 5 6 7 8 9
|
bSuccess = myFunc();
if (!bSuccess)
std::cout << "myFunc was not successful" << std::endl;
return;
// Successful, so carry on doing stuff
bSuccess = myOtherFunc();
// etc...
|
Yes, it's a silly mistake. But we're all human, we all have bad days, we all sometimes make silly mistakes. I've seen it happen in every single job I've worked in, causing bugs. I've done it myself, although I think I've caught it before it got submitted to a release whenever I've done it. (Then again, how would I know?)
If you start out by putting the braces in even around a one-line block, then it removes the chance of someone introducing a bug in this manner. In a collaborative environment, working on software that needs to be robust, it's a practice I'd recommend adopting.
I've gone back to edit my first post, to make the code clearer. Apologies for any confusion.