From VB 6 to VB .NET: The Right Move? - Part I
Many developers may be on the fence about beginning to invest in .NET training and tools. They reasonably ask about the benefits they'll get from moving to .NET. Hear 4 straight-talk reasons why developers at Greystone Solutions say the benefits of using VB.NET outweigh the learning curve.
and Rachel Prabhakar
With the release of Visual Basic .NET, Microsoft introduced significant changes to the Visual Basic language. VB .NET isn't just another release. (In fact, some in the developer community have taken to calling the language "Visual Fred," implying that it is actually a new language.)
Levity aside, VB .NET offers greatly expanded capabilities, giving developers the kind of flexibility and capacity offered by Java and C++. However, in order to take advantage of these features, VB developers will need to learn object-oriented programming concepts and methods and become familiar with the .NET Framework.
In this two-part series, we'll explore the major differences between VB and VB .NET, the benefits easily obtainable from VB .NET, and how to leverage VB .NET to build cross-platform web services.
First, let's take a look at some of the major differences between VB 6 and VB .NET and we'll mention our experiences in adopting VB .NET.
The Benefits of VB.NET
Many developers may be on the fence about beginning to invest in .NET training and tools. Quite reasonably, they wonder about the types of benefits they might see for code development and application deployment once they learn .NET.
In our experience, the benefits outweigh the cost of the learning curve. In just the first few months of working with VB .NET, we've seen a number of major benefits to using it natively over straight VB coding.
3. Data Integrity-- VB .NET gives us two ways to maintain data integrity: (1) streamlined record locking using connected data; (2) comparison based exception processing using disconnected datasets. The use of data wizards create well written SQL and stored procedures for select, insert, update and delete. The complexities of ensuring data integrity when performing updates from disconnected datasets are automatically handled by the ADO.NET classes or can be extended to the end user for data conflict resolution. This will work on any OLEDB or ODBC database, not just with Microsoft's SQL Server.
4. Debugging-- When testing for bugs and application performance between separate applications that need to run together in the .NET environment, the VB .NET tools provide good visibility into many bug-prone areas. Visual Studio .NET works across languages and across projects, so that coming up with our debug list was far quicker than in a straight VB environment. Visual Studio .NET provides these features as part of its IDE. For instance, setting up trace points can be conducted very simply from one console across multiple applications and platforms.
Although many of these debugging features were available in previous versions of the Microsoft development tools, they were often difficult to use and hence were under utilized by the development community. The combination of cross language support combined with an improved user interface for setting up, managing and standardizing the debugging tools has brought enormous productivity gains to VB .NET developers.
What's New in VB .NET
One of the first things you'll notice about VB .NET is that it no longer uses the VB runtime. Instead, VB .NET shares a common language runtime (CLR) with a number of other languages, including Visual J#, C#, Managed Extensions for Visual C++, and Jscript. All these languages provide direct access to the .NET Framework. API access remains constant across the different languages sharing the CLR, and developers can extend .NET classes in any of the CLR languages.
Code modules written in different CLR compatible languages are interoperable. For instance, a class written in VB .NET can call a class written in C#. Even more amazingly, with the .NET IDE it is possible to debug through classes written in different languages. This offers development managers a remarkable ability to leverage the skills and talents of developers experienced in different programming languages.
Furthermore, different languages can be employed for the tasks to which they are best suited. VB is well adapted for RAD development, for instance, while the C# support for operator overloading, unsafe pointers, and bitwise shift operations may make it a better choice for low-level development.
With .NET, the 10,000 or so Framework classes are available to VB developers. In the past, C++ developers had access to the MFC and ATL classes, but VB developers didn't have comparable class libraries. We have found the Framework to be astonishingly complete and well designed. In the past we found ourselves writing a lot of plumbing or utility code, but with VB .NET we're finding that we can use Framework classes instead. The Framework classes obviously provide a tremendous advantage, but the sheer volume of classes and information can be difficult to absorb.
Another crucial difference between VB 6 and VB .NET is that VB .NET is a true object-oriented language. Microsoft didn't just tack object orientation on top of VB 6, rather, VB .NET was designed from scratch as an object-oriented language. In VB .NET everything is an object. Like other object-oriented languages, VB .NET supports inheritance and function overloading.
VB developers now find themselves in a situation similar to that of C developers when C++ was introduced. Just as giving the C++ compiler to C developers didn't automatically turn them into object-oriented programmers, VB developers won't necessarily have the object-oriented programming skills needed to make good use of VB .NET. Developers and IT managers can overcome this challenge by investing the time and energy necessary to train programmers in object-oriented concepts and techniques.
VB .NET also introduces a number of new features, such as better threading and structured error handling.
In contrast to VB 6, VB .NET supports free threading. Free threading is a complex model that allows multiple threads simultaneous access to methods and components. VB .NET lets you spawn your own threads, making it easier to create scalable Web applications.
For structured error handling, VB .NET includes a "try . . . catch . . . finally" construct, like that found in Java or C++. You can write nested exception handling code, and avoid the GoTo and Resume statements that could make code bug-prone and hard to follow. The VB .NET error handling structures make it much easier to debug and maintain complex applications.
Using "Object-Oriented" Features in VB .NET
While language changes have been introduced in VB .NET, our developers have generally found them to be fairly straightforward and simple to master. It is possible to use VB .NET to write code that is quite similar to the old VB 6 code. However, the real power of VB .NET, and the steepest part of the learning curve, come in making use of VB .NET's object-oriented features and the .NET Framework classes.
With VB 6, developers could do things "quick and dirty" without fully understanding what was going on underneath. To take an extreme example, in many cases it was possible to get away with writing code without completely grasping the scope of variables. With VB .NET, developers will really have to understand the underlying fundamentals, especially of inheritance.
With all the changes in VB, should I just switch to C# or Java? As developers consider the changes introduced in .NET, some may wonder whether it is worthwhile to stick with the Visual Basic language at all. After all, if you have to learn object-oriented programming and the .NET Framework, why not go all out and simply switch to Java, C# or C++?
In our experience, VB .NET offers you almost the same power and flexibility as Java or C#. As a VB developer, you already know the VB syntax. Switching to VB .NET allows you to focus on learning object-oriented programming and the .NET Framework, without having to master a new syntax at the same time. For developers who already know object-oriented programming and the .NET framework, VB .NET offers advantages in RAD development. For programming tasks requiring lower level development, C#, C++, or Java may be a more appropriate choice.
As we have seen, there are substantial differences between VB 6 and VB .NET. While developers adopting VB .NET will have to make a significant investment of time and energy to learn the technology, it is worth making the switch because VB .NET makes it much easier to write, debug, and maintain robust, scalable, complex applications. For many developers, learning object-oriented programming skills and absorbing the huge amount of information about the .NET Framework will prove to be the most challenging aspects of switching to .NET.
Next Week: Next-gen web services with VB .NET
Barry Wolfield is vice president of client services at Greystone Solutions. Rachel Prabhakar is senior .NET developer at the same firm. Greystone is a Microsoft Gold Certified Partner for E-Commerce Solutions based in Woburn, Mass.