Introducing the Framework Class Library

As you have probably figured out from its name, the class library is merely a collection of classes and related structures that can be leveraged as base building blocks for application development. As such, it is safe to think of this collection of classes as an API: They are a boundary interface between our applications and the operating system. This concept, of course, is really nothing new to Visual Basic developers: the ADO library, the Win32 API, the COM+ services library—all of these constructs have allowed us to reference and use pre-existing code in our applications. The class library is a massive library of pre-existing code that you can use as a foundation for your application features.

Note

Referencing pre-existing libraries of code has traditionally been pretty easy with Visual Basic. One of the main issues, however, was that many times these code libraries weren't initially consumable by Visual Basic developers. If you were a C++ programmer, the world was open to you in terms of functionality. VB programmers had to wait for Microsoft or some other entity to make a wrapper or interface available that we could use from VB. Documentation also tended to be a problem.


Organization—The Namespace Hierarchy

The primary units of organization for the class library are namespaces. A namespace is just a bucket for functionality: It describes a grouping of like-focused classes and constructs. You can liken the concept of a namespace to that of a file system folder—they both attempt to implement organization across objects with parent and child relationships. Just as a folder can contain other folders and actual documents, a namespace can contain other namespaces or actual classes, delegates, and so on.

All namespaces stem from a common root: the System namespace. The System namespace is the one and only common root for all other namespaces.

The System namespace, for instance, contains the actual structures that define the common data types used in .NET such as Boolean, DateTime, and Int32. It also contains the most important data type of all, Object, which is the base object inherited by all other .NET objects.

Walking the Tree

The first level of children namespaces under the System namespace represents the high-level functionality groupings exposed by the API. Table 4.1 shows these high-level namespaces, with a brief description of their focus. Remember that each one of these high-level namespaces can (and likely will) have other children namespaces that further decompose and organize the functionality and focus of the parent namespace. A good example of this is the System.XML namespace, which parents the System.XML.Schema, the System.XML.Serialization, the System.XML.XPath, and the System.XML.XSL namespaces.

Table 4.1. Primary Namespaces Under the System Root
Name Focus
CodeDOM Source code document structure and manipulation (including compilation).
Collections Collections of objects including arrays, hash tables, and dictionaries.
ComponentModel Runtime and design-time behavior of components and controls.
Configuration Configuration settings management for the Framework.
Data Data access and management (essentially defines the ADO.NET technology).
Diagnostics Application debugging and execution tracing. Also included in this namespace are classes related to event log manipulation and performance monitoring.
DirectoryServices Access to the Active Directory.
Drawing Graphics and drawing, including printing.
EnterpriseServices COM interactions and settings.
Globalization Definition of culture-specific settings.
IO Synchronous and asynchronous access to files and streams.
Management Access to WMI functionality.
Messaging Message creation and transmission in addition to management of message queues.
Net Network communications and protocols.
Reflection Examination and on-the-fly creation of types, methods, and fields.
Resources Management of culture-specific resources.
Runtime Access to low-level runtime functions, including compilation and interop services.
Security General runtime security including policies, permissions, and credential resolution.
ServiceProcess Creation and installation of Windows services.
Text Conversion and formatting of text.
Threading Explicit thread creation and management.
Timers Server-based timers.
Web Browser/server communication over HTTP.
Windows Form-based Windows creation.
XML XML processing.

You should know that the Framework Class Library can be extended, but that the system root namespace will always contain classes that are universally useful to applications. Companies may introduce their own libraries that will co-exist with the System namespace and that will, in fact, operate under their own root namespace. Microsoft, for instance, has already shown us an example of this by including several language-focused namespaces under a root Microsoft namespace. Thus, we have Microsoft.Csharp, Microsoft.VisualBasic, and so on.

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

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