|
True but I lke to see Return(); at the end of a function. Just makes it easier to read.
I may not last forever but the mess I leave behind certainly will.
|
|
|
|
|
The keyboard shortcut "control }" will jump to the matching bracket if you can't immediately identify it. It will work when the cursor is either before or after an opening bracket or a closing bracket. I'd use that command every 5 minutes. very helpful when the scope of a set of brackets extends beyond the visible portion of the page.
who knows what evil lurks in the hearts of men?
|
|
|
|
|
Never knew that one. I'll have to give it a go.
|
|
|
|
|
|
I code in VB and C# at work - my preference is for C~ due to what I describe as its 'elegance'.
Occasionally when I swap over I catch myself adding a semicolon to some VB code however Visual Studio catches it and I soon remember that I am coding on VB.
I don't find it too big a deal - being bilingual(English and French), for me it's a similar experience swapping between two programming languages and two spoken languages.
Sometimes when I see some horrendous VB code I am heard to exclaim "Put*in de b*rdel de m*rde!" when I meant to comment in English
“That which can be asserted without evidence, can be dismissed without evidence.”
― Christopher Hitchens
|
|
|
|
|
As others have said, I close braces on opening them (well, I cheat and let ReSharper do that), and I keep the number of braced scopes in a method to a minimum, e.g. avoid nested braces like the plague. The highest level I normally get to is say for one loop or switch at a time.
No object is so beautiful that, under certain conditions, it will not look ugly. - Oscar Wilde
|
|
|
|
|
I stick to languages derived from c. Currently mostly c, java and perl.
I have no problems switch between these.
Pitch to one of your managers to have the code you're maintaining rewritten in C#... Or rewrite it in C# and tell your boss what you've did and if they'd be interested in changing over to it. To my knowledge there should be no reason to write any code in vb... If we employ people, it is never a requirement to only know vb or only know C#... Its usually in the lines of, do you have vb or C# experience. As the task at hand can usually be performed in either.
According to Wikipedia there are 89 different c derivative languages. C obviously had a winning recipe. Your subject should read 'Damn vb (why do they have to think they are special and different)'.
"Program testing can be used to show the presence of bugs, but never to show their absence."
<< please vote!! >></div>
|
|
|
|
|
Maintain codebase in vb.
There is nothing different between the two...except may be for productivity features enabled through use of the ide.
There are probably other ide that give better productivity support.
Try sharp develop for a change : [^]
|
|
|
|
|
- I usually mark them with a comment (end if, end for, ...), some find it childish, but I found it often helpful
- setup VS to clearly show matching braces
- ALWAYS use the {} even if there is only one statement.
Most common error for me if someone else wrote something like (cause I never, ever do that):
if [statement a]
else if [statement b]
else if [statement c]
else if [statement d]
else if [statement e]
else if [statement f]
else [statement g]
and you need to insert an additional statement in between somewhere.
hope this helps.
|
|
|
|
|
Never thought of the obvious of commenting the end brace. Doh
I have setup the ide to have a brighter highlight but I notice it sometimes does work. Generally if there is some other minor error..
|
|
|
|
|
I have a habit of typing } followed by back key as soon as I type {. This keeps things under control as the chances to forget typing } are none. I would also suggest to try outlining for visual studio. Try this[^]. Using this you will be able to work in the current block while collapsing the other code blocks. Another thing I would like to suggest is the use of ctrl+K+D(for code formatting), Ctrl+M+O and Ctrl+M+P to toggle outlining. I find these combinations very handy while coding.
|
|
|
|
|
The tool looks good. Going to give it a go when I can. Thanks
|
|
|
|
|
You're welcome
|
|
|
|
|
RossMW wrote: They can be time waster.
They have never been a time waster for me. I have never given it a second thought.
Because you don't do this much, you will notice "everything", I would guess.
|
|
|
|
|
I am constantly formatting the document. In VS it is Ctrl+E, D. This keeps the braces matched up.
Eric
|
|
|
|
|
|
What I have been known to do:
void SomeLongFunction {
// many lines of code
} // end void SomeLongFunction
|
|
|
|
|
No just use Resharper it does it for you.
|
|
|
|
|
In VS you can just use ctrl+'}' on one of the braces to toggle to what VS thinks is the match. This can be done for any open and close types, html tag or ( ) etc. VS2013 will add both for you by default as you type.
|
|
|
|
|
RossMW wrote: Do you have any tips on keeping these damn { } under control?
Yes, it's called ReSharper[^]
I've been using it since 2009 and I have no idea how to use Visual Studio anymore without it.
I have always wished for my computer to be as easy to use as my telephone; my wish has come true because I can no longer figure out how to use my telephone - Bjarne Stroustrup
The world is going to laugh at you anyway, might as well crack the 1st joke!
My code has no bugs, it runs exactly as it was written.
|
|
|
|
|
Find matching brace (most code editors have one) -- Visual Studio: ctrl-], Vi: %
Use a smart editor that automatically adds, shows or otherwise assists in making sure you have balanced brackets.
Consistent indentation.
It also helps not to have large blocks of code, but sometimes that just can't be avoided.
It is a pain sometimes, but I've just learned to live with it since the previous alternatives were much, much worse.
We can program with only 1's, but if all you've got are zeros, you've got nothing.
|
|
|
|
|
How long is on average one of your methods?
A method shouldn't be longer than a screen, which makes around 50 lines of code.
This will solve your braces problem immediately.
modified 20-Oct-19 21:02pm.
|
|
|
|
|
I don't know about anyone else, but when I enter a '{', I also enter the corresponding '}' before I insert any code in between the braces. I never have a problem with unbalanced/misplaced braces.
Fletcher Glenn
|
|
|
|
|
Obviously, you are using the god-forsaken "K&R" bracing style
if (condition) {
}
When you choose a coding style based on readability rather than historic fanboy popularity, these problems go away:
if (condition)
{
}
Truth,
James
|
|
|
|
|
When there's too much nesting, and therefore too many braces, consider
1) refactor out inner nestings into new methods
2) label }'s:
namespace foo
{
public class bar
{
public void fu()
{
for(var int i = 0; i < 10; i++)
{
if(Math.PI != 0.0)
{
} // if PI not 0
} // for i
} // fu
} // bar
} // foo
|
|
|
|