Coding Standards - NazmulMahadi/cse327 GitHub Wiki

Naming Convention

Variable name

• 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

• Constant name will follow pascal case

Example: SomeVar

Method Name:

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 Name:

Class names should normally use the Pascal Casing method.
EXAMPLE:
class MyAge:
....x = 23

Object Rules

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 and Module Names:

Package or module name should in lower case. For multiple words use underscores between them.

Layout convention

Line Length:

All line should be less than 100 characters

Indentation:

Use 2 spaces per indentation level.
show(parameters,
..aligned,
..one,
..after,
..another)
{
// ...
}

Statement Rules

General rules for simple statements:

Always end a simple statement with a semicolon.

Spaces Around Operators

Always put spaces around operators ( = + - * / ), and after commas:

Examples:
let x = y + z;
const myArray = ["Volvo", "Saab", "Fiat"];

⚠️ **GitHub.com Fallback** ⚠️