Variable Naming

In the past, Microsoft favored a variation of Hungarian notation when naming variables. That meant, for example, that a Visual Basic integer variable would start with the prefix int (as in intCount). But in the world of .NET, where memory management is handled automatically, data types can change without any serious consequences and the majority of variables are storing references to full-fledged objects. Hungarian notation is starting to show its age.

The new Microsoft standard is to avoid variable prefixes, especially for properties and methods visible to other classes. This style is similar to the standard used for COM components and controls, and it makes a great deal of sense for code transparency. Data types no longer pose the problems they once did, because Visual Studio .NET will spot invalid conversions and refuse to compile.

In this book, data type prefixes are not used for variables. The only significant exception is with control variables, for which it is still a useful trick to distinguish between different types of controls (such as txtUserName and lstUserCountry) and with some data objects. Of course, when you create your own programs, you are free to follow whatever variable naming convention you prefer, provided you make the effort to adopt a complete consistency across all your projects (and ideally across all the projects in your organization).



Microsoft. NET Distributed Applications(c) Integrating XML Web Services and. NET Remoting
MicrosoftВ® .NET Distributed Applications: Integrating XML Web Services and .NET Remoting (Pro-Developer)
ISBN: 0735619336
EAN: 2147483647
Year: 2005
Pages: 174

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net