A guide for programming in style.
Use Hound to automatically review your GitHub pull requests for style guide violations.
In addition to the general guidelines below, we also have the following more detailed, language/framework-specific style guides:
- Android
- Backbone
- CoffeeScript
- Ember.js
- ERb
- Git
- Haskell
- HTML
- JavaScript
- Objective-C
- Python
- Rails
- Ruby
- Sass
- Shell
- Swift
- Testing
- Avoid inline comments.
- Break long lines after 80 characters.
- Delete trailing whitespace.
- Don't misspell. Example.
- Use empty lines around multi-line blocks.
- Use spaces around operators, except for unary operators, such as
!
. - Use Unix-style line endings (
\n
). - Use uppercase for SQL key words and lowercase for SQL identifiers.
- Avoid abbreviations.
- Avoid object types in names (
user_array
,email_method
CalculatorClass
,ReportModule
). - Prefer naming classes after domain concepts rather than patterns they
implement (e.g.
Guest
vsNullUser
,CachedRequest
vsRequestDecorator
). - Name the enumeration parameter the singular of the collection.
- Name variables, methods, and classes to reveal intent.
- Treat acronyms as words in names (
XmlHttpRequest
notXMLHTTPRequest
), even if the acronym is the entire name (class Html
notclass HTML
).
- Order methods so that caller methods are earlier in the file than the methods they call.
- Order methods so that methods are as close as possible to other methods they call.