3

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)

adrianm
  • 14,468
  • 5
  • 55
  • 102
  • 1
    http://addressof.com/blog/articles/CodingGuidelines.aspx – S2S2 Jun 15 '12 at 08:50
  • @CSharpVJ +1 for linking to coding guidelines which (it says) have had contributions from Paul Vick and Brad Abrams! But they date from 2005. – MarkJ Jun 15 '12 at 15:59

1 Answers1

3

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!)

Community
  • 1
  • 1
Andrea Antonangeli
  • 1,242
  • 1
  • 21
  • 32
  • 4
    Would the downvoter please write a brief comment on why he/she downvoted? I'd really like to know if the answer is actually flawed or misleading. Or does the downvoter just generally dislike people stating that VB.Net is not a bad thing? – Dennis Traub Jun 15 '12 at 08:51
  • 1
    LOL, yes, I'm interested too in the reason for downvote... I hope it is not for religious issues :-) – Andrea Antonangeli Jun 15 '12 at 08:54
  • 1
    +1 Minor quibbles. Vb.Net is 95% equivalent to C#, but [not *exactly* equivalent](http://stackoverflow.com/questions/966457/what-is-allowed-in-visual-basic-thats-prohibited-in-c-sharp-or-vice-versa). – MarkJ Jun 15 '12 at 13:00
  • And the C# to VB.Net translators [all](http://stackoverflow.com/questions/7148997/problem-with-vb-to-c-sharp-converter) [seem](http://stackoverflow.com/questions/7212767/can-someone-help-me-convert-this-to-vb) to [fail](http://stackoverflow.com/questions/7201587/converting-inerface-with-delegate-from-vb-to-c-sharp) under [some](http://stackoverflow.com/questions/5566702/c-sharp-to-vb-class-event-sender-args-functionnameparams) [circumstances](http://stackoverflow.com/questions/5279477/i-need-help-converting-a-c-sharp-anonymous-method-to-vb-net). I'm thinking of starting a tag :) – MarkJ Jun 15 '12 at 13:01