• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            Overview

            Applications on Symbian OS use a standard set of conventions to name their classes, structs, variables, functions, macros, enumerations, and constants. This topic explains the meaning of these conventions.

             

            Class names 

            Most class names are formed with a prefix letter C, T, R, or M. Briefly, the meaning of these is as follows: 

          1. C: heap-allocated classes, that are derived from a base class CBase

          2. T: value classes, that do not own any external object

          3. R: resource classes, that contain handles to a real resource which is maintained elsewhere

          4. M: interface classes, that define abstract protocol definitions that are implemented by derived classes

            Classes that consist solely of static member functions have no prefix letter. Beyond the prefix, the class name is usually a noun that indicates the purpose of the class.


            Struct names

            Structure types are considered as similar to T classes, as they should not own external objects, and are normally given names beginning with T (although some begin with S).


            Variable names

            Member variables names begin with i, e.g. iMember. This makes it easy to check that certain cleanup-related rules are being obeyed. Arguments names begin with a, e.g. aControl or aIndex. Local variables names have no initial letter. Global variables are usually avoided, but when used, their names begin with a capital letter.

            Symbian OS does not use Hungarian or any notation which attempts to include the variable type in its name: such notations are ugly, and become impossible to manage when there are several hundred classes in the system. They are irrelevant anyway: functions are usually so short that it is easy to see the types of variables defined in them, and class browsers provide a quick way to find the types of class members.


            Function names

            Functions names indicate what they do. They are usually verbs. One exception is getter functions: for a function which returns the value of a member variable, the function name is usually the name of the variable, without the leading i:

            inline RWindow& Window() const { return iWindow; };

            A corresponding setter function would include the word Set, e.g. SetWindow().

            To terminate functions because of error conditions, Symbian OS does not use standard C++ exception handling, but its own system called leaving (see Cleanup Support Overview). Any function that might leave has a name ending in ...L(). This makes the fundamental process of checking for errors easier. The new (ELeave) function might also leave. The fundamental leaving function is User::Leave(). Any function that contains any of these, and does not trap them, might itself leave, and should be coded with a trailing L in its name. If a function calls another which might leave, then its name should have the L suffix also.

            Associated with the leaving mechanism, is the cleanup stack, which allows memory allocated on the heap to be recovered when a leave occurs. An allocation or construction function which places data on the cleanup stack ends with ...LC(). For instance, many new, PushL(), ConstructL() sequences are encapsulated in a NewLC() function:

            CS* s=CS::NewLC(p1, p2);

            This allocates the object, initialises it, and leaves it on the cleanup stack. This process may leave (if only through the PushL()!), so such functions always include an L, and are therefore ...LC().

            A function which takes ownership of its object and destroys it has a name ending in ...D(). An example is the UI framework dialog protocol:

            CEikDialog* dialog=new (ELeave) CBossSettingsDialog;
            if (dialog->ExecuteLD(R_BOSS_SETTINGS_DIALOG))
                {
                // handle successful settings
                }

            The ExecuteLD() function includes second-phase construction, execution of the dialog and then destruction.


            Macro names

            Macro names are all capitalised, with underscores to separates words.


            Enumeration names

            Enumerations are named as follows:

            • as enumerations are types, they have the T prefix
            • enumeration members have the prefix E
            • type and members should have a meaningful, unambiguous name

            Enumerations should be scoped within the relevant class, so as not to pollute the global name space.

            An example of the declaration and use of an enumeration is as follows:

            class TDemo
                {
            public:
                enum TShape {EShapeRound, EShapeSquare};
                };

            TDemo::TShape shape=TDemo::EShapeSquare;



            Constant names

            Names of constants have a prefix K. For example,

            const TInt KMaxNameLength=0x20;

          5. Feedback

            # re: Name Conventions for Applications on Symbian OS  回復(fù)  更多評(píng)論   

            2008-04-27 14:59 by cheney
            支持!

            只有注冊(cè)用戶登錄后才能發(fā)表評(píng)論。
            網(wǎng)站導(dǎo)航: 博客園   IT新聞   BlogJava   博問   Chat2DB   管理


            posts - 1, comments - 5, trackbacks - 0, articles - 2

            Copyright © cheney

            亚洲国产天堂久久综合| 香蕉久久夜色精品国产尤物| 人妻少妇久久中文字幕一区二区| 蜜臀av性久久久久蜜臀aⅴ麻豆 | 久久综合给合久久狠狠狠97色69 | 香蕉久久AⅤ一区二区三区| 中文成人无码精品久久久不卡| 亚洲va中文字幕无码久久不卡| 国内精品久久人妻互换| 久久综合九色综合欧美就去吻| 亚洲va久久久噜噜噜久久狠狠| 国产精品gz久久久| 久久永久免费人妻精品下载| 精品一久久香蕉国产线看播放| 亚洲AV日韩AV天堂久久| 欧美亚洲日本久久精品| 一本大道加勒比久久综合| 热99RE久久精品这里都是精品免费 | 中文精品99久久国产 | 精品久久国产一区二区三区香蕉 | 色综合久久88色综合天天| 久久亚洲AV无码精品色午夜| 成人妇女免费播放久久久| 久久久久久久波多野结衣高潮 | 国产无套内射久久久国产| 中文字幕热久久久久久久| 久久久久99精品成人片牛牛影视 | 国产日韩欧美久久| 久久777国产线看观看精品| 国内精品综合久久久40p| 少妇久久久久久被弄到高潮| 麻豆精品久久精品色综合| 99久久久国产精品免费无卡顿| 精品国产青草久久久久福利| 久久国产亚洲精品| 久久久无码精品亚洲日韩软件| 精品久久久无码中文字幕天天| 狠狠精品久久久无码中文字幕| 91精品国产高清久久久久久91| 国产精品久久久久9999| 久久精品国产亚洲沈樵|