symbian日记(4)

来源:互联网 发布:免作业卡淘宝网 编辑:程序博客网 时间:2024/05/18 01:34

 member variables
——reliability (c++)
  It is better by far to encapsulate member data than return reference to it.如果你非得要返回一个成员变量的引用,那最好是个常量引用。如果你必须返回个非常量的引用,you need to provide both a const and a non-const (overloaded) accessor function,或者你根本不能从一个常元函数中调用。

——reliability (c++)
  无论何时你删除成员变量,你都要把他们设置为NULL,这个是个安全措施。

——maintainability (c++)
  千万不要使用公共成员变量。

operators
——viability (c++)
  Assignment operators must handle self-assignment, though this become mostly in relevant in symbian os.

parameters
——readability
  在源文件中使用与你在头文件中定义的相同参数名。

——readability (c++)
  不要使用省略符号,如 func(...)

pointers
——reliability (c++)
  不要使用指针运算。

——reliability (c++)
  不要使用指针强制转换.不幸的是有些你使用的库强制你返回某个特定值,在这种情况下要把强制转换封装在一个函数调用中,并使用c++风格的形式最好不要用c风格的(如dynamic_cast)

——reliability (c++)
  初始化所有的指针为NULL(不是0)

——reusability (symbian)
  使用descriptors 和一些特定类来代替指针,就是当你在存储数据或者处理字符串的时候。

——convention (nokia)
  如果要检查非空指针那最好通过if (ptr),而不是if (ptr != NULL)。
看出来路子不同了吧,symbian真是处处要效率呵:)

R classes
——viability (symbian)
  你不能将R-class 对象放到清除栈中,因为他们不能有析构函数。

——viability (symbian)
  你不能通过值来传递R-class对象,因为R class变量为系统资源,你不应该试图拷贝他们。

——reliability (symbian)
  R classes必须在构造函数中处理所有的成员变量初始化,you cannot rely on memebers being zeroed.

——reliability (symbian)
  R class对象不能通过new来生成。

——reliability (symbian) note

  It is generally necessary to "open" and "close" R-type objects, and hence you see code like this:

  RFile file;
  file.OpenL();
  TRAPD(err, file.ReadL());
  if(err)
  
  //etc. etc

  这个是很没有效率的,使得代码非常难读,being (in effect) a return to the era of checking return values for error codes. Tere is a simple method for bypassing this, shown in the following example:

  class SRClassCleanup
  {
   public:

   static void OpenLC(RFile& aFile)
   {  
    User::LeaveIfError(aFile.OpenL);
    Cleanupstack::PushL(TCleanupItem(ReleaseRFileOnCleanup, &aFile));
   }

   private:

   static void ReleaseRFileOnCleanup(TAny* aObject)
   {
    REINTERPRET_CAST(RFile*, aObject)->Close();
   }

   //repeat for all R-Classes in your project.
  };

  由此我们简化前一个列子,那取决于我们是否从SRClassCleanup派生的。
  RFile file;
  OpenLC(file);
  file->ReadL();
  //etc. etc.
  Cleanupstack::PopAndDestroy(); //close file

resource files
——convention (symbian)
  应将资源结构放在.rh文件中。

——convention (symbian)
  在资源文件中,将资源文件名写成小写。

statements
——reliability (c++)
  Never modify two different object in the same statement.

——reliability (c++)
  Break语句、多返回值和continue语句可能使你的代码更清晰,如果不能达到这个效果那你最好不要使用它们。

strings
——reusability (symbian)
  不要使用字符串常量,要用资源文件里的内容。

structs
——readability (c++)
  总是用类来取代结构。

T classes
——viability (symbian)
  因为T class对象并不能放入清除栈中,所以他不能含有析构函数,特别是当你不能确定它使用在何种环境中时。

——viability (symbian)
  T class 对象不能通过new来生成。
  (symbian) note T class对象可以做为一个值来返回或者做为引用(或值)来传递。

TBool types
  (symbian) note 编译器不允许你把TBool类型同ETrue和EFalse来比较。建议用诸如if (!Visible())来代替。

templates
——reliability (c++)
  Templates should be used only for defining universal containers. Any template should be tested carefully on the target platform.

——reliability (c++)
  Templates should never be used in conjunction with virtual funcitons.

types
——viability (symbian)
  一定要使用symbianOS类型,如果用TInt来代替int

——viability (symbian)
  不要使用explicit type forms(e.g TInt16)除非在一些罕见的情况中(如从资源文件中读取资料)。

——readability (c++)
  在base types之间相互转化时,总是使用explicit casts(它将阐明你的代码含义并驱除一些警告)

——convention
  注意enumeration type的名字总是由一个大写的T前缀来开头的,而枚举的成员将是大写字母E前缀。Use relevant, meaningful, and unambiguous names for enums.

Unions
——reliability (c++)
  不要使用联合类型,除非你不得不写一些底层的面向机器代码。

variables
——reliability (c++)
  一行最好只声明一个变量。

——convention
  Put the pointer or reference indicator next to the type name, with no separating space.

——convention (symbian)
  在symbianOS中变量名常常跟着特有的前缀(如i, a, C, M, T, R, E, K, S),还可能跟着些后缀如(L, C, D),只有那些局部的变量才使用小写字母以用来distinguish them from functions.


——convention (symbian)
  变量名要尽量好懂也不要太长,当然在一个循环中使用i或j是提倡的,这些都是c/c++的风格:)

——convention (symbian)
  局部变量就要由一个小写字母开头。

——convention (symbian)
  参数名应该有前缀a,后面跟着个大写的字母。

——convention (symbian)
  成员数据名应该跟有前缀i,后面也是大写字母。

virtual funcitons
——viability (c++)
  永远不要在一个构造或析构函数中调用虚函数。原因不明而寓,可能它都没有构造好或已经解构了。

——reliability (c++)
  不要overload虚函数。

——reliability (c++)
  但你处理一个虚函数,会经常需要调用基类相关处理。譬如:
  SportsCar::DoSomething()
  {
   FastCar::DoSomething()
   //code here
  }//注意基类的调用只应该在头或尾不能是中间,这样不好维护。

——reliability (nokia)
  虚函数不要写成内联的形式,除非是析构函数。

——readability (c++)
  Never change the visibility (public/protected/private) when overriding a virtual funciton.

——reliability (c++) note
  In an overridden function you cannot make any more assumptions than the preconditions of the base class implementation and your own class Invariants.

术语表

大部分都是根据具体内容来定的分类,包括如下:
C++   ——c++ 编程
Symbian ——symbian OS编程
OOP   ——一般的面向对象的编程
UML   ——统一建模语言

(symbian) Actionve Object
  这是一个从CActive派生来的类的实例,是为了处理异步请求而准备的。

(symbian) Active Scheduler
  这个是一个symbianOS的核心对象,其中是一系列当前活动对象的列表,and which monitors them and invokes the RunL function on the highest priority one that has signalled that it requires attention with a call to SetActive.

(symbian) AIF
  一个应用程序信息文件。

(symbian) animation client
  这是一组允许用户界面代码的函数,例如,生成一个animation server, 并和它连接在一起以生成和控制那些animated images,并且释放它们。

(symbain) Animation DLL
  这是一个animation server端的DLL,允许animation images的生成,处理和释放。

(symbain) animation server
  这个animation DLL做为window server的一部分来运行的。

(symbian) Application Framework
  A set of symbian os base classes from which particular classes must be derived in order for the operation system to interact with an application program.

(OOP) Application Programmer's Interface
  An interface where operations are invoked through programmed function calls, 同用户interface不同。

(symbian) Application View
  一个从CCoeControl继承而来的类,for displaying data from the model in a particular format. Multiple views may be to display the same data in different ways.

(symbian) AppUI
  应用程序用户界面。

(symbian) AppView
  应用程序视图。

(OOP) assertion
  A Boolean expression placed at a particular point in a segment of executable code stating what must be true when execution reaches that point. If the expression evaluates to false when the code is executed, the preceding code is incorrect. Preconditions, postconditions and class invariants are special kinds of assertons.

(symbian) asynchronous service request
  这是对资源的一次调用,which starts an operation and returns, straight away. The operation may signal its completion later, through e.g. a callback.

(OOP) blocked
  这种情况发生在一个函数或一个线程执行的中断中。一个函数的执行会遭到阻塞,即当向另个函数进行一次同步调用时。

(symbian) C class
  这是从CBase类派生出来的类,C类实例是唯一应在堆上创建的。如果一个对象拥有一个析构函数那它一定是一个c类实例这样它的析构函数就可以在异常发生时自动的调用。

(OOP) callback function  
  A function implemented in a client class which can be called by the client's supplier to signal that some event has happened, such as an asynchronous operation completing, Callback 函数是从一个mixin observer class中派生的。

(symbian) CBA
  命令按钮区,也就是工具栏。

(symbian) CKON
  A GUI library specific to the Crystal系列的symbian os设备(注意symbian分水晶、珍珠和石英三个系列)

(UML) class diagram
  A diagram depicting a selection of classes in a system and relationships between them, including "inherits"

("derived from"), "contains", and "uses" relationships.

(OOP) class invariant
  作为类描述一部分的assertion,指定了一个布尔型的表达式,它要保证类的所有实例在任何时候都为True,除非是当某个成员函数在运行时可能有变化。class invariant只是当类成员被调用时有意义。如果返回False那就表明这个函数有错误。

(symbian) cleanup stack
  这是一个专门用来存放C类对象引用的(指针)堆栈,以便当异常发生时调用其析构函数。

(symbian) client
  这是个利用symbianOS server提供服务的类或package。客户和服务端可能运行在不同的线程甚至是进程。

(UML) component diagram
  这是个表达软件模块、源代码模块、二进制模块和可执行模块之间相互依存关系的图表。可能也包括接口。

(symbian) descriptor
  A string in Symbian OS defined in one of serveral class all derived from TDesC.

(symbian) Document
  这是一个继承自CEikDocument(这是作为应用程序框架一部分而存在)的一个类,它可以包含所有可被serialise的数据和能将其永久存储的函数。

(symbian) DTMF
  Dual Tone Multi Frequency - the sound generated when you press a key on a tone dial telephone.

(OOP) EIKON
  Symbian OS's generic graphical user interface. EIKON defines a particular look and feel demonstrated by the Psion series 5 devices.

(OOP) factory
  类厂。这是一个接口类,主要用来产生对象的。(symbian中也有COM的思想,够酷:)

(symbian) L function
  任何可能发生异常的函数,要在其名字后面放上后缀L大写字母。

(symbain) Leave
  这是个symbain OS异常机制,一个异常可能在new(ELeave)、User::Leave()或L函数的调用中发生。

(OOP) mixin class
  An interface class.

(OOP) observer
  An object on which a callback function can be invoked to notify it that some event has occurred in the object it is observing. The observed object does not need to know anything about the observer except that the callback function can be invoked on it.So the observed object's class is not dependent on the observer's class and can pre-exist it.

(symbian) owner
  如果一个对象对另一个对象的析构负有责任(为了释放其资源),那这个对象是它的属主对象。

(OOP) package
  A set if classes associated with one anther in some way,and organised into a collection for name scoping, ease of handing ect.

(OOP) pre-emptive scheduling
  Scheduling where a thread's execution can be suspended and later resumed, under the control of the operating system.

(sysbiam) process
  进程间能共享ROM,但注意那可写的内存空间一次只能由一个进程访问。

(Symbian) R class
  封装了系统资源的类。

(UML) sequence diagram
  UML中表达消息在对象间传递的图表,一般是按垂直方向,向下流动。在sequence diagram中相同类型的消息就是一般的函数调用。

(symbian) server
  一组类或package提供一系列服务给客户。例如,communication services, timing serveres, 等。客户和服务端在不同的线程中运行甚至是不同的进程中。

(OOP) signature
  Part of the specification or declaration of a function comprising its arguments and return type.

(symbian) socket server
  这是symbian系统服务,用来管理基于socket的连接。

(symbian) T class
  表示没有析构函数的类,T代表Type

(symbian) toolbar
  The area at the right hand side of the diaplay usually containing a set of command buttons.

(symbian) two-phase construction
  这个是构造c类对象的特有方法,这样如果在构造过程总有异常发生那也不会造成内存泄漏。

(symbian) Window Server
  这是一个symbian系统线程,用来管理用户输入和屏幕显示。

原创粉丝点击