|
I have gone the other way too many times, relying on the indentation...
if (_Framework.DuplexPlatform)
Synchronize.Visibility = Visibility.Visible;
Synchronize.Visibility = Visibility.Collapsed;
This message is manufactured from fully recyclable noughts and ones. To recycle this message, please separate into two tidy piles, and take them to your nearest local recycling centre.
Please note that in some areas noughts are always replaced with zeros by law, and many facilities cannot recycle zeroes - in this case, please bury them in your back garden and water frequently.
|
|
|
|
|
I'm one of those insecure types who always uses braces, unless the if() fits on a single line.
Software Zen: delete this;
|
|
|
|
|
So am I, because I got caught before, back in my early C days...and it took ages to work out what the heck I had done wrong!
Nowadays, about the most I will let myself get away with is:
if (value > maxRange) break; Everything else gets curly brackets
This message is manufactured from fully recyclable noughts and ones. To recycle this message, please separate into two tidy piles, and take them to your nearest local recycling centre.
Please note that in some areas noughts are always replaced with zeros by law, and many facilities cannot recycle zeroes - in this case, please bury them in your back garden and water frequently.
|
|
|
|
|
Do you fully parenthesize too?
I'm lazy, and never want to remember the precedence rules.
Software Zen: delete this;
|
|
|
|
|
Not always: I'm happy with
if (a == 1 && b == 2) But I'd use em for
if (a == 1 && (b == 2 || c == 3)) Or
if ((a == 1 && b == 2) || c == 3) Just to make it obvious what I meant.
This message is manufactured from fully recyclable noughts and ones. To recycle this message, please separate into two tidy piles, and take them to your nearest local recycling centre.
Please note that in some areas noughts are always replaced with zeros by law, and many facilities cannot recycle zeroes - in this case, please bury them in your back garden and water frequently.
|
|
|
|
|
A colleage of mine always does
if ((a == 1) && (b == 2))
while I always do
if (i < (n - 1))
Fortunately regarding other styles we use the same format.
The good thing about pessimism is, that you are always either right or pleasently surprised.
|
|
|
|
|
Fortunately C# cured me of that one - it won't let you write
if (1 && 2) Because that applies a boolean operation to two integers, so there is no confusion possible with
if (a == 1 && b == 2)
But in C and C++, I used to use the brackets as well!
This message is manufactured from fully recyclable noughts and ones. To recycle this message, please separate into two tidy piles, and take them to your nearest local recycling centre.
Please note that in some areas noughts are always replaced with zeros by law, and many facilities cannot recycle zeroes - in this case, please bury them in your back garden and water frequently.
|
|
|
|
|
Me too, but a colleague uses different code formatting and he always auto-formats files so the one-line if-statements turn into 2-line if-statements (with no braces).
|
|
|
|
|
Ditto - also I am becoming a firm believer in white space being good in code as it makes it much easier to read.
“That which can be asserted without evidence, can be dismissed without evidence.”
― Christopher Hitchens
modified 13-Sep-13 8:23am.
|
|
|
|
|
That;s not insecurity - that's being a good developer.
I upvoted you just because its nice to find folk coding the same standards as me
MVVM # - I did it My Way
___________________________________________
Man, you're a god. - walterhevedeich 26/05/2011
.\\axxx
(That's an 'M')
|
|
|
|
|
A colleague of mine is rather fond of not using {} - even over several levels, i.e.
if (...)
if (...)
for (...)
if ()
doSomething();
doSomeOtherthing(); That's why I use the Edit - Advanced - Format Document feature of Visual Studio very often...
|
|
|
|
|
You threw me there for a moment - I use CTRL+K, D (which does the same thing)
This message is manufactured from fully recyclable noughts and ones. To recycle this message, please separate into two tidy piles, and take them to your nearest local recycling centre.
Please note that in some areas noughts are always replaced with zeros by law, and many facilities cannot recycle zeroes - in this case, please bury them in your back garden and water frequently.
|
|
|
|
|
wow, that's... that's horrible
|
|
|
|
|
Seen a couple of those in an older code base Wasn't always a happy debugging experience 
|
|
|
|
|
That's really awful! In our company we altogether made a programming styleguide and {} has to used everytime (and it has to follow the structure and shall not be places on the next line).
I like this styleguide! We have good readable code everywhere now.
|
|
|
|
|
ihoecken wrote: shall not be places on the next line
Philistine! Allman style[^] is the only way to go.
And while we're at it, it's tabs every time. Anyone who uses spaces to indent their code shall be shot.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Richard Deeming wrote: Philistine!
And proud about it!
Richard Deeming wrote: Allman style[^] is the only way to go.
Eh. In my eyes it's ridiculous. Thousand lines between the code that make it unreadable.
Richard Deeming wrote: And while we're at it, it's tabs every time. Anyone who uses spaces to indent their code shall be shot.
Agree!
|
|
|
|
|
Stop! You're both wrong. Allman style and expand tabs to spaces.
Heresy!
In my code base only one type of whitespace is allowed (ya ya I don't consider newlines to be whitespace).
Windows 8 is the resurrected version of Microsoft Bob. The only thing missing is the Fisher-Price logo.
- Harvey
|
|
|
|
|
Mandatory code fix post -
Why you not do inline:
Synchronize.Visibility = _Framework.DuplexPlatform ?
Visibility.Visible : Visibility.Collapsed;
speramus in juniperus
|
|
|
|
|
I posted a summarized fragment.
Software Zen: delete this;
|
|
|
|
|
I agree that a ternary should be used when apropriate, but I prefer a more explicit formatting.
Synchronize.Visibility = _Framework.DuplexPlatform
? Visibility.Visible
: Visibility.Collapsed;
A ternary operetar is used rarely enough to expose it.
Greetings - Jacek
|
|
|
|
|
Not in my code it isn't 
|
|
|
|
|
Now I see: it is a ";" - and nothing else:
if (_Framework.DuplexPlatform) ;
{
Synchronize.Visibility = Visibility.Visible;
}
{
Synchronize.Visibility = Visibility.Collapsed;
}
|
|
|
|
|
Software Zen: delete this;
|
|
|
|
|
What else would be missing?
Keep Clam And Proofread
--
√(-1) 23 ∑ π...
And it was delicious.
|
|
|
|