Wednesday, May 04, 2005
Welcome to the Descriptor FAQ
Someone famous once said that some high percentage of computing was manipulating strings. If you believe this to be true, then getting the hang of string handling is vital.
Most programmers come to Symbian OS from some other development environment, and tend to think they’ve already got strings pretty much sussed. After all, there’s not much to C strings to understand, although there are plenty of ways they can go wrong. The Java String and StringBuf classes have about the best combination of power and simplicity that you can get. And the various String and CString classes found in different flavours of C++ environments are usually mastered fairly quickly.
But then they encounter Symbian OS descriptors. If there was anything invented to bring a high flying C++ developer firmly back to ground during their first week of Symbian OS development, it’s descriptors. “Good grief, there’s a whole zoo of them” is a typical comment upon the first reading of the descriptor chapter in a Symbian OS programming book. They look at the various diagrams showing the C equivalents for each descriptor types. They try the examples. It seems just about to make sense. And then they try using them for real, and it all goes wrong.
Descriptors seem designed to restrict you. They don’t compile when you think they should. Or they compile without complaint, but panic when you use them. And if they do compile and run without crashing, they still may just plain refuse to do what you expect them to do. At which point it’s tempting to turn to the chapter in the book on using the standard C library and use C strings instead.
Well don’t. Stick with them. You don’t really have a choice anyway if you are going to be a Symbian OS developer. There are many good reasons to use descriptors, as will become apparent as we proceed.
What is needed is a really good explanation of descriptors in simple language that non-Symbian OS developers can understand. It should be detailed, because without the detail you can’t use them successfully. There should be examples of how not to use them, as well as the more typical book examples of how they should be used.
All Symbian OS developers will have made the same mistakes of using descriptors incorrectly and not understanding what’s going wrong. This article sets out to short-cut the painful learning curve. The authors have been along it, slowly and painfully. Don’t follow in their footsteps.