03.01.2013 Views

Chapter 1

Chapter 1

Chapter 1

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Category Examples Description<br />

Static classes User, Math, Mem,<br />

ConeUtils<br />

inheritance in Symbian OS;<br />

they act similarly to<br />

interfaces in Java. The<br />

old technical term<br />

was'mixin', hence the use of<br />

M.<br />

A class consisting purely of<br />

static functions that can't<br />

be instantiated into an<br />

object Such classes are<br />

useful containers of library<br />

functions.<br />

Structs SEikControlInfo A C-style struct, without<br />

any member functions.<br />

There are only a few of<br />

these inSymbian OS; most<br />

later code uses T classes<br />

even for structs.<br />

Some other prefixes are occasionally used for classes, in rare circumstances. The only one<br />

we'll encounter in this book is HBufC, for heap-based descriptors. Kernel-side programming<br />

uses D for kernel-side CBase-derived classes.<br />

The distinction between T, C, and R is very important in relation to cleanup properties, which<br />

I'll cover in detail in <strong>Chapter</strong> 6.<br />

Lastly, always ensure that class names are nouns: classes are for objects, not actions.<br />

CBase-derived classes should not be allocated on the stack as automatics. The zero<br />

initialization will not work, so the class may not behave as expected. These classes are<br />

designed exclusively to be used on the heap; their behavior is undefined if used in a stack<br />

context. There are also situations in Symbian OS in which the destructor of an object may<br />

not be called. The methods used to resolve all this assume that the object is heap-based. To<br />

prevent this situation, most CBase classes have private constructors that are called from<br />

standard static functions (generally called NewL or NewLC).<br />

3.2.2 Data Names<br />

These also use an initial letter, excepting automatics.<br />

Category Examples Description<br />

Enumerated constant EMonday,<br />

ESolidBrush<br />

Constants in an enumeration. If it has<br />

a name at all, the enumeration itself<br />

should have a T prefix, so that<br />

EMonday is a member of<br />

TDayOfWeek.When we cover<br />

resource files, we'll also find some<br />

#defined constants use an E prefix in<br />

circumstances in which the constants<br />

belong to a logically distinct set.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!