|
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;
|
|
|
|
|
But in that case I prefer(in single line with braces)
if (myObject == null) { return; }
|
|
|
|
|
Also wrapping increases no of lines...
A drop of water breaks a rock not by brute force but by patience.
|
|
|
|
|
Wrapping increases readability of code.
JKOZA
|
|
|
|
|
Readability in this case is just about what you're used to. It's more a matter of being consistent in your coding style.
|
|
|
|
|
Readability matters when the code size increase and it is in maitainance stage or it moves from one developer to another developer.
JKOZA
|
|
|
|
|
No-one said readability doesn't matter.
|
|
|
|
|
Consistency in coding style comes automatically for a regular developer, but readability is equally important for a project.
JKOZA
|
|
|
|
|
You are talking about readability in general, which is not what the poll is about. It compares two styles. Some say the one is more readable, some say the other. If you for a second forget your own preferences, it's not hard to see that readability here is just a matter of what style one's used to. So, I'm saying readability is not the issue here. The two styles can however have other benefits over the other.
Only because you say apples taste better than pears, doesn't mean you're right. It doesn't mean you're wrong either, if you see what I mean.
|
|
|
|
|
I agree that two styles can have other benefits over the other. And I am also not saying that I am right. And I am talking about readability in terms of these two styles only. I am just telling my point of view. And I am comparing two styles by readability which can be one of the points to compare two styles. And if there is no points common between two styles then how can you compare two styles?
JKOZA
|
|
|
|
|
I agree otherwise. Wrapping increases indentation and readability.
// ♫ 99 little bugs in the code,
// 99 bugs in the code
// We fix a bug, compile it again
// 101 little bugs in the code ♫
|
|
|
|
|
|
I worked in team where sometimes other developers just insert a line below/above it and expect everything to work just fine.
|
|
|
|