The future of VisualBasic
WebForms (Web forms), Web services (Web services) and language improvements that will appear in a version
The readers of this article are users who are already familiar with Visual Basic.
Overview: The next version of Microsoft Visual Basic has three main improvements: improvements in WebForms, Webservices and object-oriented syntax. WebForms enables experienced Visual Basic users to develop network applications as easily as they do today's stand-alone programs. Through the SOAP interface, Webservices let you deploy the components you design anywhere you have access to the Internet. In addition, several key improvements in object-oriented languages make Visual Basic code as flexible as C, including inheritance, polymorphism, and overloading. For information on this aspect, please refer to Steve Ballmer's "VBITSkeynoteonthenextgenerationofVisualBasic"
isualBasic has gone through many improvements. But one thing I've loved about it since its inception is that, at its core, you can still write your programs the same as it was in 1991. Of course, its software package has been greatly enhanced compared to that time, but these improvements are generally supplementary and do not obscure the purpose of being a programming tool itself. This purpose is: to make Visual Basic easier and faster Used to design, write and debug outstanding object-oriented applications.
The current version of Visual Basic 6.0 introduces WebClasses as a simplified means for configuring robust network-oriented applications. In fact, WebClasses provide a large number of ways to port programs to the Internet through common tools. (For a detailed discussion of the scalability of Visual Basic 6.0 under the network, see Ted Pattison's "Advanced Basics Column" (published by Microsoft Internet Developer in October 1999)
I recently had the opportunity to learn about some of the new improvements planned for the next version of Visual Basic. The main improvement is in storage capacity, which has tripled the storage capacity available to developers. The next version of Visual Basic is planned to feature a feature called WebForms in the Visual Studio® environment. WebForms represents a new component-based network solution. Webservices will become a new XML-based solution that publishes middle-tier event processing functions through standard network protocols. At the same time, the Visual Basic language will include some constructs that developers have long requested, making Visual Basic consistent with the object-oriented programming habits familiar to C and Java users.
These improvements will be announced in the next beta version of Visual Basic. Here I will give some code snippets, but not the complete solution. So what is there to worry about now? It's simple, as long as you are determined to take advantage of these new features, you can now design your programs through these specific methods and get the best practical exercises to help you smoothly transition to the next version of Visual Basic. Even if you don't, you have nothing to lose as long as you organize your future programs according to the principles I lay out at the end of this article.
VisualStudioWebForms
The next version of Visual Basic will be part of the Visual Studio development environment and is likely to introduce the new concept of WebForm to web developers. The purpose of introducing the WebForm concept is to expand the random access function of Visual Basic so that Visual Basic can be applied to the writing of network programs that have an increasingly wide impact. Developers using any language in Visual Studio can share this Visual Studio WebForms.
A WebForms page consists of two parts: an HTML file that implements the visual interface of the WebForms page and a source file that handles WebForms page events. Since one-third of current development based on the Visual Basic environment is network-oriented, Microsoft plans to further enhance capabilities in this area. In the next version of Visual Basic, you can design WebForms the same way you use Visual Basic to generate forms today. You will have a toolbox of web controls. You can drag and drop controls directly into the HTML editor to use them. You just need to set their properties and write some appropriate code. (See Figure 1). In summary, you can do these tasks just like you would use Visual Basic to generate forms. You'll have form designs and compiled code that are fully compliant with IntelliSense®, WYSIWYG format. So as long as you know how to write applications using Visual Basic, WebForms allows you to become a web developer without changing the way you work at all.
Figure1BuildingaWebForminFourSteps
WebForms runs on the server and only transmits forms in HTML format to users. Just like ActiveServerPage(asp), it is neither a specific browser nor a WebForm-based application; but the entire process also runs on the server. In fact, you are running a program that generates an interface in HTML 3.2 format for remote users. Unlike ASP web pages, these codes are compiled and run instead of interpreted, so the running speed is significantly improved.
The purpose of designing WebForms is to get the best features of both ASP and WebClass. You can use any language in the Visual Studio family to generate WebForms. So, you can use what you know to write efficient, server-oriented web applications.
Webservices
Webservices is the second major improvement taken by the Visual Studio development tool system. At its core, a Webservice is a middle-tier event handler published through a standard network protocol. Since they use HTTP as the transport mechanism (see Figure 2), they can communicate through firewalls. You can simply construct multiple Webservices in a web application as long as the URLs are assigned appropriately. When the program is running, calls between all these internal components are automatically packaged and called through the XML interface. Developers can write and use Webservices on any platform and in any language. If you need confidentiality, you can use SecureSocketLayer (SSL) or standard checking technology.
Figure2WebservicesArchitecture
If any of this is starting to sound familiar to you, that’s a good place to start. The mechanism used to transfer data between components is SOAP, the Simple Object License Protocol. DonBox introduced SOAP in detail in the MSDN™ Magazine published in March 2000.
All of these new features are designed to allow web application developers to compose existing, reusable Web services so that they can write their applications faster without having to write them from scratch each time. This will usher in a new era of program code providers and program developers.
Using the next version of Visual Basic, you will soon be able to publish and implement the functions in a specific project in the form of Webservice. You may be familiar with the process of making a Visual Basic class public. There will be a new logo in the next version of Visual Basic, temporarily called webpublic. This means that the program will be published as a Webservice. It can not only be used by local projects that need it through the COM interface, but also can serve any network program that references its URL address. Just as you can add a reference to a public object in a new project, you can add a reference to a network program and use it as if it were a local program.
Of course, the operating mechanism is somewhat different. Visual Basic can resolve references to local objects through the COM interface. When you add a reference to a network service to your application, the remote object will automatically generate the interface definition and send it to the Visual Studio development environment using the SOAP protocol. Although these will be generated in XML form, you don't have to do any connection work yourself. VisualBasic will handle it automatically for you. After receiving the interface definition, you can use IntelliSense as if you had written code that referenced the object.
Here's a simple example. In some cases, you may want to write this function called Seahawks, which may look something like the following code:
PublicFunctionSeahawks(ByValopponentAsString)AsString
Seahawks="lose"
EndFunction
If the project you construct includes this function, Visual Basic will automatically generate an XML format description of this function and publish it to the Internet.
<?xmlversion='1.0'?>
<methodshref='http://julian/Football/Teams'>
<methodname='Seahawks'href='Seahawks'>
<request>
<paramdt='string'>opponent</param>
</request>
<responsedt='string'/>
</method>
</methods>
This XML file will be used to describe Seahawks functions. If you are using the Visual Studio development environment, you can drag and drop any published Webservice directly into the application to create a new class. If you want to call a Webservice anywhere on the Internet, you only need to create an instance of the class containing the Webservice and then call its published methods.
When the Seahawks function is called, it automatically communicates via XML packets. If you are using Microsoft® Internet Explorer 5.0 (which includes XML support), you can try running this function in your browser. You can also call this function using the URL address as follows:
http://julian/webservice1/component1.methods/Seahawks?opponent=Miami
It will return data in XML format as follows:
<?xmlversion="1.0"?>
<Response>lose</Response>
In order to facilitate the development of Webservices, Visual Basic will introduce a new object type, WebService. You can design and deploy your WebService to a remote service as simply as creating a local DLL file now.
Language improvements
There has long been a tense relationship between programmers who prefer Visual Basic and programmers who prefer other, more "sophisticated" languages. More than once, I have defended my favorite programming language against accusations that it is a "toy language" and that Visual Basic lacks OOP features.
Okay, so guess what happened? The next version of Visual Basic will finally put an end to their complaints. Microsoft plans to add three major features of object-oriented programming: inheritance, polymorphism and overloading. That's not all! Additional constructs, including structured error handling and browsing, will also be introduced into the Visual Basic language.
The inheritance feature allows you to design a base class and then write some derived classes that inherit the functions of the base class. This can save time and improve the reusability of the program. For example, you write a base class called BaseClass that has a function:
FunctionGetCustomerName()
'Dosomestuff
EndFunction
Now you want to write another class that can call the base class's GetCustomerName function just like its own function. What was the old method? This was not possible in the past. However, the new method now only requires inserting a simple line above the new class:
InheritsBaseClass
FunctionGetCustomerID()
'Dosomestuff
EndFunction
Writing two or more functions with the same name but different identifiers is called overloading. To some extent, Visual Basic has implemented overloading in the conversion of internal types and the setting of properties when calling functions. Compare the following two lines of valid Visual Basic code:
Text1.Text="7"
Text1.Text=7
In both calls, the text in Text1 will be set to the string "7". This is an overloaded call because Visual Basic knows how to handle the different data types of the input. It treats them as variables and converts them automatically. When you call some functions with clearly defined parameter types, Visual Basic will also perform the same conversion. The following two function calls:
a=SetVal("This")
a=SetVal(7)
The following functions can be called correctly:
FunctionSetVal(xAsString)
Form1.Text1.Text=x
EndFunction
Since Visual Basic can already transfer many different variable types, why do you need overloading functions? This is because although a single function can currently handle multiple data types, it cannot produce different actions based on the different data types passed in. Instead, compare the following two functions:
FunctionGetCustomerID(custnameasstring)AsInteger
'LookupcustomerIDbasedoncustomername
EndFunction
FunctionGetCustomerID(purchaslong)AsInteger
'LookupcustomerIDbasedonpurchaSEOrder
EndFunction
Through overloading, you can implement functions based on the input data type. This is very important for the next version of Visual Basic, because it has a new feature - default data type protection. Generally automatic conversion of variables is beneficial, but you can imagine that it can sometimes cause you trouble. For example, in the previous example of SetVal, what would happen if you want to transmit the character 7 instead of the string "7"? The next version of Visual Basic will automatically catch this error. (If your code is based on Visual Basic's previous non-type-aware functionality, this feature will be disabled)
Finally, polymorphism is the process of redefining an already defined class. For example, you want to write a derived class of the BaseClass class, but you want to rewrite the GetCustomerName function. In the next version of Visual Basic, you can implement this class definition using a new method similar to the following: (Note: the final syntax depends on the official version)
InheritsBaseClass
FunctionGetOrders()
OverridesFunctionGetOrders()
•••
EndFunction
More syntax features
The next version of Visual Basic may have more than just the object-oriented improvements I mentioned above. There are also thread generation, error handling, and many long-awaited new improvements for scalability and reusability.
Currently, Visual Basic supports the apartment-threaded model. While this model provides real efficiencies for application development, it is not ideal. The next version of Visual Basic will have improvements in this area. It uses a freethreaded model, which will be useful when writing scalable network applications. Visual Basic will also include some syntax constructs that you can use to generate multiple threads. Typical thread-occurring operations are as follows:
sett=NewThread(NewThreadstart
(AddressOf(BaseClass.Function1))
From this example, you can see that the next version of Visual Basic has the AddressOf structure, which is used to return the address of the function. You are no longer forced to skip API functions that require function pointers! If you need a return call, you can utilize this to do so.
Another planned improvement is structured error handling. Not long ago, Visual Basic required you to insert numerous OnError statements into your code. For years I've been uncomfortable with inserting so many GOTO statements. These statements repeatedly warned me not to use them again! Now let's face the problem - we need an error handling mechanism.
The next version of Visual Basic will centralize error handling. VisualBasic will support the try...catch...finally construct like those "noble" languages. You can place a subroutine containing error handling at the top of your code. Here is an example of implementing error handling:
SubSafeWrite()
Try
Open"Testfile"
•••
Write#1
Catch
Kill "Testfile"
Finally
Close#1
EndTry
EndSub
There are other exciting improvements that current Visual Basic users will become familiar with. In the next version of Visual Basic, you can initialize variables at the same time they are declared:
Dimaasinteger=10
You can also create and initialize a new object in an expression. You can also share variables through classes. Finally, but not only, the concept of inheritance extends to the foundation of the project's user interface. One of the typical criticisms of Visual Basic is that it makes it difficult to create many different forms based on the same foundation. (This is often a requirement in a joint development environment). In the next version of Visual Basic, you will be able to do this through template types.
These improvements have been anticipated for years. Why? let's see. Visual Basic's communications (which I've been doing for nearly a dozen years) have become increasingly complex, far beyond the first version in 1991. Visual Basic was originally used for the rapid design and development of small, portable tool prototypes in its early days. As a result, Visual Basic gained a (unexpected, in my opinion) reputation as a "toy language". Now that it's clearly not a toy anymore, anyone who says that is acting out of blind prejudice. There are now a large number of Visual Basic-based software packages in various fields. VisualBasic is evolving. Last year, at the Center for Research, I talked with a software developer who was writing programs using Web-Class that received millions of hits a week.
The changes in the next version of Visual Basic are surprising. If you want to get those benefits they bring, then use them. If you don't want to, you can confidently use what you are still using. However, it is good to know that the functions that C and Java do can be implemented in a language like Visual Basic that is much easier to use than C and Java.
Future development trends
What kind of impression did this preview presentation leave on you? It's a good question, but you can find the answer to it. In the past year, we can clearly see the changes in ASP development. These development programs often consist of some easy-to-read ASP scripts, and the entire program is run based on these scripts. Since ASP interprets and executes the entire script code, when assembling each component, people gradually discover the inherent limitations of this technology. I'm hearing more and more developers say that they want to completely separate their event handlers from script code and implement them under a faster compilation model, written in C++ or Visual Basic, through COM interface for assembly.
For every reason you can think of, Visual Basic can satisfy it. Designing components with Visual Basic is actually no more difficult than using VBScript or JScript®. You can write code that executes faster and achieves your requirements easily. When the next version of Visual Basic is released, you can use Visual Basic to generate network-oriented objects that are compatible with ASP. In short, taking the route of component combination will be considered the best choice now and in the future.
As I mentioned earlier, there is a broad base of Internet-oriented applications written using Visual Basic (and WebClasses). The problem is that most WebClasses-based applications are not well designed. They do not distinguish well between the different layers of the application, confusing middle-tier processes with DHTML-based user interfaces.
The next version of Visual Basic will introduce WebClasses, which are carefully selected tools for web development. Because it's more scalable, more powerful, and truly language-agnostic. It works across all tools in Visual Studio. If you pay attention to some basic rules of multi-layer development, you can make this transition easily. Special attention should be paid to separating the middle layer process and the display layer process. It is strongly recommended to refer to the Windows® DNA2000 architecture when doing these tasks. The core event processing functions must be completed in the middle layer, and you can use various components written in your favorite compiled language to implement these functions. These components are then assembled in an ASP script file so that the components can work together. It would be ideal if you put most of your logic in event objects rather than scripts. Not only is it a good idea for future transitions to Webservices, it's also a practice worth emulating. ->