From 020f465bad7f2696067c517043551172c55bc9e2 Mon Sep 17 00:00:00 2001 From: Daniel Arndt Date: Thu, 28 Jun 2018 19:08:22 +0200 Subject: [PATCH] Update coding conventions --- doc/doxygen/headers/coding_conventions.h | 32 ++++++++++++++---------- 1 file changed, 19 insertions(+), 13 deletions(-) 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; } -- 2.39.5