Newsgroup: it.comp.lang.visual-basic
Titolo: [!] Visual Basic Next Generation [LUNGHISSIMO]

Tratto da: 
http://msdn.microsoft.com/vstudio/nextgen/language.asp
--
Ciaps
Stracca
---------------------------------------------
    Le risposte alle tue domande le trovi
    sul Sito Comune di questo NewsGroup:
 
http://www.murialdo.it/it_lang_vb
       ... e nell'help in linea !
---------------------------------------------
Visual Studio Enables the Programmable Web
Language Innovations
Introduction
To rapidly build enterprise Web applications, developers must rely on
business logic that is scalable, robust, and reusable. Over the past several
years, object oriented programming has emerged as the primary methodology
for building systems that meet these requirements. Using object oriented
programming languages helps make large-scale systems easier to understand,
simpler to debug, and faster to update.
While Visual Basic® has set the standard for rapid development of Windows
applications, the lack of object-oriented language features has limited its
acceptance for creating middle-tier components. To address this issue, the
next generation of Visual Basic will add object-oriented language features
to simplify the development of enterprise Web applications. With these new
language features, Visual Basic will deliver all the power of C++ or Java
while maintaining the instant accessibility that has made it the world's
most popular development tool.
This next generation of Visual Basic will provide a first class object
oriented programming language with new features such as inheritance,
encapsulation, and polymorphism. Additionally, developers will be able to
create highly scalable code with explicit free threading and highly
maintainable code with the addition of modernized language constructs like
structured exception handling. Visual Basic will provide all the language
characteristics that developers need to create robust, scalable distributed
Web applications with the following new features:
New object oriented programming features
Inheritance
Encapsulation
Overloading
Polymorphism
Parameterized Constructors
Additional modernized language features
Free Threading
Structured Exception Handling
Type Safety
Shared Members
Initializers
A History of Language Innovation
The Visual Basic language has a long history of updates that map to
fundamental changes in the Windows® platform. For example, the significant
changes made to QuickBasic® to support Windows 3.0 GUI development resulted
in the first release of Visual Basic. In Visual Basic 4.0, the shift to
COM-based programming resulted in language constructs for creating DLLs. And
in Visual Basic 5.0, the language evolved to support the creation of COM
controls.
With each successive revision, the popularity of Visual Basic has soared.
The power that the new Visual Basic object-oriented language features
provide developers building enterprise Web applications will most certainly
continue this trend.
----------------------------------------------------------------------------
----
Object oriented programming
There are several weaknesses with traditional structured programming where
data is stored separately from procedural code. Any code that is written as
structured code is not modular. Because data elements are accessible from
any code, it is possible for data to be modified without the developer's
knowledge. This can result in runtime errors that are very difficult to
debug. Additionally, maintenance becomes very tricky. Trying to understand
the global impact of changing a line of code with structured programming can
be very difficult. Finally, this reliance on having the programmer manage
both code and data results in much lower rates of reuse.
Object oriented Programming (OOP) solves these problems. It packages data,
and the methods that act on that data, into a single unit called an object.
An object's data can be hidden to prevent unauthorized modification. The
object surfaces a set of public methods to operate on this data. This
concept is called encapsulation. Because implementation details are
separated from the interface, the underlying programming logic can be
changed at a later date without fear of breaking code that calls the object.
OOP allows developers to reuse code and data together through inheritance.
By inheriting from predefined objects, developers can more rapidly construct
complex applications. Since writing new code always has the potential for
incorporating bugs, reusing tested code minimizes the chances of additional
bugs.
In order to address these needs, the next generation of Visual Basic will
provide additional language features that will make it a first class Object
Oriented Programming language with all the benefits described above.
Inheritance
Consistently the number one most requested feature for Visual Basic is
support for implementation inheritance. Developing in Internet time requires
rapid assembly and massive reuse. To facilitate implementation inheritance,
Visual Basic will add the Inherits keyword to the language.
Developers can use the new keyword Inherits or the class property sheet's
Inherits property to derive from an existing class.
Class1
 Function GetCustomer()
 ...
 End Function
Class2
 Inherits Class1
 Function GetOrders()
 ...
 End Function
The Inherits statement supports all the usual properties associated with
inheritance.
Instances of the derived class support all methods and interfaces supported
by the base class
The derived class can override methods defined in the base class using the
Overrides keyword
The derived class can extend the set of methods and interfaces supported by
the base class
Encapsulation
Encapsulation means that developers can contain and hide information about
an object, such as internal data structures and code. It isolates the
internal complexity of an object's operation from the rest of the
application.
For example, when you set the Caption property on a command button, you
don't need to know how the string is stored. Visual Basic will help you do
this by letting you declare properties and methods as private protected or
public.
Why would you want to protect class members? Let's assume that certain
properties of a class represented an object's state. If you couldn't prevent
those properties from being accessed directly from outside the class, how
could you ever guarantee the state of that object? If you protect the
property, you could then create a custom method that would be used to assign
values to that property. The method could contain validation code to ensure
that the value is set properly. Since the property value is assigned in just
one place, the code becomes much easier to debug and maintain. In the
example below, "me" refers to a specific instance of a class.
 Protected cName as string
 Protected Function ChangeName(NewName)
  Me.cName = NewName
 End Function
Overloading
Overloading is a feature that will allow an object's methods and operators
to have different meanings depending on its context. Operators can behave
differently depending on the data type, or class, of the operands. For
example, x+y can mean different things depending on whether x and y are
integers or structures. Overloading is especially useful when your object
model dictates that you employ similar names for procedures that operate on
different data types. For example, a class that can display several
different data types could have display procedures that look like this:
Overloads Sub Display (theChar As Char)
...
Overloads Sub Display (theInteger As Integer)
...
Overloads Sub Display (theDouble As Double)
Without overloading, you'd have to create distinct names for each procedure
even though they do the same thing:
Sub DisplayChar (theChar As Char)
...
Sub DisplayInt (theInteger As Integer)
...
Sub DisplayDouble (theDouble As Double)
Polymorphism
Polymorphism refers to the ability to process objects differently depending
on their data type or class. Additionally it provides the ability to
redefine methods for derived classes. For example, given a base class of
Employee, polymorphism enables the programmer to define different
PayEmployee methods for any number of derived classes, such as Hourly or
Salaried or Commissioned. No matter what type of Employee an object is,
applying the PayEmployee method to it will return the correct results.
Class Employee
 Function PayEmployee()
   PayEmployee = Hours * HourlyRate
 End Function
Class CommissionedEmployee
 Inherits Employee
 Overrides Function PayEmployee()
  PayEmployee = BasePay + Commissions
 End Function
Parameterized Constructors
Parameterized constructors (or more simply "constructors") allow you to
create a new instance of a class while simultaneously passing arguments to
the new instance. Constructors are essential for object oriented programming
since they allow user-defined construction code to be passed parameters by
the creator of the instance. They simplify client code by allowing a new
object instance to be created and initialized in a single expression.
----------------------------------------------------------------------------
----
Additional Modernized Language Features
The next generation of Visual Basic adds a number of additional constructs
that simplify the development of more robust, scalable applications. These
features include providing type safety in the language, productivity
features like initializers, as well as function pointers. The language has
been extended to make the Visual Basic language a comprehensive one.
Free Threading
Today when developers create applications in Visual Basic, the code that
they write is synchronous. That means that each line of code must be
executed before the next one. When developing Web applications, scalability
is key. Developers need tools that enable concurrent processing.
With the inclusion of free threading, developers can spawn a thread, which
can perform some long-running task, execute a complex query, or run a
complex calculation while the rest of the application continues, providing
asynchronous processing.
Sub CreateMyThread()
 Dim b As BackGroundWork
 Dim t As Thread
 Set b = New BackGroundWork()
 Set t = New Thread(New ThreadStart(AddressOf  b.Doit))
 t.Start
End Sub
Class BackGroundWork
 Sub DoIt()
 .
 End Sub
End Class
Structured Exception Handling
Developing enterprise applications requires the construction of reusable,
maintainable components. One challenging aspect of the Basic language in
past versions of Visual Basic was its support for error handling. In the
past, developers had to provide error-handling code in every function and
subroutine. Developers have found that a consistent error-handling scheme
means a great deal of duplicated code. Error handling using the existing On
Error GoTo statement sometimes slows the development and maintenance of
large applications. Its very name reflects some of these problems: As the
GoTo implies, when an error occurs, control is transferred to a labeled
location inside the subroutine. Once the error code runs it must often be
diverted via another cleanup location via a standard GoTo, which finally
uses yet another GoTo or an Exit out of the procedure. Handling several
different errors with various combinations of Resume and Next quickly
produces illegible code and it leads to frequent bugs when execution paths
aren't completely thought out.
With Try...Catch...Finally, these problems go away, developers can nest
their exception handling, and there is a control structure for writing
cleanup code that executes in both normal and exception conditions.
Sub SEH()
 Try
    Open "TESTFILE" For Output As #1
  Write #1, CustomerInformation
 Catch
     Kill "TESTFILE"
 Finally
  Close #1
 End try
End Sub
Type Safety
Today the Visual Basic language is very liberal in the implicit type
coercions that it will generate. For assignment and for parameter passing
other than by reference, the Visual Basic compiler will allow nearly any
data type to be converted to any other type by generating runtime coercion.
The runtime coercion operation will fail if the value that is to be
converted cannot be converted without data loss. Through the addition of a
new compilation option, Visual Basic can generate compile-time errors for
any conversions that may cause an error at runtime. Option Strict improves
type safety by generating errors when a conversion is required which could
fail at runtime or which, like the automatic conversion between numeric
types and strings, is unexpected by the user.
Shared Members
Shared members are data and function members of classes that are shared by
all instances of the class. Sharing a single instance of a data member or
function among all instances of a class is required in a Visual Basic
application with inheritance. A shared data member is one that all instances
of a class share. A shared data member exists independently of any
particular instance of the class. A shared method is a method, which unlike
normal methods, is not implicitly passed an instance of the class. For this
reason no unqualified references to non-shared data members is allowed in a
shared method. Public shared members can be accessed remotely and they can
be late-bound from an instance of the class.
Initializers
The next version of Visual Basic will support initialization of variables on
the line in which they are declared. Initializers can be used anywhere
including inside a control structure. The semantics of a procedure level
declaration, which includes an initalizer, is the same as a declaration
statement immediately followed by an assignment statement. In other words,
this statement:
Dim X As Integer = 1
is equivalent to these statements:
Dim X As Integer
X = 1
Conclusion
In the next generation of Visual Studio®, Visual Basic will provide a first
class object oriented programming language with inheritance, encapsulation,
and polymorphism. Additionally, developers will be able to create highly
scalable code with explicit free threading. The code they write will be
highly maintainable with the addition of modernized language constructs like
structured exception handling. Visual Basic will provide all the language
characteristics that developers need to create robust, scalable distributed
Web applications.
Last Updated: 2/22/00
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.

© 2000 Microsoft Corporation. All rights reserved. Terms of Use.
Ah, è anche y2k compliant!
Iniziamo bene... Spero NON sarà un'applicazione compatibile (nel senso che
deve essere compatita)...
Ciao

Parameterized Constructors
Alla faccia dei Javisti!
Grande Bill. Grande VB.
Fabio Pagano.