Things we love about VisualBasicDotNet:
''(...sometimes related to ThingsWeLoveAboutVbClassic.)''
''Not to be confused with ThingsWeHateAboutVisualBasicDotNet.''
----
'''List:'''
* XML Literals, right in the source code.
* SQL-like DLinq (LinqToSql) syntax.
* The '''Overrides''' keyword.
* The '''Shared''' keyword, for "static" Fields and Methods.
* Has optional NamedParameter''''''s that are designed fairly well. I ''loooove'' named parameters.
----
----
'''Discussion:'''
----
* '''XML Literals, right in the source code.'''
You can embed XML literals right into your source code:
Dim xmlVar As XElement = _
Constant text here.
and you can embed expressions to dynamically change element and attribute names and values
Dim xmlVar As XElement = _
><%= "Hello " + nameVar + "." %>
<<%= dynamicElementName %> <%= dynamicAttributeName %>="static attribute value"/>
and VisualBasic automatically does all the appropriate quoting, giving one a high level of protection against SqlInjection attacks.
----
----
* '''SQL-like DLinq (LinqToSql) syntax.'''
Query syntax in DLinq (LinqToSql) is much more like the StructuredQueryLanguage (SQL) syntax we're accustomed to, rather than the "collections library" style syntax in C#.
In VisualBasicDotNet, one might do a DLinq query like this:
SELECT p2.ProductName, p1.UnitPrice
FROM dbo.ProductsCostingMoreThan(80.50)
AS p1 INNER JOIN Products AS p2 ON p1.ProductID = p2.ProductID
Where in the CsharpLanguage (C#), it would look more like this:
var q =
from p in db.ProductsCostingMoreThan(80.50m)
join s in db.Products on p.ProductID equals s.ProductID
select new {p.ProductID, s.UnitPrice};
The VB.NET syntax is much more like the RelationalDatabase's SQL syntax than the C# version.
The C# version has all the same clauses, but they're in some other order that's "more natural" for a collections library.
Related: LanguageIntegratedQueryProject
----
----
* '''The Overrides keyword.'''
For a VisualBasic subclass to override a superclass method, you '''must''' use the '''Overrides''' keyword:
If the method signatures match and you don't have the '''Overrides''' keyword, it's a compile error.
The Java 5 '''@Override''' annotation is nice, but when it's missing, the program might or might not still be overriding a superclass method, and the original programmer might or might not have been intending to override a superclass method; it can be hard to be sure.
But with VisualBasic the intention and implementation are always clear: You see the '''Overrides''' keyword IfAndOnlyIf this method overrides a superclass method.
----
----
* '''The Shared keyword, for "static" Fields and Methods.'''
The '''Shared''' keyword more clearly expresses that fields and methods are '''Shared''' across all instances of a class -- making its usage much less error-prone than the C/C++/C#/Java overloading of the '''static''' keyword for this purpose, particularly for relatively less experienced developers.
----
CategoryVisualBasic CategoryDotNet