October 3rd, 2007

The most important choice in writing is not what you say, it’s what you don’t say

“The most important choice in writing is not what you say. It’s what you don’t say.” Eric Gunnerson gave me that advice when I was writing my book. It’s sort of the writing version of “You don’t know what you do until you know what you don’t do.”

That’s why I’ll write

Of course, you probably wonder this magical pfl comes from. It comes from the Multilanguage Object in mlang.

  IMLangFontLink2 *pfl;
  CoCreateInstance(CLSID_CMultiLanguage, NULL,
                   CLSCTX_ALL, IID_IMLangFontLink2, (void**)&pfl);
  ...
  pfl->Release();

and not

The pfl variable we’ve been using is an interface pointer to the IMLangFontLink2 interface. We obtain this pointer by calling the CoCreateInstance function, asking for the object whose class ID is CLSID_CMultiLanguage (defined in the mlang.h header file) and specifying the interface ID (IID) of IID_IMLangFontLink2. The interface ID is a 128-bit value that uniquely identifies an interface; we use it here to specify that we wish to have access to the IMLangFontLink2 interface. Since COM uses explicit reference counting, we must remember to call the IUnknown::Release method when we are finished with the interface pointer. Each call to the IUnknown::Release method decrements the reference count by one, and when the reference count drops to zero, the object is destroyed.

  IMLangFontLink2 *pfl;
  CoCreateInstance(CLSID_CMultiLanguage, NULL,
                   CLSCTX_ALL, IID_IMLangFontLink2, (void**)&pfl);
  ...
  pfl->Release();

 

This is why I hate reading technical books. People think it’s better to write fifty words when ten are enough, that you should explain everything in excruciatingly tedious detail just in case there’s a reader out there who sees the word CoCreateInstance and says, “Gosh, I don’t know what that is, and I’m going to declare this book useless unless it explains everything from first principles.”

What next? “The left open brace begins a block of statements”?

Topics
Other

Author

Raymond has been involved in the evolution of Windows for more than 30 years. In 2003, he began a Web site known as The Old New Thing which has grown in popularity far beyond his wildest imagination, a development which still gives him the heebie-jeebies. The Web site spawned a book, coincidentally also titled The Old New Thing (Addison Wesley 2007). He occasionally appears on the Windows Dev Docs Twitter account to tell stories which convey no useful information.

0 comments

Discussion are closed.