Directives

5.1 Define focused variables.

When you create and use variables, you should strive to make each variable serve a clearly defined purpose. It can be tempting to make variables serve double duty, but the small savings in memory is often negated by the resulting complexity of the code. A variable used for multiple purposes is said to be unfocused. If you need to perform unrelated actions or calculations on a variable, you’d be better served by having two focused variables rather than one unfocused variable. It’s unnecessarily difficult to read and debug code that contains unfocused variables, and the code itself is more likely to contain errors.

Example. Incorrect:
   Public Function IsEmailAddressValid(ByVal strEMailAddress As String ...

Get Practical Standards for Microsoft® Visual Basic® .NET, Second Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.