|
High five!
"Go forth into the source" - Neal Morse
|
|
|
|
|
The decision which to use is simple:
- follow the coding standard
- if you don't have it, use whichever style is used in file/project
- new project/file, use whatever you find more atheistically pleasing to you
Personal atheistic preference is one of very few arguments that I can accept as valid in this "debate" (like in any other debate on any kind of style).
The only argument that is supported by concrete numbers is saved on-screen space by the second style. All other arguments are largely unsubstantiated (maybe I'm wrong, but let me see some numbers)
So don't go around calling people lazy just because they don't conform to your preference, it can make you look obnoxious.
<edit>
My preference: ?: . What' you gonna do now?
<edit>
|
|
|
|
|
Mladen Janković wrote: So don't go around calling people lazy just because they don't conform to your preference, it can make you look obnoxious.
++Mladen.rep;
|
|
|
|
|
Mladen Janković wrote: it can make you look obnoxious.
But I am obnoxious
|
|
|
|
|
Well I can't argue with that
|
|
|
|
|
Do you really require 8 lines to convey 4 lines worth of information?
Perhaps "begin" and "end" would be even more clear? How about "then"?
if (condition) then
begin
DoThis();
end
else
begin
DoThat();
end;
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
oh dear lord
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87֦ʻ6ϣN8ȤBcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKQUFK[M`UKs*$GwU#QDXBER@CBN%
R0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-iTV.C\y<pjxsg-b$f4ia>
-----------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
LOL, that looks exactly like T-SQL
|
|
|
|
|
I am not lazy (well, I may be, but that's not the point) and the reason I prefer the latter is to reduce the noise. Less noise, more readability.
|
|
|
|
|
Personally, for one line this-or-that...
condition.IfTrue(()=>DoThis()).Else(()=>DoThat());
Marc
|
|
|
|
|
Yes, I am sure for your disciples that's a very good thing
«OOP to me means only messaging, local retention and protection and hiding of state-process, and extreme late-binding of all things. » Alan Kay's clarification on what he meant by the term "Object" in "Object-Oriented Programming."
|
|
|
|
|
If both branches are a single line, I prefer the second. However, I've seen too much of this abomination:
if (condition)
{
DoThis();
DoSomethingElse();
}
else
DoThat();
|
|
|
|
|
If there's only one "do", the whole thing should be on one line.
The reason the blocks were introduced is because multiple "do"s on one line are hard to read, so insisting that a single "do" be in a block is taking the idea in the wrong direction.
I wanna be a eunuchs developer! Pass me a bread knife!
|
|
|
|
|
Perhaps best to blame the language designers for allowing such freedom ?
I'm with Chris L. and others who point out we're no longer in the age of fewer-characters-are-best-because-memory's-so-precious that we can't afford white-space, or beaucoup de braces.
C# code that looks like VB has the smell of sewage to me (note: I do not "hate" VB).
«OOP to me means only messaging, local retention and protection and hiding of state-process, and extreme late-binding of all things. » Alan Kay's clarification on what he meant by the term "Object" in "Object-Oriented Programming."
|
|
|
|
|
They think, If we write that way then our system will be heavy as each character has some byte.
|
|
|
|
|
How would you feel about
condition ? DoThis() : DoThat(); ?
My plan is to live forever ... so far so good
|
|
|
|
|
condition
? DoThis()
: DoThat();
And now?
All in all none of this really matters. As long as everyone on the project sticks to a predetermined coding standard, then the format doesn't matter as much, as long as its consistent.
Consistency in code can resolve a huge amount of misunderstanding.
|
|
|
|
|
Standard? STANDARD? What's that???
I found that we do keep to standards whenever all the other developers code exactly the same way as I do.
My plan is to live forever ... so far so good
|
|
|
|
|
The reason I moved from VB.NET to C# was the curly braces bro! Don't make me give up the curly braces!
I don't speak Idiot - please talk slowly and clearly
"I have sexdaily. I mean dyslexia. Fcuk!"
Driven to the arms of Heineken by the wife
|
|
|
|
|
I don't care very much as long as it's consistent.
But since you can't make multiple statements without braces...
Wrong is evil and must be defeated. - Jeff Ello
(√-sh*t) 2
|
|
|
|
|
Either one of those suits me fine. The ones I can't stand are these:
if (condition)
{
DoThis();
}
else
DoThat();
if (condition)
DoThis();
else
{
DoThat();
}
Anything that is unrelated to elephants is irrelephant Anonymous ----- The problem with quotes on the internet is that you can never tell if they're genuine Winston Churchill, 1944 ----- I'd just like a chance to prove that money can't make me happy. Me, all the time
|
|
|
|
|
And then there is the choice between:
if (condition) vs if (condition == true)
if (!condition) vs if (condition == false)
I sometimes put in the == false part because the ! is easy to miss when reading.
|
|
|
|
|
Karel Čapek wrote: Why are people so lazy?
Did it occur to you that it may be about style and not laziness?
Some people can have even another style:
if (condition) DoThis();
else DoThat();
To alcohol! The cause of, and solution to, all of life's problems - Homer Simpson
----
Our heads are round so our thoughts can change direction - Francis Picabia
|
|
|
|
|
Fabio Franco wrote: Did it occur to you that it may be about style and not laziness?
No: people who do this tend to shortcut other things (sweeping generalization and/or observation over many years of being a coder) or crush the code into as small a space as possible making it hard to read.
The point is really to have consistency of style and format in the code: braces make it easier to read. Consider this:
int a = 0;
string bean = "green";
float golden= 1.618;
if (condition)
{
x = 42;
bean = "eatme";
golden = a * pi;
}
else
a = 1;
bean = 'foo';
golden = a - x;
I find that style difficult to read and adding the braces would make it much easier to see the flow.
Oh, and then there are tabs v spaces...
|
|
|
|
|
I only remove braces on single-line method preconditions at the beginning of a method:
if (arg==null) throw new ArgumentNullException("arg", arg);
Everywhere else I put braces.
|
|
|
|