diff options
author | jthorn <jthorn@f88db872-0e4f-0410-b76b-b9085cfa78c5> | 2003-06-02 20:15:20 +0000 |
---|---|---|
committer | jthorn <jthorn@f88db872-0e4f-0410-b76b-b9085cfa78c5> | 2003-06-02 20:15:20 +0000 |
commit | 2d8f80e283c0ac51dce4c3a1055bbd1b7aca77b8 (patch) | |
tree | 5b5932e5953908c986f93d90fbc639230f780456 /src/CODESTYLE | |
parent | 76b2060996e7b58d1257f3ca078cb4b00d514b5b (diff) |
explain my code style a bit more
git-svn-id: http://svn.einsteintoolkit.org/cactus/EinsteinAnalysis/AHFinderDirect/trunk@1090 f88db872-0e4f-0410-b76b-b9085cfa78c5
Diffstat (limited to 'src/CODESTYLE')
-rw-r--r-- | src/CODESTYLE | 39 |
1 files changed, 33 insertions, 6 deletions
diff --git a/src/CODESTYLE b/src/CODESTYLE index 56be3ea..10488a3 100644 --- a/src/CODESTYLE +++ b/src/CODESTYLE @@ -1,6 +1,6 @@ AHFinderDirect Code Style ========================= -$Header: /usr/local/svn/cvs-repositories/numrelcvs/AEIThorns/AHFinderDirect/src/CODESTYLE,v 1.2 2003-05-06 15:43:54 jthorn Exp $ +$Header: /usr/local/svn/cvs-repositories/numrelcvs/AEIThorns/AHFinderDirect/src/CODESTYLE,v 1.3 2003-06-02 20:15:20 jthorn Exp $ This file documents some general programming conventions used in this thorn. @@ -60,9 +60,33 @@ if (condition) ... surrounding code while (condition) { - ... body of while loop + ... loop body } +... surrounding code + for (int i = 0 ; i < N ; ++i) + { + ... loop body + } + +... surrounding code +// if there are multiple for-loops in the same scope using the same +// loop variable, I add extra (redundant) { } around the loops so the +// code will compile unchanged under both the archaic and the modern +// for-loop declaration scope rules + { + for (int i = 0 ; i < N ; ++i) + { + ... loop #1 body + } + } + { + for (int i = 0 ; i < N ; ++i) + { + ... loop #2 body + } + } + All switch statements should have a default: case (which often just does an error_exit()). @@ -135,16 +159,19 @@ C++ Classes and Libraries All the main data structures are C++ classes, but there are also plenty of C-style structs. struct foo is for "dumb data", and has at most -contructors. class foo is for full-fledged C++ classes; these have -no public data members. C++ class data members have names with a -trailing underscore; no other identifiers in this thorn have such names. +contructors. + +class foo is for full-fledged C++ classes; these have no public data +members. data members are always declared at the end of the class, and +have names with a trailing underscore; no other identifiers in this thorn +have such names. Most "large" classes are non-copyable and non-assignable. Right now I write this explicitly in each class; once compilers improve a bit more and boost becomes more widely deployed it would be cleaner to convert this to inheriting from boost::noncopyable. -In the same genre, once compilers imprive a *lot* more :), most/all +In the same genre, once compilers improve a *lot* more :), most/all of the raw new[]-array references should probably be converted to boost::array, and my jtutil::array[1234]d<> classes should be converted to boost::multi_array. |