Skip to content

Instantly share code, notes, and snippets.

@fd
Last active December 12, 2015 06:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fd/4731002 to your computer and use it in GitHub Desktop.
Save fd/4731002 to your computer and use it in GitHub Desktop.
Mr. Henry - Code Style document

Mr. Henry - Code Style document

=> YOU MUST FOLLOW THIS RULE.
=> YOU MUST NEVER, EVER DO THIS.

General

Variable names

✓ — Variable names should NEVER be acronims.

✓ — They must scale with the lifetime of the value.

Short lifetime:

  • loop index counters can be called (i, j, k)
for (var i = 0; i < 100; i++) {
  # ...
}

Long lifetime:

  • global variables
  • constants
  • class/module names
  • method names
  • variable names inside methods/functions

Javascript

✓ — Always end statements with a colon

console.log("Hello World");

✓ — Always declare your variables with the var statement.

var my_nice_and_descriptive_variable = "Hello World";

✓ — When working on a Mr. Henry project, ALWAYS use Hanging Gardens to manage your javascript dependencies.

✗ — Never use global variables. (I, @fd, will make you suffer if you do.)

✗ — Never include micro-jQuery-plugins. If you can write it in 20 LOC, write it your self.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment