Developer .NET UPDATE—brought to you by Windows & .NET Magazine Network.
THIS ISSUE SPONSORED BY
Microsoft ASP.NET Connections
XML Web Services Connections
(below DEVELOPER .NET PERSPECTIVES)
SPONSOR: MICROSOFT ASP.NET CONNECTIONS
MICROSOFT ASP.NET CONNECTIONS TO CO-LOCATE WITH SQL SERVER MAGAZINE LIVE!
Microsoft ASP.NET Connections and VS.NET Connections will co-locate with SQL Server Magazine LIVE! from Oct. 27 - 30. Register for one event and access sessions to the other two events for FREE. Save $2,990 when you register today, before your Early Bird discount expires. Access more than 170 sessions from top third-party gurus, Microsoft product developers, and magazine authors. This must-attend event will help you keep your skills sharp. Dig deeper into the Microsoft .NET Framework and discover how it will impact you and your company. Chock full of practical information you can use right away. Real-world technical tips and insights you don't want to miss. Register on the Web before this event sells out!
July 30, 2002—In this issue:
1. DEVELOPER .NET PERSPECTIVES
- Object-Based vs. Object-Oriented Environments
- Get Kudos & a Free Trip to SQL Server Magazine LIVE! in Orlando!
- Windows & .NET Magazine Is Even Cooler in a Digital Version
- Clarification: Symbols Sometimes Appeared as Gibberish
- Featured Thread: The MCDBA Certification and .NET Exams
4. NEW AND IMPROVED
- Learn About ASP.NET
5. CONTACT US
- See this section for a list of ways to contact us.
1. DEVELOPER .NET PERSPECTIVES
(contributed by Bill Sheldon, firstname.lastname@example.org)
One of the biggest shifts for most developers migrating to the Microsoft .NET Framework involves the underlying programming paradigm. Although C++ developers have always worked in an object-oriented (OO) environment, most other developers have worked in what can be termed an object-based environment. This difference might not seem significant, but the real challenge comes in understanding some of the concepts that a true OO environment, such as the .NET Framework, introduces.
Many people wonder why Visual Basic .NET isn't backward-compatible with Visual Basic (VB) 6.0. Although transitioning VB 6.0's runtime environment to the .NET Framework might have been possible, the underlying paradigm shift mandated that VB undertake a massive transformation. This underlying shift, and not any specific syntax changes, prevents backward compatibility. As an object-based environment, VB 6.0 is limited in access to concepts such as inheritance, overloading, and overriding. Just like C++, Lisp, Smalltalk, and other OO languages, Visual Basic .NET (and every .NET language) takes full advantage of OO concepts.
To discuss some of OOP's inherent features, we all need to be on the same page with some of these concepts, starting with the concept of an object. An object has a set of data (i.e., properties) and behaviors (i.e., methods) associated with that data. For example, consider a table of employees in a database. Although this table has certain data that defines the employees, it doesn't have any behaviors. That's where classes come into play. You can create a class that persists the data associated with the employees (i.e., persists the properties) and that provides a set of behaviors that control how to manipulate the data (i.e., provides the methods).
So far, this definition of an object describes how objects behave in object-based environments, such as VB 6.0. However, this definition doesn't describe how objects behave in an OO environment. The object that I've described thus far has more in common with a procedural language than an OO language. Objects in object-based languages are complete packages—everything that describes the implementation of the object is self-contained. One object doesn't share its implementation with any other objects. More important, no native way exists to group a set of objects as a generic type. The ability to group a set of classes under a generic class is at the heart of OOP.
With VB 6.0, you can create an employee object, but that object can't act like a person unless you write code. Although you can use a concept called interface inheritance to put a wrapper on the object so that you can treat the object as a person, this wrapper doesn't automatically give you the same behavior because every object must implement its own version of that wrapper. So, although VB 6.0 uses objects, you can't automatically create specific objects as part of a generic definition. However, in OOP, you can have a generic definition define a behavior that, when called, will look at the specific type of object and call the correct implementation method for that behavior.
OO terms such as polymorphism, inheritance, overloading, and overriding describe the ability to group classes under more generic classes and manage the implementation of both the specific and the more generic classes. Polymorphism is generally the scariest of these terms, but in many ways, it's the simplest to understand. According to Merriam-Webster OnLine (http://www.m-w.com), polymorphism is "the quality or state of being able to assume different forms." So, if you can treat the employee object as a person, then the object is polymorphic. Using interface inheritance, you already have this ability to a limited extent. However, polymorphism extends this ability because you can use inheritance instead of explicitly implementing each object's different form. (For more information about polymorphism, click here.)
Inheritance means that you can say, in the initial class declaration, that a class is derived from a more generic class. For example, an employee IS A person—the "ISA" test is the key to inheritance. Thus, employees are simply a specific type of person; as such, you can use the behavior and properties associated with people without needing to reimplement that logic. You can even create a group called supervisors that are employees, which means that the supervisors are also people. Thus, you can treat supervisors as people.
An important point to remember about inheritance is that when you manipulate the object's type, you don't risk losing any data because the object never loses its original type. For example, when the system implements polymorphism, the system doesn't change the underlying behavior or data; it simply limits what's exposed to the methods and properties associated with the current type. Polymorphism is just a temporary transformation, or "cast," from the object's actual type to one of the base classes that help define the object.
To manage all this movement within a generic type, you use overloading and overriding. Generally, overloading and overriding are associated with the way objects within the same class structure expose methods. At the top of the class structure, the person class might have a CreateNew method. Because the person class has no idea that employees or supervisors exist, it might require only a name to create a new person. Because the person class has the method, the employee class—which inherits from the person class—also has this method.
Overriding comes into play when you want to change a method. Suppose you want to create employee objects by specifying an employee number rather than a person's name. The person object doesn't know about employee numbers, so you need to create a function with the same name "CreateNew" within the employee class. After you create this function, you can create an employee object by calling the employee class's CreateNew function and specifying an employee number.
Earlier, I noted that with polymorphism, the object doesn't change when you cast it to a parent (or base) type. This concept is important in overriding. When you override a method, even if the object has been cast as a base class, the base class knows that the more specific class might have reimplemented this method. If the base class finds a reimplemented method in the more specific class, the base class will call the specific class's version of the method. For example, suppose an application declares a new instance of an employee, then passes this employee to a generic function that handles creating new people. The generic function is unaware that an employee object exists. When that generic function passes in the name of the new person, the object will recognize that it is really an employee (a specific type of person) and call the CreateNew function.
Overriding relies on the fact that with polymorphism, the actual class is part of the object's definition. Even when you designate an object as a more generic version of itself, the actual object still has a reference to its specific type. In this respect, overriding differs greatly from overloading.
Overloading doesn't make a function available through polymorphism; instead, it lets you specialize the methods that originate in the base class. For example, with overloading, you might create a CreateNew function in the employee class that accepts both the person's name and the employee number. Of course, the person class has no concept of employee numbers, so it can't reference this member function.
Unfortunately for VB developers, the implementation syntax for many OO concepts varies greatly between Visual Basic .NET and the other .NET languages. The result is that in future commentaries, I'll often provide two versions of the implementation for concepts such as inheritance, overriding, and overloading. Introducing each concept deserves a column of its own, so I'll be covering these concepts in detail in the coming weeks. However, next week, I'll discuss the construction and destruction of objects. Although the .NET garbage collector is great, you still need to know how to clean up resources before the garbage collector takes out the trash.
SPONSOR: XML WEB SERVICES CONNECTIONS
XML WEB SERVICES CONNECTIONS TO CO-LOCATE WITH WINDOWS & .NET MAGAZINE LIVE!
XML Web Services Connections and Windows & .NET Magazine LIVE! will co-locate from Oct. 30 Nov. 2 immediately following Microsoft ASP.NET Connections, VS.NET Connections, and SQL Server Magazine LIVE! Deep discounts available for those attending the entire week of conferences. Save even more by registering now to lock in your early bird discount. Full details for conference sessions, speakers, and workshops are now online. Register today to guarantee your seat!
(brought to you by Windows & .NET Magazine and its partners)
Get the recognition you deserve for your cutting-edge SQL Server solution and take home the SQL Server Innovator's Cup. If you work with SQL Server and have created a technical solution to a problem or enhanced a program or system feature to improve performance or return on investment, you qualify to enter this awards program sponsored by Microsoft. Enter today at
Now you can get Windows & .NET Magazine delivered right to your PC digitally! Download a free sample issue now, and experience for yourself how easy it is to get a paper-free magazine. Fill out our brief survey (you'll find links inside the digital magazine), and get a special offer on a digital subscription. Act now!
Marquis Howard's July 23 commentary "Developer .NET Perspectives: WebMethod Attributes" contained code that included angle brackets. Depending on the format in which you receive your Developer .NET UPDATE email message, the angle brackets might have appeared as "‹" for the left angle bracket and "›" for the right angle bracket. We apologize for any inconvenience this problem might have caused.
Troy is wondering whether Microsoft plans to include the Microsoft .NET exams as electives for the Microsoft Certified DBA (MCDBA) certification, and if so, when that would occur. To join the discussion, go to
4. NEW AND IMPROVED
(contributed by Carolyn Mader, email@example.com)
O'Reilly announced Matthew MacDonald and G. Andrew Duthie's "ASP.NET in a Nutshell," a reference book that exposes you to the Microsoft .NET platform. The book features a tutorial, two reference sections, and sample code. The book takes you through the transition from Active Server Pages (ASP) to ASP.NET. Topics include Web forums, Web services, ASP.NET server controls, data access, data binding, ASP.NET security, ASP.NET configuration, and the Page, HttpContext, and HttpRequest classes. Pricing is $39.95. Contact O'Reilly at 707-827-7000, 800-998-938, or firstname.lastname@example.org.
5. CONTACT US
Here's how to reach us with your comments and questions:
- ABOUT DEVELOPER .NET PERSPECTIVES — email@example.com
- ABOUT THE NEWSLETTER IN GENERAL — firstname.lastname@example.org
(please mention the newsletter name in the subject line)
- TECHNICAL QUESTIONS — http://www.winnetmag.net/forums
- PRODUCT NEWS — email@example.com
- QUESTIONS ABOUT YOUR DEVELOPER .NET UPDATE SUBSCRIPTION?
Customer Support — Developer_dot_NET_update@winnetmag.com
- WANT TO SPONSOR DEVELOPER .NET UPDATE?
This weekly email newsletter is brought to you by Windows & .NET Magazine, the leading publication for Windows professionals who want to learn more and perform better. Subscribe today.
Receive the latest information about the Windows and .NET topics of your choice. Subscribe to our other FREE email newsletters.