|
You can do this too;
if (condition) { statement; }
Someday it will save your life (or that of your successor).
------------------<;,><-------------------
|
|
|
|
|
Counteracted the vote of 1 by some 'tool'. Gave you a 5, you made a valid point. Some would consider it redundant, but who cares?
RedSonja wrote: Someday it will save your life (or that of your successor).
I'm not too sure that writing code will save anyone's life, but whatever floats one's boat.
Enjoy your day
P.S.
It seems that the law of averages here don't work properly. Or perhaps the comment voting system has changed.
Shouldn't 1 (original vote) +5 (my vote) /2 (number of votes) be equal to 3 (true result based on the aforementioned math)? Or is it that my vote isn't truly one vote, as much as it is apparently equal to (0.8/5)=0.16 of a vote point per point that I voted? *shrugs*
Some say that ignorance is bliss... Blissful, aren't they?
|
|
|
|
|
I also find the following easier to read:
if (condition) statement;
|
|
|
|
|
This one made me laugh
'Till a very short while ago say... a couple of months I never done this.
What made me change were my co-workers that were always saying it was a bad practice and they had a bad time reading my code because of that .
To stop earing them I just started doing it... eh... I still don't find it necessary and my brain processes that code with no problem.
Cheers!
Alex
|
|
|
|
|
The way you use braces, end statements etc is entirely down to the syntax of the language, local standards, if any, and personal preference.
The compiler does not care, readable code needs only to be consistent.
Another discussion on the very old topic is, in my opinion, a waste of time.
|
|
|
|
|
Who cares? We do, the people who have to maintain it.
Only valid for serious code, of course.
------------------<;,><-------------------
|
|
|
|
|
That was the entire point of my including consistency. I too have to maintain legacy code as well as developing new and I have been a professional development, degree qualified and chartered, engineer for more than twenty years so I do fully understand the issues. But personal preference has nothing, in this context, to do with writing quality code.
|
|
|
|
|
You'll be surprised (I know I am) how many people care!
Moreover, I had so many pointless discussion on this pointless topic. Apparently it encourage good "maintainability"
I guess it's from people who have little other criteria!
BTW, since I met MVVM, I think my code maintainability has progressed significantly!
(way more significantly that this old pointless debate! :P )
A train station is where the train stops. A bus station is where the bus stops. On my desk, I have a work station....
_________________________________________________________
My programs never have bugs, they just develop random features.
|
|
|
|
|
Paul Darlington wrote: Another discussion on the very old topic is, in my opinion, a waste of time.
And yet you're discussing it. If you're not happy Mr Grumpy-pants, come up with your own survey. This game is open to all.
|
|
|
|
|
Provocative statements invariably generate interesting responses, Fun here isn't it
|
|
|
|
|
That's why I keep coming back.
|
|
|
|
|
Spot on! But suggesting that it is irrelevant won't get you sympathy from readability part of crowd.
I don't wrap... it looks ugly as hell (to me), it's that simple, everything else are just made-up excuses.
|
|
|
|
|
Paul Darlington wrote: Another discussion on the very old topic is, in my opinion, a waste of time
But we're software developers and we love religious wars!
In reality, whatever people answer on this it would not be top of my list of maintainability bugbears.
Kevin
|
|
|
|
|
Every, every time!
In legacy code I inherit this is so often the cause of errors. Anyway, the programming standards demand it. OK, it was me who wrote it in there, but it makes sense.
If you want to save space, you can write
if (errcode == 1) { return iError; }
------------------<;,><-------------------
|
|
|
|
|
RedSonja wrote: In legacy code I inherit this is so often the cause of errors.
If that is really the case then it's because the programmer (original or the one who performs changes) is clueless and no coding standard will help it.
|
|
|
|
|
Awfully sweet of you to put it like that.
I do this for a living, it's not a hobby, so when I am modifying someone else's code we are in a hurry, the project leader is hovering and there is a progress meeting at 12 noon. If they didn't bother to code tidily it takes longer. If my version of VS tabs and indents differently from whatever they used then it is not clear what they were thinking. If they used braces is it clear at once.
Sometimes you can see from the tabs and comments what they intended but they forgot the braces and it is wrong. This is a common mistake made by our students.
------------------<;,><-------------------
|
|
|
|
|
That is, I always use begin/end.
That was not there, so i selected third by mistake.
Avinash S. Godse
|
|
|
|
|
I don't know if the question was edited but it says this at the end:
Replace {}'s with Begin/End or whatever is appropriate for your language du jour
|
|
|
|
|
For if only, while only and so on, I never wrap single line.
But, for else, if it comes after a braced if, I wrap it also.
So:
if (x)
DoSomething();
else
DoOtherSomething();
but
if (x)
{
DoSomething1();
DoSomething2();
}
else
{
DoSomething3();
}
|
|
|
|
|
for if only, while only and so on ...
... but, for else, if it comes after a braced if ...
What?
|
|
|
|
|
Look at the example... I think you will understand.
|
|
|
|
|
Agree with you, I use them when it makes the code more readable... sometimes they add clutter when used and not needed though...
|
|
|
|
|
I use
if(statement){
...
}
Like real programmers.
|
|
|
|
|
Ennis Ray Lynch, Jr. wrote: Like real programmers.
Then I must be an imposter.
--
** You don't hire a handyman to build a house, you hire a carpenter.
** Jack of all trades and master of none.
|
|
|
|
|
You're either wrapping or you're not. The question doesn't ask about formatting.
cheers,
Chris Maunder
The Code Project | Co-founder
Microsoft C++ MVP
|
|
|
|