Joerg Jooss said:
None of the above has ever been a "best" practice, just a practice.
Best practices:
1. Minimize scope. That's why you see (1).
2. Don't use Hungarian notation. That was probably useful before ANSI C
showed up... that's why you see (2).
3. Use properties. If you need to indicate access to implementation details,
use language features such as this or Me.
That's why you see (3).
Exactly. "Best Practices" arise to remedy specific deficencies or prevent
common mistakes in programming. But as languages and frameworks evolve,
they build in solutions for problems which previously had to be solved by
following the Best Practices guidelines. In languages which are not
completely typesafe, it improves readability and reduces the likelyhood of
typesafety violations to decorate variable names with an indication of their
type. Thus the Hungarian notation arose, and later became obsolete with the
advent of better typing in languages.
VB6 was a very different language from VB.NET, and so the "Best Practices"
for VB.NET should also be very different. The Best Practices for VB.NET are
things like:
-Always use a Try/Finally block when accessing disposable objects.
-Don't catch exceptions when you don't have the right context to handle
them, and never "eat" exceptions.
-Avoid the VB compatability libraries and use the regular framework
functionality for new (not converted vb6) code.
-Avoid COM interop where possible.
-Prefer Object Oriented designs over Structured/Procedural designs.
-Always declare For loop variables in the for statement itself (new to
vb.net 1.1)
-Use strongly-typed DataSets or bindable custom business objects for
type-safe data access across all application tiers.
-Never build SQL statements through string concatenation, use parameter
markers and always store the SQL on a single line.
-Use "Imports" to improve readability and reduce typing.
-Always use Option Explicit On, and Option Strict On
-Alway specify Option Compare one way or the other.
-Usually Dim and assign variables on the same line
David