Coding Standards - NazmulMahadi/cse327 GitHub Wiki
• Use meaningful names
• we use camelCase for variable names.
• All names start with a letter.
• Global variables will be written in UPPERCASE.
• Do not start names with a $ sign. It will put you in conflict with many JavaScript library names.
Example: sumOfTheMoney,
listOfBooks.
• Constant name will follow pascal case
Example: SomeVar
Method name should in camelCase.
Example:
let number = '23.32';
let result = parseInt(number);
console.log(result); // 23
Here, the parseInt() method of Number object is used to convert numeric string value to an integer value.
Class names should normally use the Pascal Casing method.
EXAMPLE:
class MyAge:
....x = 23
General rules for object definitions:
- Place the opening bracket on the same line as the object name.
- Use colon plus one space between each property and its value.
- Use quotes around string values, not around numeric values.
- Do not add a comma after the last property-value pair.
- Place the closing bracket on a new line, without leading spaces.
- Always end an object definition with a semicolon.
Example:
const person = {
..firstName: "John",
..lastName: "Doe",
..age: 50,
..eyeColor: "blue"
};
Package or module name should in lower case. For multiple words use underscores between them.
All line should be less than 100 characters
Use 2 spaces per indentation level.
show(parameters,
..aligned,
..one,
..after,
..another)
{
// ...
}
General rules for simple statements:
Always end a simple statement with a semicolon.
Always put spaces around operators ( = + - * / ), and after commas:
Examples:
let x = y + z;
const myArray = ["Volvo", "Saab", "Fiat"];