Skip to content
Jean-Michaël Celerier edited this page Sep 5, 2018 · 3 revisions

Cosmetics

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