Visual Basic .NET Is Object Oriented

Visual Basic .NET Is Object Oriented

As a Visual Basic programmer, you might be thinking that up till now you didn't need to learn object-oriented programming. Classic Visual Basic served your needs nicely. You could do most anything you needed to with some advanced knowledge of the language. However, many programming luminaries feel that the shift from the current programming paradigm to .NET will be at least if not more monumental than the shift from DOS to Windows. A new, energized object-oriented Visual Basic is the tool that is needed.

If you are new to object-oriented programming, don't let this worry you. As I cover the new facets of the language, I'll also explain and illustrate object-oriented techniques. The concepts presented in this chapter (and described in more detail in Chapter 2, "Object-Oriented Programming in Visual Basic .NET") will be amplified throughout the book. If concepts aren't completely clear after you finish this chapter, they soon will be.

Remember that with power comes responsibility. Classes and objects were first introduced in Visual Basic 4.0 and enhanced in versions 5.0 and 6.0. Unfortunately, studies show that over 50 percent of all Visual Basic programmers chose to disregard them. While we could safely turn our backs on classes and objects in previous versions of Visual Basic, we can no longer ignore them with Visual Basic .NET.

As in Java, everything in Visual Basic .NET is an object. But what exactly does that mean? Well, something like an integer object now has its own methods that can format the value the object has or change itself into a string. Object-orientation is part and parcel of Visual Basic .NET, so you don't want to avoid it any longer.

To be honest with you from the start, Visual Basic .NET will require a steeper learning curve than classic Visual Basic. I will cover all aspects of Visual Basic .NET programming, including concepts such as events and classes, which some programmers find difficult. Each part will be covered in detail. And once you learn Visual Basic .NET, you can very easily move to C# or even Visual C++ .NET. A welcome by-product of learning Visual Basic .NET now is that this knowledge will also expand your understanding and use of other languages, which will make you much more marketable.

Unlike programming in previous versions of Visual Basic, programming in Visual Basic .NET requires an understanding of not only the framework I just covered, but the language itself and the infrastructure of how .NET programs are assembled. When teaching Visual Basic 6 to my graduate students, I hold off covering classes and objects until later in the semester. We pace ourselves because there is so much you can do without objects in classic Visual Basic. Because we don't have that luxury in this book, the first few chapters will be front loaded with new concepts such as the .NET Framework, how Visual Basic .NET programs are built, and the fundamentals of object-oriented programming. The remainder of the book will provide programs to hammer home these concepts.

Of course, classic Visual Basic was designed for simplicity, and while simplicity accounted for Visual Basic's phenomenal success, it also meant the language evolved along a different path from C++. With Visual Basic, creating applications with various buttons, text boxes, and other graphical gizmos was relatively straightforward. However, object-oriented capabilities such as inheritance just weren't part of the language. Visual Basic .NET has lost some of this simplicity in favor of more power, flexibility, and robustness. Visual Basic has grown up and joined the ranks of other pure object-oriented languages to handle the programming tasks of the twenty-first century.

As classic Visual Basic evolved, it became more complex. Programmers could build DLLs, ActiveX controls and servers, and classes. Along with this power came a level of difficulty. Advanced Visual Basic programmers had to know about the Windows API, COM, DCOM, ADO, classes, objects, and the rest. Likewise, classic Visual C++ evolved by getting easier. Various graphical tools, frameworks, wizards, code generators, and templates were added to assist in handling the lower-level tasks of Windows programming. As Visual Basic grew in complexity and C++ got easier, we reached an intersection of language complexity and language power. At that intersection is .NET. Both languages have evolved to a point at which they are now relatively equal in power and complexity. As I said earlier, .NET is the great equalizer.

The Visual Basic .NET Web Forms and the Windows Form designers permit a developer to easily create standardized interfaces. Both of these technologies rely heavily on classes. For example, in Visual Basic 6, when a form was added to a project, all of the complexity of construction was hidden. All of the public interfaces were hidden from the programmer. However, they were always there, and the form was still a class under the hood. In Visual Basic .NET, a Windows Forms module contains all of the code to instantiate (create an instance of) itself as well as any controls placed on the form. Programmers are responsible for adding code for handling events. In Visual Basic .NET, you can't even create a form without understanding the concept of a class.



Coding Techniques for Microsoft Visual Basic. NET
Coding Techniques for Microsoft Visual Basic .NET
ISBN: 0735612544
EAN: 2147483647
Year: 2002
Pages: 123
Authors: John Connell

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