Pet Peeve
-
Why are people so lazy? For example, how hard is it to
if (condition)
{
DoThis();
}
else
{
DoThat();
}as opposed to:
if (condition)
DoThis();
else
DoThat();Pedants :sigh:
-
Exactly.
Jeremy Falcon
-
Why are people so lazy? For example, how hard is it to
if (condition)
{
DoThis();
}
else
{
DoThat();
}as opposed to:
if (condition)
DoThis();
else
DoThat();Pedants :sigh:
Cool, Religious war in the Lounge!!! :rolleyes:
I'd rather be phishing!
-
Why are people so lazy? For example, how hard is it to
if (condition)
{
DoThis();
}
else
{
DoThat();
}as opposed to:
if (condition)
DoThis();
else
DoThat();Pedants :sigh:
What exactly is a peeve? and how do you train it? I prefer the second method as a matter of style and space. To each his/her own!
New version: WinHeist Version 2.1.0 There's a fine line between crazy and free spirited and it's usually a prescription. I'm currently unsupervised, I know it freaks me out too but the possibilities are endless.
-
I'm not lazy, but I'll still use the latter. There's no point in always having to use a bracket so I don't, unless it makes things easier to read. Which in your example it doesn't. Wasting space just makes a source code file longer anyway and harder to navigate. Concise wins, unless it's hard to read.
Jeremy Falcon
it doesn't make anything easier to read, and it definitely makes things harder to maintain.
-
Why are people so lazy? For example, how hard is it to
if (condition)
{
DoThis();
}
else
{
DoThat();
}as opposed to:
if (condition)
DoThis();
else
DoThat();Pedants :sigh:
In a coding standard that put's
{
's on their own line I prefer this:if (condition)
DoThis();
else DoThat();If you're putting the
{
on the previous line, IMO they're easy enough to overlook that the explicit closing}
is needed. And if you're writing javascript :(( the opening{
is obligate and this:if (condition) { DoThis();
} else {DoThat();}or this:
if (condition) DoThis() else DoThat();
are obscenities. X|
Did you ever see history portrayed as an old man with a wise brow and pulseless heart, waging all things in the balance of reason? Is not rather the genius of history like an eternal, imploring maiden, full of fire, with a burning heart and flaming soul, humanly warm and humanly beautiful? --Zachris Topelius Training a telescope on one’s own belly button will only reveal lint. You like that? You go right on staring at it. I prefer looking at galaxies. -- Sarah Hoyt
-
Why are people so lazy? For example, how hard is it to
if (condition)
{
DoThis();
}
else
{
DoThat();
}as opposed to:
if (condition)
DoThis();
else
DoThat();Pedants :sigh:
It's not laziness. The second one is quicker and easier to read IF the condition and the branched commands are short. As soon as any of those lines gets the slightest bit complicated, or if there's any nesting at all, I add the braces.
Proud to have finally moved to the A-Ark. Which one are you in?
Author of the Guardians Saga (Sci-Fi/Fantasy novels) -
I'm not lazy, but I'll still use the latter. There's no point in always having to use a bracket so I don't, unless it makes things easier to read. Which in your example it doesn't. Wasting space just makes a source code file longer anyway and harder to navigate. Concise wins, unless it's hard to read.
Jeremy Falcon
I have to { disagree. } I prefer the verbosity and clarity that the braces bring to the code.
Jeremy Falcon wrote:
Concise wins, unless it's hard to read.
Which is usually what happens. People that use the latter form also tend to be the ones that crush every line together so that you first have to separate to properly understand. Is there a lack of space on your screen? In any case a method bigger than a screen is just plain fugly. :)
-
I have to { disagree. } I prefer the verbosity and clarity that the braces bring to the code.
Jeremy Falcon wrote:
Concise wins, unless it's hard to read.
Which is usually what happens. People that use the latter form also tend to be the ones that crush every line together so that you first have to separate to properly understand. Is there a lack of space on your screen? In any case a method bigger than a screen is just plain fugly. :)
Karel Čapek wrote:
I prefer the verbosity and clarity that the braces bring to the code.
You should try VB then.
Jeremy Falcon
-
That's not good enough...
if
(
condition
)
{
this
.
DoThis
(
)
;
}
else
{
this
.
DoThat
(
)
;
}It's not properly formatted until there's only one token per line. :)
Proud to have finally moved to the A-Ark. Which one are you in?
Author of the Guardians Saga (Sci-Fi/Fantasy novels) -
it doesn't make anything easier to read, and it definitely makes things harder to maintain.
Chris, you can't BS me, come on man. You honestly expect me to buy that not using brackets for a single-line if condition makes code harder to maintain? Seriously? Where's the joke icon?
Jeremy Falcon
-
It's not laziness. The second one is quicker and easier to read IF the condition and the branched commands are short. As soon as any of those lines gets the slightest bit complicated, or if there's any nesting at all, I add the braces.
Proud to have finally moved to the A-Ark. Which one are you in?
Author of the Guardians Saga (Sci-Fi/Fantasy novels)Ian Shlasko wrote:
As soon as any of those lines gets the slightest bit complicated, or if there's any nesting at all, I add the braces.
:thumbsup:
Jeremy Falcon
-
Karel Čapek wrote:
I prefer the verbosity and clarity that the braces bring to the code.
You should try VB then.
Jeremy Falcon
Heathen! Blasphemer! How do you even know that VB uses braces???
-
That's not good enough...
if
(
condition
)
{
this
.
DoThis
(
)
;
}
else
{
this
.
DoThat
(
)
;
}It's not properly formatted until there's only one token per line. :)
Proud to have finally moved to the A-Ark. Which one are you in?
Author of the Guardians Saga (Sci-Fi/Fantasy novels)Oooooooo, look at how easy that is to maintain now!! :drool:
Jeremy Falcon
-
Heathen! Blasphemer! How do you even know that VB uses braces???
Ha. Well you see... I work for the devil, but it's only because I'm evil.
Jeremy Falcon
-
Why are people so lazy? For example, how hard is it to
if (condition)
{
DoThis();
}
else
{
DoThat();
}as opposed to:
if (condition)
DoThis();
else
DoThat();Pedants :sigh:
IMHO the latter is easier to read. I've recently had to resort to cheap reading glasses as { started looking like (! (even at 125%} :laugh: I don't always use {}, but when I do, I also prefer then on their own lines for readability. :thumbsup:
"Go forth into the source" - Neal Morse
-
That's not good enough...
if
(
condition
)
{
this
.
DoThis
(
)
;
}
else
{
this
.
DoThat
(
)
;
}It's not properly formatted until there's only one token per line. :)
Proud to have finally moved to the A-Ark. Which one are you in?
Author of the Guardians Saga (Sci-Fi/Fantasy novels)if (condition) { this.DoThis(); } else { this.DoThat(); }
You probably meant
Ian Shlasko wrote:
It's not properly formatted until there's only one token per line in the entire application.
I guess it's theoretically possible... :~
public class SanderRossel : Lazy<Person>
{
public void DoWork()
{
throw new NotSupportedException();
}
} -
Chris, you can't BS me, come on man. You honestly expect me to buy that not using brackets for a single-line if condition makes code harder to maintain? Seriously? Where's the joke icon?
Jeremy Falcon
Sure it's easy, until another developer adds a second line and forgets to add brackets. I've been working in some source code that didn't use brackets for single statements. I introduced a few bugs by not adding them when I had to and I've been wondering more than once if the original developer REALLY meant not to add brackets....
if (condition)
DoThis();
else
DoThat();
DoAnotherThing();is really weird to look at and at the very least makes you wonder if it was intended... Especially if
DoAnotherThing();
isn't properly in/outdented!public class SanderRossel : Lazy<Person>
{
public void DoWork()
{
throw new NotSupportedException();
}
} -
Sure it's easy, until another developer adds a second line and forgets to add brackets. I've been working in some source code that didn't use brackets for single statements. I introduced a few bugs by not adding them when I had to and I've been wondering more than once if the original developer REALLY meant not to add brackets....
if (condition)
DoThis();
else
DoThat();
DoAnotherThing();is really weird to look at and at the very least makes you wonder if it was intended... Especially if
DoAnotherThing();
isn't properly in/outdented!public class SanderRossel : Lazy<Person>
{
public void DoWork()
{
throw new NotSupportedException();
}
}Ok, you have a good point with that, but it's still not worth the trade off of having really extra long files / routines. Besides, it gives you something to spot the new guys with so you can give them a hard time.
Jeremy Falcon
-
IMHO the latter is easier to read. I've recently had to resort to cheap reading glasses as { started looking like (! (even at 125%} :laugh: I don't always use {}, but when I do, I also prefer then on their own lines for readability. :thumbsup:
"Go forth into the source" - Neal Morse