Skip to content

Latest commit

 

History

History
64 lines (53 loc) · 2.56 KB

coding-conventions-and-style-guides.md

File metadata and controls

64 lines (53 loc) · 2.56 KB
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

HTML and CSS Style Guide

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.

JavaScript Style Guide

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.

JavaScript Style Guide Basics

  1. Write variable and function names in camelCase.
  2. All names have to start with a letter.
  3. Always put spaces around operators and after commas.
  4. Indent code blocks by 2 spaces.
  5. Put the opening bracket of a function at the end of the first line and use one space before the opening bracket.
  6. Put the closing bracket of a function on a new line.
  7. 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.
  8. For the sake of readability, avoid lines longer than 80 characteres.

Naming Conventions:

  1. Global variable and constants are written in UPPERCASE
MAX_VALUE = “1000”
  1. Number - name it based on the value it represents
var age = 10;
  1. String - same as above
var location = "Salt Lake City";
  1. Boolean - asks a yes/no question
var isTheRealSlimShady = true;
  1. Function - verb or action word/phrase describing its job
var capitalizeLetters = function (letter) {return letter.toUppercase()};
  1. Array - Plural word describing its contents
var instruments = ["guitar", "drums", "bass", "keyboard"];
  1. Object - Singular word describing what it represents
var animal = {type: "cow"})

Python Style Guide

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.