Symbian Basic specification: naming convention

Source: Internet
Author: User
Tags exception handling naming convention

Profile

Applications on Symbian OS use a standard set of conventions to name classes (Class), structs (struct), variables (variable), functions (function), macros (macros), enumerations (enumeration), and constants (constant )。 This topic explains the meaning of these conventions.

Names of classes (class)

The names of most classes are composed of prefix characters c,t,r,m. Here's a quick look at what they mean:

The C:C prefix indicates that the class derives from CB ASE and should be based on a heap construct.

The T:t prefix represents a simple class that does not have any additional resources.

The R:R prefix represents a resource class that contains a handle to a resource in another location.

The m:m prefix represents an interface class that defines an interface but requires a derived class implementation.

For more detailed discussion of prefixes please refer to the class type (class Types--developer Library»symbian OS guide»essential idioms»class types).

Classes that are composed of static functions do not have prefix characters. In addition to prefix characters, class names often represent the purpose of a class by a noun.

Name of structure (struct)

The struct (struct) type is treated as a T class because it does not own any additional resources, and its prefix is usually t (but some begin with s).

Name of variable

The name of the member variable begins with I, for example: Imember, which makes it easy to check for certain purge-related rules. The name of the parameter begins with a, for example: Acontrol or Aindex. Local variable naming does not require prefix characters. Global variables should be avoided, with the first letter capitalized when used.

Symbian does not use Hungarian (Hungarian) or any other name method that contains type information in its name: that would seem complicated and not easy to manage when the system has hundreds of classes because they are always inaccurate: functions are usually very short, This makes it easy to see the types of variables defined therein and class browser provides a quick way to find the class member type.

Name of the function

The name of the function should indicate what it is going to do, usually by means of a verb, a function of the "Get" class is an exception: a function that returns a member variable whose name is usually a variable name that removes the prefix "I":

Inline rwindow& Window () const {return iwindow;};

A corresponding "Set" function contains the word "set", for example: Setwindow ().

The Symbian platform does not use standard C + + exception handling when an error occurs, and it has its own exception handling system called leave (reference»developer Library»symbian OS guide»c++ API guide»base»mem Ory management»cleanup Support Overview). The function name that may produce leave ends with L, which makes it easier to check for errors. function new (Eleave) may also produce leave. The most basic function to produce Leave is User::leave (). Any function that contains the above function and does not catch an exception can produce an exception, and its name should end with L when the code is written. If a function calls another function that may produce leave, its name should also end with L.

associated with the leave mechanism is the purge stack (cleanup stack), which restores the memory allocated on the heap when leave is generated. Allocations or constructors that place resources on the purge stack (cleanup stack) end with LC, for example, NEW,PUSHL (), Constructl () are often encapsulated sequentially into the NEWLC () function:

cs* S=CS::NEWLC (P1, p2);

The above action is to assign an object, initialize and place it on the purge stack (cleanup stack), this process may produce leave (it always contains the invocation of PUSHL), so the function name of this class always contains L, thus forming an LC (c means to clear the stack (cleanup Stack)) ends.

The name of the function that gets ownership of the object and destroys it ends with D. Example of a dialog box in a UI frame:

ceikdialog* dialog=new (eleave) Cbosssettingsdialog;

if (Dialog->executeld (R_boss_settings_dialog))

{

Handle Successful settings

}

The Executeld () function contains the second stage construct (second-phase construction), displays a dialog box, and then destroys its operation.

Name of the macro

The name of the macro is all capitalized and separates the words with an underscore.

Naming of enumerations

Enumeration is named by the following method:

Enumeration as a simple type with a T prefix;

Enumeration members have an e prefix;

Types and members should be meaningful, without the ambiguity of the name.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.