Skip to content

Style Guide

Mathieu Tuli edited this page Nov 18, 2019 · 8 revisions

Code Style Guide

C++ Style Guide

Table of Contents

Follow the following guide, and for extra information not found in this readme, refer to theGoogle Style Guide

#include Hierarchy

  • Standard libraries always on top

  • Local includes below

  • Space each set of includes by an empty line

  • Order by longest include on top

  • example

#include <iostream>
#include <string>

#include "ChannelMonitor.hpp"
#include "Chanel.hpp"

Tab/Spacing

2 character-long spacing (Indent 2 spaces at a time). No tabbing, make sure your IDE or text-editor or ... is set to emit spaces when you tab. example

int main(){
  int i;
  for(;;){
    i++
  }
}

Naming Conventions

  • Class Names
    • UpperCamelCase
class ThisIsAnExample
  • File Names
    • Files for Class definitions
      • UpperCamelCase for class name
ThisIsAnExample.hpp
ThisIsAnExample.cpp
  • Else
    • lowercase underscore spaced
this_is_another_example.hpp
this_is_another_example.cpp
  • Functions
    • Lowercase underscore spaced
void this_is_an_example(){}
  • Global Variables
    • All caps underscore spaced
#define THIS_IS_AN_EXAMPLE
  • Variables
    • lowercase underscore seperated
int this_is_an_example

General Notes

  • Do not use namspaces, explicitly declare them inline
    • DON'T using namespace std;
    • DO std::cout << "Hello" << std::endl;

Python Style Guide

Table of Contents

Follow the following guide, and for extra information not found in this readme, refer to theGoogle Style Guide

import Hierarchy

  • Standard libraries always on top

  • from includes above imports

  • Local includes below

  • Space each set of includes by an empty line

  • Order by longest include on top

  • example

from pathlib import Path
from example import A

import opencv
import pyqt

import local.local.local
import other.local

Tab/Spacing

4 character space tabbing, as required by Python (duh) example

def main():
    i = 0
    for i in [1, 2, 3]:
        print(i)

Naming Conventions

  • Class Names
    • UpperCamelCase
class ThisIsAnExample:
  • File Names
    • Files for Class definitions
      • UpperCamelCase for class name
ThisIsAnExample.py
  • Else
    • lowercase underscore spaced
this_is_another_example.py
  • Functions
    • Lowercase underscore spaced
def this_is_an_example:
  • Global Variables
    • All caps underscore spaced
THIS_IS_AN_EXAMPLE = 2
  • Variables
    • lowercase underscore seperated
this_is_an_example = 1

Clone this wiki locally