title | description | published | date | tags |
---|---|---|---|---|
Coding Conventions and Style Guide |
Gives a brief summary of JavaScript and Python Coding Conventions and links to resources on the topic. |
true |
2021-05-05 15:14:42 UTC |
guidelines |
We will be using BEM (Block, Element, Modifer) coding conventions for HTML and CSS, with an emphasis on the Naming Conventions. Additionally, refer to BEM CSS Documentation and BEM HTML Documentation as a reference when you are coding.
Below is the basics of JavaScript coding conventions and style guides discussed in the W3 School Style Guide and JavaScript Code Convention and Best Practices articles. Make sure to read those two articles, and come back to them when you have questions.
- Write variable and function names in camelCase.
- All names have to start with a letter.
- Always put spaces around operators and after commas.
- Indent code blocks by 2 spaces.
- Put the opening bracket of a function at the end of the first line and use one space before the opening bracket.
- Put the closing bracket of a function on a new line.
- Use colon and one space (newline) between each property and the value of an object. If an object is short, the properties and values can be written in one line.
- For the sake of readability, avoid lines longer than 80 characteres.
Naming Conventions:
- Global variable and constants are written in UPPERCASE
MAX_VALUE = “1000”
- Number - name it based on the value it represents
var age = 10;
- String - same as above
var location = "Salt Lake City";
- Boolean - asks a yes/no question
var isTheRealSlimShady = true;
- Function - verb or action word/phrase describing its job
var capitalizeLetters = function (letter) {return letter.toUppercase()};
- Array - Plural word describing its contents
var instruments = ["guitar", "drums", "bass", "keyboard"];
- Object - Singular word describing what it represents
var animal = {type: "cow"})
PEP 8 is a style guide for Python code. We follow the PEP 8 guidelines to write more readable code.
Make sure to read PEP 8: The Style Guide for Python Code before coding.