Skip to content

Latest commit

 

History

History
executable file
·
46 lines (34 loc) · 1.54 KB

File metadata and controls

executable file
·
46 lines (34 loc) · 1.54 KB

JsLingua Coding Convention

File naming

  • All the modules must be in the racine
  • Each language has a folder with 3 letters: ara, eng, fra, jpn, etc.
  • In each, the name of each implementation must be: ..js. Example: ara.morpho.js
  • All minuscule

Modules

  • Class names starts with Majuscule. e.g. Morpho.
  • Class names for implementations are CamelCase, starting with language code then module name. e.g. AraMorho.
  • A module exports a class, which we can then instantiate.

Variables

  • their names are camelCase
  • use always "let"; no "var" NOOOOOOO "var" I repeat
  • if they are local, they can be long (since, they can be shorten using uglify-js)
  • if they are bounded to the class, keep them short (eg, this.result ==> this.res)

Constantes

  • their names: MAJ_LIKE_THIS
  • use "const", no "var", I repeat: no "var"

Functions

  • their names camelCase
  • if the function is private, its name's length doesn't matter
  • if it is protected, shorten
  • if it is public, use two versions: short and long (the long one just uses the short)
  • the shortened functions are all minuscule
  • if they are private (local) start with " __ "
  • if they are protected, start with " _ "

Here a list of function beginnings in shorten version:

  • l: list available values. For example, to list available stemming methods: Morpho.lstem()
  • n: new. For example: JsLingua.nserv("morpho", "eng").
  • g: get. Fore example: engMorpho.gstemdesc("porter");
  • s: set. For example: engMorpho.sstem("porter");
  • a: add a method. Usually, the function is protected