December 18, 1999

Don’t include Extender properties in ActiveX Wizard

The left-most listbox in the first page in the ActiveX Control Interface Wizard includes all the properties exposed by the constituent controls currently on the UserControl’s surface. Unfortunately, this list includes Extender properties, methods, and events, which should be never added to the public interface of the ActiveX control being

Deal properly with Variant properties that can contain objects

If you want to implement a Variant property that can also be assigned an object, you must be very careful about how you build the corresponding Property procedures. To begin with, you must create three procedures, that is Property Get, Let and Set. In fact, the Property Set procedure will

Default Properties tend to hide programming mistakes

Visual Basic lets you create a default property or method by simply selecting the “(Default)” item in the combo box that appear if you click the Advanced button in the Procedure Attributes dialog box. (You can display this dialog from the Tools menu, or by right-clicking on a property name

Over Engineering, Wheel Re-Invention, and Other Diseases

Writing code from scratch, without any prior design or plan, is a very bad programming practice. However, the opposite, namely over-engineering, can be just as harmful. In essence, over engineering is the use of costly, redundant or “cute” features that are not truly necessary. A good example of this is

Declaring a typedef

typedef names can hide intricate syntactic constructs such as pointers to functions and template instances. However, many novices simply don’t know how to declare a typedef, or worse yet

Deep Copy and Shallow Copy

The terms “deep copy” and “shallow copy” refer to the way objects are copied, for example, during the invocation of a copy constructor or assignment operator. In a deep copy (also called “memberwise copy”), the copy operation respects object semantics. For example, copying an object that has a member of

Declaring Pointers to Data Members

Although the syntax of pointers to members may seem a bit confusing at first, it is consistent and resembles the form of ordinary pointers, with the addition of the class name followed by the operator :: before the asterisk. For example, if an ordinary pointer to int looks like this:

The Representation Of Pointers To Members

Although pointers to members behave very much like ordinary pointers, behind the scenes, they are not necessarily represented as pointers. In fact, a single pointer to member usually consists of a struct that contains between up to four fields, each occupying 4 bytes. This is because pointers to members have

Declaring Pointers to Member Functions

Pointers to member functions consists of the member function’s return type, the class name followed by ::, the pointer’s name, and the function’s parameter list. For example, a pointer to a member function of class A that returns int and takes no arguments is defined like this (note that both