Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VB.Net coding guidelines [closed]

We develop small applications for various customers. I now got a task to set up some coding guidelines for in-house and external programmers.

(Management know nothing about development and only see the problem in transferring projects from one developer to another. Customers pay by the hour and development is a small part of total project so code quality is a non-issue)

My first step is to set up guidelines for C# and VB.Net (SQL will probably come later).

(Most code here is created with CTRL-CCTRL-V and testing is done with F5.
I have tried to introduce unit testing / code review but that is not going to happen. Static analysis is the only way forward at the moment)

I am most comfortable in C#/C++ (but sometimes work with existing VB6/VBA/VB.Net code) so setting up C# guidelines is pretty easy:

  • Warning Level 4
  • StyleCop
  • FxCop
  • Code metrics (e.g. Cyclomatic complexity < 15, Maintainability > 50)

For VB.Net I need to replace StyleCop with some written guidelines but how do I set up the VB.Net compiler. Personally I never code without Option Explicit / Option Strict etc but if I do that on our VB.Net projects I get hundreds of warnings/errors (implicit conversions, default return type/value etc).

The VB developers does not seem to have a problem working without help from compiler warnings. I do not think their productivity generally differs from C# developers (it is more a personal thing).

I do not want to enforce my own preference for static checking so my questions is:
What warning levels are reasonable/best practice for VB.Net development?

(English is not my first language so I hope this does not sound like I think VB.Net or VB Developers are inferior to C# in any way. I just don't have much experience in VB.Net projects)

like image 590
adrianm Avatar asked Jul 30 '26 05:07

adrianm


1 Answers

VB.net is just equivalent to C#. If somebody has doubts about that he just can have a look to the various C# to VB.Net translators over the Internet. Chosing C# or VB.net is only a question of habits, readability and feeling. Not a technical or performance question.

Starting from this, almost the same guidelines you have stated for C# can be used for VB.net. So setting the same warnign level should be OK... (is there a possibility for VB.net too? I remember you have a set of options the compiler will warn you... )

The problem can be you will not have free tools like StyleCop (but there are commercial ones, like stated in What StyleCop like tools are there for VB.NET ).

You can also consider buying the Ultimate or Premium editions of Visual Studio (they have an integrated static analysis tool).

And YES, enforce use of Option Explicit / Option Strict (at least for new code or the one which s being reviewed!)

like image 119
Andrea Antonangeli Avatar answered Aug 01 '26 15:08

Andrea Antonangeli



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!