|
It is good pratice and follow it always to wrap any number of lines.
|
|
|
|
|
Consistency is a wonderful thing!
------------------------------------
I will never again mention that I was the poster of the One Millionth Lounge Post, nor that it was complete drivel. Dalek Dave
CCC Link[ ^]
Trolls[ ^]
|
|
|
|
|
And you can always add statements later without having to remember to add the now needed braces.
Cheers!
|
|
|
|
|
I agree with this. Many times I used to confuse with unwrapped single lines
|
|
|
|
|
If you have trouble remembering to add braces after inserting new lines you should consider changing your career.
|
|
|
|
|
And yet, you don't know how to handle braces correctly... I admire you persistence. So tell me how did you get so far, by name calling?
|
|
|
|
|
|
Agreed, consistency is the key, thus I never wrap single line blocks - I'm consistently trying to reduce nuber of code lines.
|
|
|
|
|
If it is an if followed by a single line or an if-else where both are followed by single lines, then I don't wrap. If multiple lines occur in either part of an if-else , then I wrap both parts.
|
|
|
|
|
It is better to wrap the lines, even if it is a single line. It reduces the confusion and future bugs.
Regards - Kunal Chowdhury | Microsoft MVP (Silverlight) | CodeProject MVP | Software Engineer
|
|
|
|
|
strongly agree
|
|
|
|
|
agree
just have to enforce myself..
|
|
|
|
|
A person might be able to play without being creative, but he sure can't be creative without playing.
|
|
|
|
|
Agree
|
|
|
|
|
I feel that code should always be wrapped between braces. (readability) Not doing it for single line statements would surly be inconsistent towards the rest of your code. (consistency)
"Program testing can be used to show the presence of bugs, but never to show their absence."
<< please vote!! >>
|
|
|
|
|
Single:
if ( pWnd == NULL)
return;
Multiple:
if ( pWnd == NULL) {
return;
} else if ( pWnd->IsWindowVisible()) {
return;
}
|
|
|
|
|
Back when I used to code without using code blocks for single line statements, I would occasionally add some code later on for one of the branches and find that I'd forget to add the block and the indentation would trick me into thinking a code block was there causing me to chase my tail for bit.
What a time waster.
I just got to the point where I'd always use code blocks, to prevent these silly mishaps.
|
|
|
|
|
|
If anybody get used to he will never make the mistakes again. Else its always good what you like to do as adding blocks has no effect on performance ......
|
|
|
|
|
I had done one mistake and running code stop working, after debugging the code I realized that I comment the line after if.Total waste of 1-2 hour.
"Every Little Smile can touch Somebody's Heart...
May we find Hundreds of Reasons to Smile Everyday... and
May WE be the Reason for someone else to smile always!" (ICAN)
|
|
|
|
|
Regards - Kunal Chowdhury | Microsoft MVP (Silverlight) | CodeProject MVP | Software Engineer
|
|
|
|
|
"Every Little Smile can touch Somebody's Heart...
May we find Hundreds of Reasons to Smile Everyday... and
May WE be the Reason for someone else to smile always!" (ICAN)
|
|
|
|
|
ShilpiP wrote: Always wrapped..
FTFY
The more anger towards the past you carry in your heart, the less capable you are of loving in the present.
My Blog![ ^]
|
|
|
|
|
Thanks
"Every Little Smile can touch Somebody's Heart...
May we find Hundreds of Reasons to Smile Everyday... and
May WE be the Reason for someone else to smile always!" (ICAN)
|
|
|
|
|
if I am checking for null like,
if (myObject == null)
return;
|
|
|
|