Class Descriptor

Part of the ObjectBasedProgramming pattern language. Discussion occurs on ClassDescriptorDiscussion?.

Original at http://www.geocities.com/SiliconValley/Foothills/5962/classdescriptor.htm


Intent

Provide a centralised storage to store information common to a particular class, but extrinsic to an instance of that class.

Motivation

The two motivations are:

Applicability

Use the ClassDescriptor pattern when

Solution

Information pertaining to an entire class is moved out of the instance data structure, and moved into a class descriptor.

Consequences

The ClassDescriptor has three important consequences:

  1. Reduced memory usage. Information pertaining to a class is separated from the information intrinsic to an object. The extrinsic information is removed from the instance data. The elimination of duplication can greatly reduce memory usage, especially if there is a great number of instances.

  2. Higher conceptual complexity. The use of a class descriptor introduces another layer of indirection, and consequent conceptual complexity.

  3. Class Tag pattern must be applied. To access the correct class descriptor, there must be a mechanism to determine the class of an object at run-time.

Sample Code

This section is to be filled out.

Known Uses

This section is to be filled out.

Related Patterns

The ClassDescriptor pattern is an implementation-level application of the FlyweightPattern.

The ClassTag pattern is a pre-requisite of this pattern.

The FunctionPointer pattern is often used with this pattern. The function pointers are information extrinsic to an object instance, and are a perfect candidate to move into the class descriptor.


EditText of this page (last edited November 9, 2002) or FindPage with title or text search