0

My instructor states that variable & object naming conventions have been changed for vb.net. From using a shortened prefix as a variable name such as btnFoo or intFoo(as it has been ever since I can remember) to the more lengthy, verbose & "CamelCase" postfix version of FooButton or FooInteger.

I have been looking through the .Net reference pages & forums, and can't seem to find any evidence on a change in convention. Is anyone aware of a change?

zkdr
  • 83
  • 11

2 Answers2

3

Early Visual Basic naming recommendations were based on "System Hungarian". Microsoft even published a list of recommended prefixes, quite remarkable in that the name of the component vendor was even included in the prefix. Like "cbos", the custom ComboBox control published by Sheridan, as opposed to "cbop", published by Pioneer.

System Hungarian has always been rather controversial, with a rich history of failing miserably at keeping up with changes. The naming conventions in the winapi are a good example. Clearly the scheme where the tool vendor name is included has no hope of ever scaling into the future, Visual Basic launched an ecosystem with hundreds of control vendors. A convention that has no hope of ever being used consistently is not a useful convention.

So yes, this was entirely dropped in .NET. CamelCase is used very consistently in the tens of thousands of identifier names in the framework, it has been extraordinarily effective. The rules are spelled out well in the naming guidelines.

Do keep in mind that this is just a guide, you are certainly not required to follow them. The conventions used inside your team always trump whatever a software vendor thinks is useful. It is not like they have a good track record of getting it right :)

Community
  • 1
  • 1
Hans Passant
  • 922,412
  • 146
  • 1,693
  • 2,536
1

These were in the Framework Design Guidelines: Conventions, Idioms, and Patterns for Reusable .NET Libraries book, first published in 2005 - there are relevant excerpts on MSDN. These set to deprecate Hungarian notation, as that had got misused over the years for exposed names in .Net frameworks.

Rowland Shaw
  • 37,700
  • 14
  • 97
  • 166
  • Thank you, this helps tremendously. – zkdr Mar 14 '14 at 10:17
  • I would highly recommend reading the book (or the later edition) if you plan to write a lot of libraries that are used by your customers. Of course, they are only guidelines, but they will lead to code that is as easy to read and maintain as the .Net Framework itself. – Rowland Shaw Mar 14 '14 at 10:27