Deciding Whether to Upgrade

The Common Language Runtime provides a managed execution environment with strong typing and managed memory allocation and deallocation. This imposes certain restrictions that result in improved overall system stability, performance, scalability, and security. In addition, Visual Basic .NET modernizes the Basic programming language by adding first-class object-oriented programming features and strong typing, making it the equal of any modern object-oriented language. However, these dramatic new capabilities also mean that upgrading from Visual Basic 6.0 to Visual Basic .NET is not a trivial undertaking.

Microsoft has redesigned and restructured Visual Basic, resulting in broken compatibility with Visual Basic 6.0. Many of the most compelling new features in .NET could not have been added without breaking compatibility. The following list summarizes some of the new features available in Visual Basic .NET that are not supported in Visual Basic 6.0:

  • Inheritance-based object-oriented programming.

  • Rich base class libraries, such as those for working with regular expressions, file I/O, and XML.

  • Easy publishing and consumption of XML Web services.

  • Interoperability with other .NET languages such as C#.

  • New language features, including structured exception handling.

  • New Windows capabilities, such as control docking and anchoring and GDI+ graphics.

  • XCopy deployment; no registration required.

  • A familiar model for building Web applications in ASP.NET, using forms, controls, and events.

  • Improved data access and data marshaling with ADO.NET.

  • A robust security model that includes code access permissions.

The price you pay for all this is that much of your old code won't work as it did before. You need to carefully weigh your options before plowing ahead with a migration plan.

Some Applications May Not Warrant Upgrading

When considering whether to upgrade your Visual Basic applications, it is important to keep in mind that upgrading to Visual Basic .NET is optional. It is likely that you have at least some applications that you will never upgrade. Some applications won't benefit from the new features in Visual Basic .NET. You'll need to evaluate each application to see whether it's worth the time and money that upgrading will inevitably cost.

If you or your developers had the foresight—and the resources—to create n-tier architectures, with presentation code, business logic, and data access code separated into loosely coupled components, you can consider leaving some components as is. Visual Basic .NET enables you to reference and work with middle tier or data access components that were built using Visual Basic 6.0. In this scenario, you might need to upgrade only the presentation code at first.

Consider the Cost/Benefit Ratio

Carefully consider the benefits of an upgrade. Clearly, .NET is the future of Windows and Web development on the Microsoft platform. What other potential benefits exist? Scalability? Maintainability? Security? You'll need to weigh these against the costs of the upgrade.

Even if the cost of the upgrade is high, you might still decide to migrate simply to take advantage of the new capabilities in the .NET platform.

There are several cost factors to consider when deciding whether to upgrade.

Language Differences

Visual Basic .NET expands the language in a significant fashion, building on Visual Basic 6.0 by including new keywords, syntactical elements, conditional statements, modifiers, and attributes. Here are a few examples of language features that have changed in Visual Basic .NET:

  • All subroutines require parentheses. For example, MsgBox "Hello World" must now be MsgBox ("Hello World").

  • Subroutine parameters must be qualified by using the ByVal or ByRef keywords explicitly.

  • The syntax for declaring event handlers has been updated, as has the syntax for event parameters.

  • All arrays must have a lower bound of zero. This requirement means that you cannot use Option Base 1.

  • Upgrading fixed-length strings can cause problems. In Visual Basic 6.0, values assigned to a fixed-length string in a user-defined type were automatically truncated if they were longer than the fixed length. After upgrading to Visual Basic .NET, strings will no longer be truncated, possibly resulting in incorrect results.

  • The Variant data type has been eliminated. The closest approximation the .NET Framework offers is the Object type, which is the base type for all other types.

  • The amount of storage allocated to variables declared as Integer or Long has doubled in Visual Basic .NET.

  • Variables declared in a block of code, such as a loop or an IF block, are visible only within that block and any block nested beneath it. In Visual Basic 6.0, a variable declared anywhere in a procedure is scoped to the entire procedure.

You will need to locate and modify sections of code that are affected by these changes to avoid errors or unexpected results.

Architectural Considerations

Visual Basic .NET does not only present a new language. As part of the .NET development platform, it also presents new architectural options. The OOP features of the .NET Framework and the Common Type System, as well as the loosely coupled nature of Web services—both support a component-oriented, interface-based approach to building applications. Although components and interfaces were supported in Visual Basic 6.0, most programmers build monolithic, tightly coupled applications. The more component-oriented and loosely coupled your application is, the easier it will be to upgrade, and the more choices you will have when phasing in the upgrade over time.

In some cases, your application might rely on features that have changed so drastically in Visual Basic .NET that a complete rewrite is your only option. For example, any of the following elements will need to be redesigned in .NET:

  • OLE container controls

  • Painting functions

  • Clipboard code

  • Controls and forms collection code

  • Property pages

Web Applications

Although you can upgrade components of Web applications written in Visual Basic 6.0 using the Upgrade wizard (or the new Upgrade Visual Basic 6 Code option in Visual Studio .NET), there is no tool that will tackle the entire application. The architectural differences between Web applications written with ASP.NET and those that were possible with Visual Basic 6.0 are too extreme to be handled by a wizard or code generator. You will probably want to rewrite Web applications from the ground up to take advantage of the new capabilities in ASP.NET.

Weighing the Benefits of an Upgrade

To enjoy the benefits from moving a Visual Basic 6.0 application to Visual Basic .NET, you will probably need to re-architect and rewrite most of the application eventually. Choosing to upgrade existing code rather than re-writing it from scratch will almost always be a concession to economic imperatives rather than a pure design choice.

However, those economic imperatives are what keep businesses alive. You will find that parts of your applications can successfully be upgraded using the tools available in Visual Studio .NET, and parts can be kept as is, at least temporarily.

In the end, make your decision considering all of your options. Weigh the benefits and costs and look at the return on investment for your organization.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.19.14.243