An Object-Oriented Glossary

Getting started with object-oriented programming involves becoming familiar with several new concepts. I've collected and defined the most important new terms you might encounter in your explorations.

Abstract class: A class that can't be instantiated and can work only as a base type for other (concrete) classes. In VB.NET, you flag an abstract class with the MustInherit keyword.

Class: The design-time definition of all the members of an object. Class variables are pointers to an object's actual data, which is stored in the .NET managed heap.

Constructor: A special procedure named Sub New that's invoked when an instance of the class is created.

Delegate: A type-safe pointer to a method. A delegate class defines a target method's signature (number and type of the method's arguments and its return value); a delegate object is a delegate instance that points to a specific method with that signature.

Encapsulation: The ability to hide the actual implementation of an object's behavior, so that you can change the implementation later without affecting the client code. It's one of the three main features of object-oriented programming, along with polymorphism and inheritance.

Event: A mechanism that allows objects to call back their clients to notify them that something has happened; .NET events are based on delegates.

Field: A private or public variable defined inside a class, a module, or a structure.

Field initializer: A variable VB.NET lets you declare and assign an initial value to in the same statement. This is especially useful for class fields, because you can set their initial values without having to define a class constructor for this purpose.

Finalization: The last step in an object's life, during which the garbage collector reclaims the memory block the object took in the managed heap. This step can occur some time after the application has released the last reference to the object, so the term undeterministic finalization is often used.

Garbage collection: The process during which the .NET runtime discards memory blocks belonging to objects that are no longer used and compacts the managed heap.

Inheritance: The ability to derive a new (derived) class from a simpler (base) class. All .NET types except interfaces inherit directly or indirectly from System.Object.

Interface: A group of related methods, properties, or events. A .NET interface can't include fields or constructors, and all the members defined in the interface are implicitly public.

Managed heap: A memory block where each .NET application holds objects' data.

Method: A Function procedure or a Sub procedure other than a Sub New.

Module: A special class that can't be instantiated and whose members are shared implicitly.

Namespace: Namespaces provide a way to organize related types under a common path—a bit like using subdirectories to group related files. For example, all classes related to multithreading are gathered in the System.Threading namespace.

Nested type: A type that contains the definition of another type. If you mark the nested type as Private, then only the code in the wrapping type can use it.

Overloading: The ability to define multiple properties, methods, or constructors with the same name but different argument signatures. In VB.NET, you have the option of flagging all the overloaded versions of a given member with the Overloads keyword.

Overridden member: A member that's been redefined in the derived class. In VB.NET, you flag an overridden member with the Overrides keyword. You can override only members that are declared as virtual in the base class.

Polymorphism: The ability for different classes to expose the same subset of members to outside clients. You usually achieve polymorphism under .NET by means of inheritance or by having two or more classes implement the same interface.

Property: A class member that behaves like a "smart field," in that it exposes a Get procedure that's invoked when the property is read, and a Set procedure that's invoked when the field is assigned. You can mark it with the ReadOnly and WriteOnly keywords if the property can't be assigned or read, respectively.

Protected member: A method or property you mark with the Protected keyword, which is visible only from inside its class and classes that inherit directly or indirectly from the class where you define the member. Members you flag with the Protected Friend keyword are like protected members, except they're also visible from other classes in the same assembly as the class that contains the member.

ReadOnly field: You can mark a field with the ReadOnly keyword, in which case you can assign that field only from inside its type's constructor.

Scope: The degree of visibility of a member. VB.NET supports the Private, Friend, Protected, Protected Friend, and Public scope keywords. In VB.NET, the default scope for types is Friend (visible inside the same assembly); the default scope for type methods and properties is Public; and the default scope for fields is Private in classes and Public in structures.

Sealed class: A class that can't be inherited from. In VB.NET, you flag a sealed class with the NotInheritable keyword. You can't use this keyword with structures, because structures are sealed implicitly.

Shadowed member: A member in an inherited class that replaces (as opposed to overrides) a member with the same name in the base class. In VB.NET, you flag a shadowed member with the Shadows keyword.

Shared (or static) constructor: A special Shared Sub Main method that's invoked when an application creates the first instance of a given type.

Shared (or static) member: You can mark a field, property, method, constructor, or event as Shared to indicate that it belongs to its type rather than to each individual instance of its type; all instances share these members.

Structure: A structure is similar to a class, except a structure variable holds the actual data, rather than pointing to it.

Type: A .NET type can be a class, a module, a structure, an interface, or an Enum block.

Type member: A type can contain six kinds of members: fields, methods, properties, constructors, events, and nested types.

Virtual member: A method or property that can be redefined in an inherited class. Fields, constructors, and events are never virtual; if you want to allow an inherited class to redefine a field, you must wrap it in a property and make the property virtual. In VB.NET, you flag a virtual member with the Overridable keyword.