C++ namespaces and the using namespace MyNamespace statement can confuse lupdate. It will interpret VClass::tr like MyNamespace::VClass::tr. Runtime translation of these strings will fail because of that.

Same true for variables that will not be changed after initialization.

Don’t use:

intconst*p;

Precede boolean values with words like “is” and “did”.

boolisValid;booldidSendData;

Precede getters that return values through out arguments with the word “get”.

voidgetInlineBoxAndOffset(InlineBox*&,int&caretOffset)const;

Use descriptive verbs in function names.

boolconvertToASCII(short*,size_t);

Prefer const to #define. Prefer inline functions to macros.

Macros that expand to function calls or other non-constant computation: these should be named like functions, and should have parentheses at the end, even if they take no arguments (with the exception of some special macros like ASSERT). Note that usually it is preferable to use an inline function in such cases instead of a macro.

#define, #ifdef “header guards” should be named exactly the same as the file (including case), replacing the . with a _.

Constructors for C++ classes should initialize all of their members using C++ initializer syntax. Each member (and superclass) should be indented on a separate line, with the colon or comma preceding the member on that line.

The * of the pointer is in the first column because it improves readability when considered part of the type.

Ordering of class variables and methods should be as follows:

list of friend classes

public variables

public methods

protected variables

protected methods

private variables

private methods

This allows the public interface to be easily found at the beginning of the class.

Always make class methods ‘const’ when they do not modify any class variables.

Avoid use of ‘const_cast’. When object is needed to be modified, but only const versions are accessible, create a function that clearly gives an editable version of the object. This keeps the control of the ‘const-ness’ in the hands of the object and not the user.

Function overloading should be avoided in most cases. For example, instead of: