Changes between Version 5 and Version 6 of CodingStyle
- Timestamp:
- Dec 22, 2007, 5:26:26 PM (17 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
CodingStyle
v5 v6 8 8 * If a function becomes longer than 100 lines or so, split it up. 9 9 * If a file is becoming 'landfill', split it up. 10 * C++ .hfiles often contain both interface and implementation. Clearly divide these.10 * C++ `.h` files often contain both interface and implementation. Clearly divide these. 11 11 12 12 === Code documentation === 13 13 14 * .Cfiles have a comment at the top saying what's in the file (and perhaps what isn't).14 * `.C` files have a comment at the top saying what's in the file (and perhaps what isn't). 15 15 * Functions are preceded by a comment saying what they do. 16 * Structs and classes are preceded by a comment saying what they are.16 * structs and classes are preceded by a comment saying what they are. 17 17 18 18 === Naming === … … 86 86 === Includes === 87 87 88 * A .Cfile should have the minimum set of #includes to get that particular file to compile (e.g. the includes needed by {{{foo.C}}} should be in {{{foo.C}}}, not {{{foo.h}}}).88 * A `.C` file should have the minimum set of #includes to get that particular file to compile (e.g. the includes needed by {{{foo.C}}} should be in {{{foo.C}}}, not {{{foo.h}}}). 89 89 * Includes should be ordered from general (`<stdio.h>`) to specific (`thisfile.h`). 90 90 … … 105 105 === Things to avoid === 106 106 107 * Use {{{typedef}}} (not {{{#define}}}) to define types.108 * Don't use {{{memset()}}} or {{{memcpy()}}} to initialize or copy classes that are non-C compatible. Write a default constructor and a copy constructor.107 * Use `typedef` (not `#define`) to define types. 108 * Don't use `memset()` or `memcpy()` to initialize or copy classes that are non-C compatible. Write a default constructor and a copy constructor instead. 109 109 110 110 === Error codes ===