From Manta Wiki
Jump to: navigation, search

Coding Guidelines

  • Code should compile.
    • In the future, we may be adding "build tests" that run asynchronously.
  • Code should be warning free with all warnings turned on. For certain compilers some specific warnings have been turned off by default.
  • Indentation should be 2 spaces.
    • Emacs: (setq c-basic-offset 2) (set-default 'tab-width 2)
    • XCode: Preferences->Indentation, Tab Width: 2, Indent width: 2.
  • Code should be tab free.
    • To disable tabs in emacs, please use:(setq indent-tabs-mode nil)
    • XCode has options to use spaces instead of tabs. Go to Preferences->Indentation. Uncheck the "Tab key inserts tab, not spaces" option.
  • Code should be kept under 80 characters wide where possible. This isn't saying you can't have code that is longer, but try to avoid it. The most typical places are function parameters.
  • Code should be used.
  • Code should never call exit
    • Manta is designed to build as a library. Calling exit brings down the entire process and so is considered bad behavior. Instead use throw InternalError defined in SCIRun/Code/Exceptions/InternalError.h
  • Capitalization should be:
    • FirstLetterUpcase: classes, structs, named enums, typedefs
    • firstLetterLowcase: function names
    • lower_case_underscore: varabile names, constants
    • ALL_UPCASE: macro and other preprocessor code
  • Comments in the code that signify a TODO or special note should be written like below, so that other developers can quickly see who should be responsible for the comment and code it pertains to.
// TODO(name)
// NOTE(name)