Conclusion

 <  Day Day Up  >  

Methods are the workhorses of the language, containing most of the executable code of a program. Declare statements allow calling code that is external to the Framework. Now that we have covered executable statements, the next chapter talks about fields, which are variables that can be stored within types, and properties, which are a cross between methods and fields.

Here are some style points to consider.

  • A method declaration with no parameters can choose to omit the parentheses, but they are suggested for emphasis and readability.

  • In previous versions of Visual Basic, parameters were reference parameters by default. The default changed in Visual Basic .NET because the overhead of reference parameters made them less desirable as the default type of parameter.

  • Previous versions of Visual Basic supported optional Variant parameters without default values. Visual Basic .NET no longer supports declaring such parameters, but does still support calling COM methods that have such parameters.

  • Late binding should only be used when absolutely necessary. Deferring type checking until runtime is more prone to errors and limits the ability of Visual Studio to provide Intellisense. Specifying Option Strict at the top of a file disallows late binding within that file.

  • Overloading is preferred over using Object to handle parameters that can accept more than one type, because it allows arguments to be strongly typed. Overloading is also preferred over using optional parameters, because it often is easier to call.

 <  Day Day Up  >  


The Visual Basic .NET Programming Language
The Visual Basic .NET Programming Language
ISBN: 0321169514
EAN: 2147483647
Year: 2004
Pages: 173
Authors: Paul Vick

Similar book on Amazon

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