Question

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?

Was it helpful?

Solution

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

OTHER TIPS

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top