Coding Standard - mainuzzaman/MediSolution GitHub Wiki

Coding Standards

Coding Standards for (JavaScript)

Naming Convention:

Variable Name:

Variable name should be in “lowercase” for single variable and for multiple variable “CamelCase” will be followed.

Example:
patientName
patientAge

Constants Name:

Constants are usually defined on a module level and written in all capital letters with underscores separating words.

Example:
PI
MAX_LIST

Method Name:

For Method Name, "lowercase" should be used. lowercase with words separated by underscores as necessary to improve readability.

Example:
function toCelsius(fahrenheit){
return (5 / 9) * (fahrenheit - 32);
}

Package and Module Name:

All package names will be in “lowercase” as well as module names. The name size must be short. For multiple words, “CamelCase” will be followed.

Class Name:

For Class names, we will use one convention between Pascal casing and Camel case convention.

Example:
Pascal Casing
class MyPrescription:
...pres_list= 1
Camel Case
class myPrescription:
..pres_list =1

Comments:

Comments should be complete sentences. The first word should be capitalized, unless it is an identifier that begins with a lowercase letter (never alter the case of identifiers!).

Example:

//Faulty code
//Needs to work

Exception Names: Because exceptions should be treated as classes, the naming standard for classes applies. On the other hand, you should name your exceptions with the suffix "Error" (if the exception actually is an error).\

###File Convention: HTML files should have a .html extension (.htm is allowed).
CSS files should have a .css extension.
JavaScript files should have a .js extension.

Indentation:

Use 4-space indentation and no tabs.
Example

if (this_is_one_level and
….that_is_another_level):
….do_something()

Coding Standard for HTML\CSS

Grammar

  • Each statement brace adds a gap in front of the block for readability.
  • The selector is grouped separately on a line selector.
  • Each statement should be on its own line to provide more accurate error reporting.
  • #fff is an example of a hexadecimal value that should be all lowercase. Lowercase characters are easier to recognize when scanning a page since their form is more immediately distinct.
  • Each statement is the statement : after should insert a space.
  • 0 units to the specified value to avoid, for example, with a margin: 0; instead of margin: 0px;

Example:

  • Bad CSS
    .selector, .selector-secondary, .selector[type=text]
    { padding:10px;
    margin:0px 0px 10px;
    box-shadow:0px 1px 2px #CCC,inset 0 1px 0 #FFFFFF
    }
  • Good CSS
    .selector,
    .selector-secondary,
    .selector[type="text"]
    {
    padding: 15px;
    margin-bottom: 15px;
    box-shadow: 0 1px 2px #ccc, inset 0 1px 0 #fff;
    }