Writing code - northern-bites/nbites GitHub Wiki

You are part of a large team now so all of the bad habits you have developed in writing code for yourself have to disappear. It simply is not ok to write bad code anymore (unless we are in the middle of competition and desperately need a quick hack). You can find all kinds of writing on the net about writing good code (e.g linux kernel style ) Go read them all . . . good.

Among the things that we require is that you write according to the Northern Bites style.

  • We use the K&R style of coding with only one exception
  • Unlike K&R we use 4 spaces and no tabs for indentation. Please set your text editor to
    • Auto-expand tabs
    • Smart indent, using 4 spaces
    • NOTE: many editors (i.e. emacs) will pretend that tabs are spaces.
    • Highlight trailing whitespace. When you see this, delete it!
    • DON’T INDENT NAMESPACES. Please.
  • We have an emacs configuration file set up for this already here . Save this file in your home folder as .emacs and everything should be taken care of.
  • Compound statements should always be bracketed, even one liners. It saves debugging errors later, especially by someone that didn’t write the original code.
  • Stick to one statement per line.
  • Avoid extraneous white space. Which isn’t to say “don’t use white space” it is to say don’t have loads of blank lines where they do not have a good purpose.
  • Keep your lines under 80 characters. You might have a nice big monitor, but not everyone else does.

Don’t forget that comments are not the only form of documentation. Use resources like this Wiki to help explain tricky parts of the code. You can also add text files to the code base to explain things. When writing documentation consider including information you would want to know if you joined the team the next day.

⚠️ **GitHub.com Fallback** ⚠️