From: Daniel Arndt Date: Thu, 28 Jun 2018 17:08:22 +0000 (+0200) Subject: Update coding conventions X-Git-Tag: v9.1.0-rc1~971^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=020f465bad7f2696067c517043551172c55bc9e2;p=dealii.git Update coding conventions --- diff --git a/doc/doxygen/headers/coding_conventions.h b/doc/doxygen/headers/coding_conventions.h index c373cb14e5..aaeb05eba5 100644 --- a/doc/doxygen/headers/coding_conventions.h +++ b/doc/doxygen/headers/coding_conventions.h @@ -100,6 +100,9 @@ executable.
  • %Function and variable names may not consist of only one or two letters, unless the variable is a pure counting index.
  • +
  • Type aliases (using-declarations) are preferred to + typedef-declarations.
  • +
  • Use the geometry information in GeometryInfo to get the number of faces per cell, the number of children per cell, the child indices of the child cells adjacent to face 3, etc, rather @@ -137,17 +140,14 @@ executable.
  • Sometimes it makes sense to implement a class by using several non-member functions that are not part of the public interface and are only meant to be called in the current source file. Such free functions should be - put in an anonymous namespace structured in the following way: + put in an internal namespace structured in the following way:
       namespace internal
       {
    -    namespace ClassName
    +    namespace ClassNameImplementation
         {
    -      namespace
    -      {
    -        // free functions go here
    -      }
    +      // free functions go here
         }
       }
       
    @@ -159,7 +159,7 @@ executable. camel case — while functions and variables use lowercase letters and underscores to separate words. - The only exception are the iterator typedefs in Triangulation + The only exception are the iterator alias in Triangulation and DoFHandler (named cell_iterator, active_line_iterator, etc) to make the connection to the standard library container classes clear.
  • @@ -353,8 +353,8 @@ we list here: too much locally. You may end up with a code of the following kind:
    -    for (cell=triangulation.begin(); ...)
    -      for (face=0; ...)
    +    for (const auto &cell = triangulation.active_cell_iterators())
    +      for (unsigned int face=0; ...)
             {
               if (something)
                 { ... }
    @@ -389,11 +389,13 @@ we list here:
         {
           Point cell_center;
           ... // something lengthy and complicated
    -      for (cell = dof_handler.begin_active(); ...)
    +      for (const auto &cell = dof_handler.active_cell_iterators())
             {
               cell_center = (cell->vertex(0) + cell->vertex(1)) / 2;
               ...
             }
    +      ...
    +    }
       
    The problem is that if the code between the declaration and initialization @@ -409,11 +411,13 @@ we list here: void foo () { ... // something lengthy and complicated - for (cell = dof_handler.begin_active(); ...) + for (const auto &cell = dof_handler.active_cell_iterators()) { Point cell_center = (cell->vertex(0) + cell->vertex(1)) / 2; ... } + ... + }
    This makes it much clearer what the type of the variable is @@ -444,12 +448,14 @@ we list here: void foo () { ... // something lengthy and complicated - for (cell = dof_handler.begin_active(); ...) + for (const auto &cell = dof_handler.active_cell_iterators()) { const Point cell_center = (cell->vertex(0) + cell->vertex(1)) / 2; ... } + ... + }
    By marking the variable as constant we make sure that we don't accidentally @@ -479,7 +485,7 @@ we list here: typename Triangulation::cell_iterator CellAccessor::child (const unsigned int child_no) { - ...; + ... return something; }