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 />

Constant KMaxFileName,<br />

KRgbWhite<br />

Member variable iDevice, iX,<br />

iOppFleetView<br />

Automatics device, x,<br />

oppFleetView<br />

Constants of the #define type or<br />

const TInt type. KMax-type<br />

constants tend to be associated with<br />

length or size limits: KMaxFileName,<br />

for instance, is 256(characters).<br />

Any nonstatic member variable. The i<br />

prefix refers to an 'instance' of a class.<br />

Any variable declared as an automatic.<br />

Static members aren't used in native Symbian OS code. Global variables, such as console,<br />

are sometimes used in .exes (though not in DLLs). Globals have no prefix. Some authors<br />

use initial capitals for globals, to distinguish them from automatics. I haven't got very strong<br />

views on the right way to do things here, preferring to avoid the issue by not using globals.<br />

The i convention is important for cleanup. The C++ destructor takes care of member<br />

variables, so you can spot overzealous cleanup code, such as<br />

CleanupStack::PushL(iMember) by using this naming convention.<br />

As with class names, you should use nouns for value names, since they are objects, not<br />

functions.<br />

3.2.3 Function Names<br />

It's not the initial letter that matters so much here, as the final letter.<br />

Category Examples Description<br />

Nonleaving function Draw(),Intersects() Use initial capital. Since<br />

functions do things, use a verb<br />

rather than a noun.<br />

Leaving function CreateL(), AllocL(),<br />

NewL(), RunL()<br />

Use final L. A leaving function<br />

may need to allocate memory,<br />

open a file, and so on –<br />

generally, to do some operation<br />

that might fail because there<br />

are insufficient resources or for<br />

other environment-related<br />

conditions (not programmer<br />

errors). When you call a leaving<br />

function, you must always<br />

consider what happens both<br />

when it succeeds and when it<br />

leaves. You must ensure that<br />

both cases are handled.<br />

Symbian OS's cleanup<br />

framework is designed to allow<br />

you to do this.This is Symbian<br />

OS's most important naming<br />

convention.

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

Saved successfully!

Ooh no, something went wrong!