jcoehoorn

Why I like VB.Net over C#

Comments

Re optional parameters, C# has params keyword which act like optional parameters. But whenever I feel the need for optional parameters (very rare nowadays) I always take it as a sign that there is something more fundamentally wrong with my design.

Similarly with the curly braces. If my method is longer than the height of my monitor can display, it's a sign that the method is too long and in need of refactoring.

As for background compiling, ReSharper provides pretty much the same functionality plus lots of refactoring features and keystrokes (when set to use IntelliJ mode). Nowadays, my productivity goes way down if ReSharper is not installed on a machine.
Just one, maybe two well-defined optional parameters on the end of a method are okay. More than that would be a little... odd. It's not something like printf in C, where you could include any number of parameters.

Definitely agree on keeping methods short. Visual Studio will also highlight the starting brace in C# if you click on a closing brace.

One part of my complaint with {} is that at the end of files you tend to have a group of closing braces. These aren't just methods, but the class and namespace as well, and perhaps the end of a loop or else condition. VB makes it easy to see at a glance which is which.

It also lets the compiler enforce what kind of block it finishes, which can catch a certain class of error. Those errors are admittedly uncommon, but we've all misplaced a brace now and then.


Agree with the braces thing if you aren't using ReSharper :) It has VB.NET support in the latest version so it is worth a look. I know it costs money but the amount of time it saves me (and others) is easily justified.
Optional parameters are a bit like GOTO - in my mind they shouldn't really be there... what you're really talking about is overloading.

VB.NET has always seemed a little like .NET dressed up in a more friendly (higher level) set of clothes to appease the masses. Working in industry, I see far more C# churning out of dev houses than VB.

Post a comment

Already a Vox member? Sign in

Advertisement