You are currently viewing a snapshot of www.mozilla.org taken on April 21, 2008. Most of this content is highly out of date (some pages haven't been updated since the project began in 1998) and exists for historical purposes only. If there are any pages on this archive site that you think should be added back to www.mozilla.org, please file a bug.



Best C++ Practices in Mozilla

What is this document?

This document is a collection of guidelines that represent the `best practices' for contributing C++ code to Mozilla. Code that follows these guidelines is more likely to be accepted into the tree. Contributors who consistently follow these practices are more likely to be granted CVS write access.

Document Status

Unfinished. I'm still adding the main content, and expecting input from reviewers@mozilla.org, et al.

Introduction

Four closely related guidelines:

make it clear

write code that is clear and obvious to the human beings who will read it; foster understanding

no surprises

write code that keeps its promises; avoid misleading interfaces

do the simplest thing that can possibly work

simple answers work sooner and last longer; start with the right algorithm and/or structure, but profile before optimizing

don't re-invent the wheel

leverage existing code; avoid reimplementation

Names

We currently use the naming convention described in New Layout: Coding Conventions.

Portability and Language Features

We currently avoid the language features proscribed in the C++ portability guide.


Bibliography

web resources

Until this document gets a little more filled out, here are the C++ guidelines we've been living with.

New Layout: Coding Conventions

C++ portability guide

The Complete nsCOMPtr User's Manual

books

Effective C++ CD: 85 Specific Ways to Improve Your Programs and Designs

by Scott Meyers. ISBN 0-201-31015-5.

Effective C++: 50 Specific Ways to Improve Your Programs and Designs (2nd ed)

by Scott Meyers. ISBN 0-201-92488-9.

More Effective C++: 35 New Ways to Improve Your Programs and Designs

by Scott Meyers. ISBN 0-201-63371-X.

Exceptional C++

by Herb Sutter. ISBN 0-201-61562-2.