Problem in a program??

Pages: 12
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.
Last edited on
@JLBorges

(See how nice the post looks with lots of vertical white spaces in between!)


As you see yourself you agree with me about vertical lines. :)
It is much nicely to read a well formated book instead of someone summary where there is not seen where some logical unit starts and where it ends.
> As you see yourself you agree with me about vertical lines. :)

Not necessarily. I hold that too much, unnecessary, vertical white space is as bad as having too little vertical white space. In the end, it is a matter of good taste, and above all consistency.

As long as you do not insist that the rest of the world must bow to your personal opinion on the issue, should put braces and white spaces just where you want them to put it, I've no dispute with you.
Topic archived. No new replies allowed.
Pages: 12