For support and discussion:

This document describes some dos and don'ts when writing an interface in IDL for Mozilla. For a complete guide, see the How To Freeze document.

Rule: Use camel case for naming.
All methods and attributes should begin with a lowercase letter. Every subsequent word in the method or attribute name should be capitalized. Avoid capitalizing first letters and using underscores to separate words.
Why: IDL usually follows Java and JavaScript convention, which is camel case.
In addition, the first letter of all names are promoted to upper case in C++. The C++ signature is the same whether or not the first letter is capitalized.
Rule: Use attributes wherever you are referring to a single, non-dynamic value.
Why: Scripted access to the interface is easier to read.
Combining two get/set methods into a single attribute also syntactically shows their relevance. Methods also imply some sort of action or side effect.
Rule: Avoid excessively long names, but keep them readable.
Don't abbreviate words. Avoid names that involve prepositions like "of" or "on"
Rule: Use ACString to represent ASCII strings or binary string-like data.
Why: The nsA- string classes are more efficient than the "string" type.
They include the length of the string passed in, and avoid excess allocations. They also allow for subfragments of existing strings without copying, and when assigning one string to another, the underlying buffer can often be shared.
Rule: Use AString or AUTF8String to represent unicode strings. Avoid the "wstring" type where possible.
Why: XPConnect will properly handle unicode conversion.
In addition, the nsA- string classes are more efficient than the old "wstring" type.
Rule: Avoid out parameters
Avoid them especially when a method has only one out parameter. Use the return value of a function instead.
Why: Be script friendly!
out parameters are extra work for scripts, which must create a temporary object to hold the resulting value.
Rule: Avoid excess #includes.
Try to avoid #including extra .h or .idl files unless there are constants or other declarations that are required to compile the .idl file.
Why: Excess includes increase dependencies.
A consumer of an interface does not necessarily use the full interface, and thus may not need a full declaration of every type that the interface uses.
Rule: Try to #include only other .idl files.
If you need access to a type available only in C++, try to predeclare it and rely on C++ consumers to #include the correct header.
Why: Easier maintenance of IDL files.
Generated C headers will differ from the IDL, causing confusion as to what classes have been defined. If you predeclare a type and then #include a .h file in order to get the definition, you may have problems with the generated header if the #included .h file changes later. Excessive #includes can also cause unnecessary rebuilding when a header changes.
Rule: Avoid CID and ContractID declarations in IDL or C++ interface declarations
Why: IDL is for declaring interfaces, and interfaces alone. CIDs and ContractIDs are implementation details.
Instead of putting these details in an IDL file, put them in a separate header file. The separate header file could contain all ContractIDs/CIDs for your module, or you could create a single C++ header which contains the ContractID/CID.

Original Document Information