|
We had snow on Tuesday and Wednesday in Madison, WI. Driving in seeing ice on people's cars was a bit strange. Since it is going to be in the 70's tomorrow and early next week.
All I have to say is that I'm moving back south.
|
|
|
|
|
Now, I am not interested in a VB versus C# debate but.
In my job I only spend about 20% of my time coding. Being from a C# background anything new I would normally do in C# (and yes very occasionally VB), but I also have to maintain old VB code (and heaven forbid, very occasionally VB6).
Normally I spent a month or two in each language (depending on the task at hand) and are happy in any camp. Changing back and forth between languages is relatively straight forward, but lately I noticed it takes me longer to get back into swing of C#.
And the reason..
Well, I think its because I've got myself into bad c# typing habits from using vb. I seem to be wasting so time chasing missing / misplaced { }, forgetting semicolons case sensitivity and ()'s.
Now semicolons, case and () problems are just a "Oh Bugger" moment, but as for missing / misplaced { } 's. They can be time waster.
For all you pro c# developers, Do you have any tips on keeping these damn { } under control?
|
|
|
|
|
I find that after spending a day doing Ruby programming, my soul cries out to at least write a few lines of C# code in the evening. Ah...
But to your question, my fingers are so programmed to type {} whenever I write a method, I can't really help you there. In fact, in Ruby where occasionally one does use {} I get really pissed off at the IDE for auto-completing the closing }. Or ] or ). Hmmm...I bet there's a way to kill that in RubyMine.
Marc
|
|
|
|
|
I main problem I seem to is after a lot of if, Switch or whatever and you end up with a lot of
}
}
}
}
and then trying to figure which } belong with which {
|
|
|
|
|
RossMW wrote: and then trying to figure which } belong with which {
Dang, doesn't the IDE (dimly, I'll grant) light up the matching braces?
[on my high horse] If you have that much nesting, maybe you should break the function apart into smaller calls? [/on my high horse]
Marc
|
|
|
|
|
Yes, very dimly. Makes it hide to find when you have to scroll to see it.
Just have to remember the Left brace, right brace, back arrow, code... dance move...
|
|
|
|
|
You can change the color of the highlighting
clicky[^]
If the brain were so simple we could understand it, we would be so simple we couldn't. — Lyall Watson
|
|
|
|
|
Thanks. Changed it to magenta, so now its easy to spot!
|
|
|
|
|
What was the setting name you changed to do that?
Where there's smoke, there's a Blue Screen of death.
|
|
|
|
|
Tools > Options > Environment > Fonts and Colors > Brace Matching (Rectangle)
Just overlooked it myself first on first try
If the brain were so simple we could understand it, we would be so simple we couldn't. — Lyall Watson
|
|
|
|
|
Thanks for such a quick reply! > from Charlotte, NC, USA
Where there's smoke, there's a Blue Screen of death.
|
|
|
|
|
You can also use this to find the matching "{}"
On the keypad use the Ctrl key on the right side of the keyboard.
Press right Ctrl ] key combination. This will take you to the matching "{}".
|
|
|
|
|
Actually that's a closing brace for your namespace, class, method and if statement. Not much nesting at all, it just looks that way in C#
This is where I'd usually sing some VB praise, but having been away from VB for far too long I'm just not in the mood
|
|
|
|
|
Sander Rossel wrote: Actually that's a closing brace for your namespace, class, method and if statement.
Heh, good point. I usually never pay much attention to those.
Marc
|
|
|
|
|
It's one of the advantages of VB in that the end states what it's the end of. I think that just makes me a bit lazy on the formatting before coding.
|
|
|
|
|
Before they started colour matching the {}, I got into the habit fo placing a comment following the closing brace with an inverted reference to the starting brace procedure name.
The difficult may take time, the impossible a little longer.
|
|
|
|
|
Marc Clifton wrote: Dang, doesn't the IDE (dimly, I'll grant) light up the matching braces? Only when you put the cursor just after the } or just before the {. Not if the cursor is inside the block in question.
If you think 'goto' is evil, try writing an Assembly program without JMP.
|
|
|
|
|
VS is good at matching braces and so is Notepad++. But if you wany to nest things so deeply you ought to put it in a separate class or function.
I may not last forever but the mess I leave behind certainly will.
|
|
|
|
|
FWIW
In VS, set focus to a brace, CTRL_} finds the matching brace.
There are strangers on the Plain, Croaker
|
|
|
|
|
You could always:
}//End of switch logic
}//End of if peter knows jane
}//End of while loop
}//Finally! end of dam program TG Of course then you would have the never put comments in code police on your tail. Also, you'd have to pray your comments are relative to what has really ended. In case you are wondering, TG is the same as in TGIF.
|
|
|
|
|
I love the code completion features in my editors. I use Visual Studio and Sharp Develop. When I type in if and hit tab it stubs in the braces and brackets. For and if/else I use ife tab.
After the closing bracket I put in two slashes and a comment following the block. This way when I run into "dribble" (the stream of closing brackets yo showed) each on of the closing brackets hass a comment identifying what that bracket closes. It's tedious to get into the habit but it helps late at night when you are debugging things line by line and you get distracted by the family in your home office. ("Where the %^#$& did I leave off?")
|
|
|
|
|
Left brace, right brace, back arrow, code...
|
|
|
|
|
Sounds like a dance move, cha cha cha
|
|
|
|
|
That it pretty much is - definitely muscle memory at this stage.
|
|
|
|
|
Is it just me... VS2013 automatically creates the closing bracket whenever I type an opening...?
|
|
|
|