What's in a name?
This vignette is a classic example of how sample code
is rarely a good conduit for learning a new
technology. While scanning through the sample code one of the
first things to catch our eye was CLSID. Ever so eager to
learn everything about a technology, we read the header files and the help
to come to this conclusion.
OLE 2.0 is creme de la creme
of technologies developed by Microsoft. The appeal of
OLE lies in it's commitment to allowing trouble free parleys
between applications. To have programs "talking" to each
other, the need of the hour was to have a method that
would help one OLE application identify another.
Microsoft used the oldest possible
system. Every OLE server is given a
unique number with which it will register itself with a
registration database. Any application seeking to use an OLE
server will search the database for this number and use it to activate the
server.
Moreover, it is not only the applications that are to be
registered with the registration database. The only viable implementation
of OLE so far has been in C++.
Microsoft has provided a set of standard interfaces to
facilitate this implementation. More interfaces will be added as the
days go by. These interfaces, too, are registered with the database and
have to be provided with unique identifiers. Not to mention
other components of an application such as its type library or property
pages.
With OLE expected to become the accepted
standard for inter-application communication; the numbers
assigned as IDs to the OLE applications can be no
pedestrian int or long. These data types
are far too small in size to provide unique IDs for
long.
Microsoft is known for it's foresight. It is also
known never to do things in half-measures. It decided that the IDs will be
128 bits long. Just imagine the prodigious number of
combinations that are possible with 128 bits. It will be a long time
before we run out of unique IDs.
Even the legendary Bill Gates; with
his immense reach and influence; couldn't define a new data type to
hold a number so large. Such minor hurdles have never
stopped Microsoft. They created a structure tag
called GUID, Globally Unique
Identifier.
typedef struct GUID
{
DWORD Data1;
WORD Data2;
WORD Data3;
BYTE Data4[8];
}GUID;
The members of this structure put together give us a
128 bit identifier. The rationale behind this particular
format for the structure was never stated.
CLSID is
but a name for this GUID structure.
CLSID stands for Class
Identifier. As we went deeper into the code,
we encountered yet another of these terms,
IID. A little investigation revealed that this
was nothing but another name for the GUID structure. But
this time it was used to identify an interface; hence the name
IID or Interface
Identifier.
All went well for sometime before
we encountered REFIID; Reference
Interface Identifier. This is once again
a GUID structure. By now we were getting increasingly
irritated at these different names that seem to pop out of the wood-work
at regular intervals. But we had underestimated the power of
Microsoft's imagination. As we delved into OLE automation, we came
across another variation. The UUID ; Universally
Unique Identifier. When we searched for the
UUID definition, we half expected the answer we
got; it was yet another name for the GUID structure. An
UUID is used to identify a type library and/or it's
individual components.
We believe Microsoft has this thing
about names. It has always been an advocate of "sensible" names;
names loaded with meaning. Look at the name and you should know what
it stands for. This was first apparent in the
Windows API. HBRUSH, HPEN, HBITMAP all
#defined to unsigned integers. Whether the user used
HBITMAP or UINT when defining the variable was a
matter of choice. While using UINT saves the user the
bother of having to remember a number of different names using
HBITMAP helps determine the use of the variables at a
glance.
This policy of "meaningful" names is just fine. But
don't you think calling the same structure CLSID, GUID, IID,
REFIID and UUID is carrying things a bit too far?
Especially when the intent of this structure remains unchanged, that
is to be an unique identifier. Or doesn't Microsoft believe in the
concept of too much of a good thing?