Skip to content
Jean-Michaël Celerier edited this page Jan 7, 2017 · 3 revisions

Cosmetics

  • Indentation : 2 spaces.
  • Classes & structs naming : lower_case_with_underscores.
  • Files naming : like_this.hpp, like_that.cpp.
  • Public member naming : lowerCase.
  • Private member naming : m_lowerCase.

General

  • Use modern C++ features where it makes sense and makes the code cleaner.
  • Try to use value semantics and pass-by-reference most of the time.
  • Try to limit the use of pointers, when it is necessary use std::unique_ptr unless a problem specifically calls for std::shared_ptr.
  • Try to limit inheritance, and especially the use of virtual functions.
  • If a virtual function makes sense, don't forget to :
    • Make the destructor virtual.
    • Put the destructor implementation in a .cpp file.
  • Use variant for closed polymorphism (when you know all the types from the beginning).
  • Use string_view when a function works on strings without storing them, and use std::string for storing.
  • Use optional when parsing something or when a function may not always yield a result.
Clone this wiki locally