first_page the funky knowledge base
personal notes from way, _way_ back and maybe today

MCAD/MCSD Notes: Chapter 3, Lesson 1; Namespace Fundamentals

Lesson 1: Namespace Fundamentals

The purpose of this lesson is to introduce the namespace and object oriented programming (OOP) concepts. I find this chapter confusing and aggressively asserting a Microsoft-centric view of OOP. I assume that I would not have so much trouble with this lesson when I am not aware of the famous achievements of Sun Microsystems!

Namespaces are imported with the using keyword in C# and the Imports keyword in VB.NET. References to namespaces outside of the current VS.NET project depends on the Project > Add Reference command.

The OOP concept of definition is in the use of the class keyword in C# and the Class/Module...End Class/Module blocks in VB.NET.

These concepts are Definition, Access, Inheritance, Constructors and destructors, Delegates, and Abstract classes and interfaces. The opinion here is that two of these concepts, Inheritance and Abstract classes and interfaces, can be rolled up under polymorphism as suggested by the MSDN article "Polymorphism in Components" at:

http://msdn.microsoft.com/library/en-us/vbcon
    /html/vbconImplementingInterfacesInComponents.asp

Correspondingly, in VB.NET we have: Public, Protected, Friend, Protected Friend and Private.

It may be useful to associate the "protection" of members with inheritance, that the very presence of the protected keyword implies a design featuring inheritance.

The author's definition of inheritance for VB.NET deliberately does not use the term "base class" evidently because of its use of the Module... VB.NET inheritance has been awarded the feature called "shadowing" while C# appears to be coming up short. However, the C# Programmer's Reference covers the topic of the new modifier here:

 http://msdn.microsoft.com/library/en-us/csspec/html/vclrfcsharpspec_10_2_2.asp

The author's code sample on page 107 uses the new modifier and is doing the equivalent of VB.NET's shadowing. The "Overview of the Inheritance Keywords" table on pages 102--103 finally shows this equivalence explicitly.

Correspondingly, in VB.NET we have the New() and Finalize() methods.

Correspondingly, in VB.NET we have the Delegate statement.

Another way to say this is that "multiple inheritance" is not supported by the .NET platform. When the author introduces this term there is also the first hint to the stereotypical VB6 programmer that there is another world out there beyond the realm of Microsoft using terms like multiple inheritance. I find that addressing this stereotypical audience in the book is more of an obstacle than not.

A derived member can overload or shadow the base member without regard to the base member's declaration. In C#, when a base member is declared as virtual (or Overridable in VB.NET), a derived member can override this base base member.

For more information, see MSDN article "Recommendations for Abstract Classes vs. Interfaces" here:

http://msdn.microsoft.com/library/en-us/vbcon
    /html/vbconAbstractClassesVersusInterfaces.asp

For more information, see MSDN article "An Introduction to Delegates" here:

http://msdn.microsoft.com/msdnmag/issues/01/04/net/default.aspx

The first pattern uses WithEvents and Handles keywords, which makes VB.NET backwards compatible with VB6. The second pattern uses AddHandler and RemoveHandler statements, which makes VB.NET syntax similar to C# delegate patterns.

mod date: 2005-03-15T22:16:12.000Z