Basic information

Welcome by the code conventions of mtdef. These code conventions are for the projects that are made by the mtdef team.


/**
 * This is a code block
 * We use these to show the code conventions
 */

If you hover with your mouse over the code block you can see which programming language it is.

We use a number of names that are known. In order to avoid any misunderstanding, we make clear what we think of some naming. You can read them at the mtdef wiki.


Class creation
function ClassName ()
{
  // Code for constructor
}

The constructor function is allways placed in at the top of the class file.
Class spacing is vieweble in the Class spacing tile.


Private variables
function ClassName ()
{
  var _isPrivate;
}

This is how we write a private variable in ECMAScript 5. Due to getters and setters we write our variable with _camelCase.

function ClassName ()
{
  this._isPrivate;
}

Due to performance we do not use truly private variables in classes. We create a public variable with private syntax.

var getPrivate = someClass._isPrivate;
someClass._isPrivate = setPrivate;

NOTE: We do not allow to call "private" variables shown as above. Even though this is possible, we want to prevent this by giving them the private syntax. This ensures that everyone knows that it is not the intention to call this variable. These variables are only used by the class they are in.


"Public" variables
function ClassName ()
{
  this.isPublic;
}

This is how we write a public variable in ECMAScript 5. Due to no bound getters and setters we write our variable with camelCase.
We prefer not to use a public but private, getters and setters


Getters and setters (class)
Object.defineProperty(ClassName, 'isPrivate0', {
  get: function() {
    return this._isPrivate0;
  },
  set: function(value) {
    this._isPrivate0 = value;
  }
});

Object.defineProperty(ClassName, 'isPrivate1', {
  get: function() {
    return this._isPrivate1;
  },
  set: function(value) {
    this._isPrivate1 = value;
  }
});

This is how we write a getter and setter in ECMAScript 5 for a "private" variable. Due to the private we write our getter and setter with camelCase.


"Private" functions
// !! Do not call these functions
ClassName.prototype._FunctionName = function ()
{
  // Code for "private" function
}

Because there is in ECMAScript 5 a way of truly private functions but due to performance. We create public functions and give theme our "private" syntax with _PascalCase.

someClass._FunctionName();

NOTE: We do not allow to call "private" functions shown as above. Even though this is possible, we want to prevent this by giving them the private syntax. This ensures that everyone knows that it is not the intention to call this function. These functions are only used by the class they are in.


"Public" functions
ClassName.prototype.FunctionName = function ()
{
  // Code for "public" function
}

For the public functions we use the public function syntax PascalCase


Static functions
ClassName.FunctionName = function ()
{
  // Code for static function
}

Because static functions are always "public" we give them the "public" PascalCase


Namespace
var NAME_SPACE = ( function()
{
  // Namespace code.

  return this;
})();
In javascript there is no special namespace syntax so we use HIGH_CASE for the naming. For spacing in a name space please view the namespace spacing tile. In namespaces we use truly private variables and functions.

Global variables
var variableExample0 = 0;

// Flag
var FLAGEXAMPLE0 = 1 << 0;  // int value 1

Almost all global variables are camelCased. Except the "constants" because they are used for flags or namespaces. Flags are using UPPERCASE unlike namespaces, they are using HIGH_CASE. Because there are no constants in ECMAScript 5 we never overwrite UPPERCASE or HIGH_CASE variables.

FLAGEXAMPLE0 = 3;

NOTE: We do not allow to overwrite "constants" variables shown as above. Even though this is possible, we want to prevent this by giving them the constant or namespace syntax. This ensures that everyone knows that it is not the intention to overwrite this variable.


Global functions
function FunctionName ()
{
  // Code for global function
}

All global functions are PascalCased


File spacing
/**
 * License: LGPL-2.1
 *  - link: https://link.to/LICENSE
 *
 *  Author: TessavWalstijn
 *  - link: https://github.com/TessavWalstijn
 */

function CLASS () {}
// ~~ OR
var NAME_SPACE = ( function() { return this; })();

In a file there is only a class or namespace.


File spacing

If in a file is not a class or namespace. Then the following spacing applies.

/**
 * License: LGPL-2.1
 *  - link: https://link.to/LICENSE
 *
 *  Author: TessavWalstijn
 *  - link: https://github.com/TessavWalstijn
 */

var CONSTEXAMPLE0 = 0,
  CONSTEXAMPLE1 = 1,
  CONSTEXAMPLE2 = 2;

function UsedInStart () {}

function Start () {}

// Only used when the functions are not called from an other file.
Start();

Class spacing
function ClassName ()
{
  this_isPrivate0;  
  this._isPrivate1;

  this.isPublic0;
  this.isPublic1;
}

Object.defineProperty(ClassName, 'isPrivate0', {
  get: function() {
    return this._isPrivate0;
  },
  set: function(value) {
    this._isPrivate0 = value;
  }
});

Object.defineProperty(ClassName, 'isPrivate1', {
  get: function() {
    return this._isPrivate1;
  },
  set: function(value) {
    this._isPrivate1 = value;
  }
});

ClassName.prototype._FunctionName3 = function () {}

ClassName.prototype._FunctionName0 () {} // Private.
ClassName.FunctionName0 () {}            // Static.
ClassName.prototype.FunctionName0 () {}  // Public.

ClassName.prototype._FunctionName1 () {} // Private.
ClassName.FunctionName1 () {}            // Static.
ClassName.prototype.FunctionName1 () {}  // Public.

More spacing information for getters, setters and functions at their own spacing tile.


Namespace spacing
var NAME_SPACE = ( function()
{
  var _isPrivate0;
  Object.defineProperty(this, 'isPrivate0', {
    get: function() {
      return _isPrivate0;
    },
    set: function(value) {
      _isPrivate0 = value;
    }
  });
  
  var _isPrivate1;
  Object.defineProperty(this, 'isPrivate1', {
    get: function() {
      return _isPrivate1;
    },
    set: function(value) {
      _isPrivate1 = value;
    }
  });

  this.isPublic0;
  this.isPublic1;

  var _FunctionName0 = function () {};
  this.FunctionName0 = function () {};
  
  var _FunctionName1 = function () {};
  this.FunctionName1 = function () {};

  return this;
})();

More spacing information for getters, setters and functions at their own spacing tile.


Function spacing

// One line functions.
function FunctionName () { /* Only used for short functions */ }

// Multiline functions.
function FunctionName ()
{
  /*
   * From 2 lines and max 15 lines (comments are not counted).
   * The braces are below the function.
   */
}

// One line parameters are at max of 3.
// These functions have the braces behind the function
function FunctionName (param0, param1, param2) { /* One line function */ }

function FunctionName (param0, param1, param2)
{
  /* Multiline function */
}

// Multiline parameters are from 3 parameters.
function FunctionName (
  param0,
  param1,
  param2,
  param3
) { /* One line function */ }

function FunctionName (
  param0,
  param1,
  param2,
  param3
) {
  /* Multiline function */
}

Functions are always spaced between them. Except when they are static and the same function. View the class spacing as example


Loops spacing
// One line if with out else.
if (bool) doo = a; // Only used for short ifs

// One line if with else.
bool ? doo = a : doo = b;

// Multiline ifs.
// These ifs have the braces behind the if. (with out else)
if (bool) {
  /*
  * From 2 lines and max 5 lines (comments are not counted).
  * The braces are after the if.
  * When the lines are 5+ then we move them to a function and apply the one line if.
  */
}

// One line checks are at max of 3.
if (bool0 && bool1 || bool2) doo = a; //One line if

if (bool0 && bool1 || bool2) {
  /* Multiline if */
}

// One line checks are at max of 3.
if (bool0 && bool1 || bool2) doo = a; //One line if
else doo = b; //One line else

// When the one line if is to long we break them up like this:
if (bool0 && bool1 || bool2)
  do_a_lot_of_stuf = option_of_stuf_A;
else
  do_a_lot_of_stuf = option_of_stuf_B

(bool0 && bool1 || bool2)
  ? do_a_lot_of_stuf = option_of_stuf_A
  : do_a_lot_of_stuf = option_of_stuf_B;

// These ifs have the braces behind the if. (with else)
if (bool0 && bool1 || bool2) {
  /* Multiline if */
} else doo = b; //One line else

// These ifs have the braces behind the if and else.
if (bool0 && bool1 || bool2) {
  /* Multiline if */
} else { 
  /* Multiline else */
}

// Multiline checks are from 3 parameters. (official not an one line if)
if (
  bool0 &&
  bool1 ||
  bool2 &&
  bool3
) doo = a; //One line if

if (
  bool0 &&
  bool1 ||
  bool2 &&
  bool3
) {
  /* Multiline if */
}

// One exeption for multiline checks.
(bool0 && bool1 || bool2 && bool3)
  ? do_a_lot_of_stuf = option_of_stuf_A
  : do_a_lot_of_stuf = option_of_stuf_B;

If statements are always spaced between them.


Switch spacing

When a if statement has one check and more then 2 elses we switch the if to an switch.

switch (expression) {
  case 0:
    /* code block */
    break;
  case 1:
  case 2:
  case 3:
    /* code block */
    break;
  case 4:
    /* code block */
    break;
  default:
    /* code block */
    break;
}

Loops spacing
var MAX = 10;
  
// One line forLoop.
for (var i = 0; i < MAX; i++)
  console.log(i); // One line forLoop

// Multiline forLoop.
for (var i = 0; i < MAX; i++) {
  /*
  * From 2 lines and max 5 lines (comments are not counted).
  * The braces are after the forLoop.
  * When the lines are 5+ then we move them to a function.
  */
}

// doWhileLoop is never one lined.
var i = 0;
do {
  /*
  * From 2 lines and max 5 lines (comments are not counted).
  * The braces are after the doWhileLoop.
  * When the lines are 5+ then we move them to a function.
  */
} while (i < MAX);

// whileLoop
var n = 0;
while (n < 3) {
  /*
  * From 2 lines and max 5 lines (comments are not counted).
  * The braces are after the whileLoop.
  * When the lines are 5+ then we move them to a function.
  */
}

// One line forInLoop
for (variable in object)
  /* statement */;

// Multiline forInLoop
for (variable in object) {
  /*
  * From 2 lines and max 5 lines (comments are not counted).
  * The braces are after the forInLoop.
  * When the lines are 5+ then we move them to a function.
  */
}

Loop statements are always spaced between them.


Variables spacing
// If you have multiple variables with one type we declare once that type for that section code
var variableExample0 = 0,
  variableExample1 = 1,
  variableExample2 = 2;

// Flag
var FLAGEXAMPLE0 = 1 << 0, // int value 1
  FLAGEXAMPLE1 = 1 << 1,   // int value 2
  FLAGEXAMPLE2 = 1 << 2;   // int value 4

Almost all global variables are camelCased. Except the "constants" because thay are used for flags or namespaces. Flags are using UPPERCASE unlike namespaces, they are using HIGH_CASE.

FLAGEXAMPLE0 = 3;

NOTE: We do not allow to overwrite "constants" variables shown as above. Even though this is possible, we want to prevent this by giving them the constant or namespace syntax. This ensures that everyone knows that it is not the intention to overwrite this variable.


Getter and Setter spacing
/* ~~ The following code is in one of the following objects:
 * ~~ Class
 * ~~ Namespace
 *    ?? Our own namespace syntax
 * ~~ Object      
 *    ?? Like the basic `obj = new Object` or `obj = {}`
 */

// One lined getter and setter.
get isPrivate0 () { return this._isPrivate0; }
set isPrivate0 (value) { this._isPrivate0 = value; }

// Multiline getter and setter.
get isPrivate1 () {
  // Code for getter.
  return this._isPrivate1; 
}
set isPrivate1 (value) {
  // Code for setter.
  this._isPrivate1 = value; 
}

// If it is posible we want that the accompanying "private" variable with the getters and setters.
/* First variable    */ this._isPrivate2;
/* Second getter     */ get isPrivate2() { return this._isPrivate2; }
/* As a third setter */ set isPrivate2(value) { this._isPrivate2 = value; }

Between various getters and setters there is a white space. Unlike the accompanying getters, setters and if possible the accompanying "private" variable.


Comments spacing / styling
/**
 * File:       file.name with basic information
 *  - version: [release state abbreviation] v[version code]
 *  - note:    more information about the file
 *
 * License:    [license abbreviation like: LGPL-2.1]
 *  - link:    https://link.to/LICENSE
 *
 * Author:     TessavWalstijn
 *  - link:    https://github.com/TessavWalstijn
 */

// One line comment.

/* One line block comment. */

// Multiline lined comment.
// Multiline lined comment.
// Multiline lined comment.

/**
 * Multiline block comment.
 * Multiline block comment.
 * Multiline block comment.
 */

/**
 * TODO This is how we write to do.
 *   -- This is how we list a todo.
 * 
 * /TODO This is a todo done.
 *    /- This is the list item done.
 */

// ## This is a non important comment.
// /# This is a lined non important comment.

// ?? This is an important question.
// /? This was an important question.

// ~~ This is an important comment.
// /~ This was an important comment.

// !! This is an warning comment.
// /! This was an warning comment.

/**
 * Summaries for a function or class.
 * @param  {string} param0 The use of the string.
 * @param  {number} param1 The use of a number or flag.
 * @param  {object} param2 The format of the object and the use of it.
 * @return {number}        What type the function returns.
 */

The styling commes from the Better Comments extension.



Comments styling settings

The styling commes from the Better Comments extension. Our better comments settings is shown here below.


"better-comments.tags": [
  {
      "tag": "/!",
      "color": "#FF2D00",
      "strikethrough": true
  },
  {
      "tag": "!!",
      "color": "#FF2D00",
      "strikethrough": false
  },
  {
      "tag": "/?",
      "color": "#3498DB",
      "strikethrough": true
  },
  {
      "tag": "??",
      "color": "#3498DB",
      "strikethrough": false
  },
  {
      "tag": "/#",
      "color": "#474747",
      "strikethrough": true
  },
  {
      "tag": "##",
      "color": "#474747",
      "strikethrough": false
  },
  {
      "tag": "/todo",
      "color": "#FF8C00",
      "strikethrough": true
  },
  {
      "tag": "todo",
      "color": "#FF8C00",
      "strikethrough": false
  },
  {
      "tag": "/-",
      "color": "#FF8C00",
      "strikethrough": true
  },
  {
      "tag": "--",
      "color": "#FF8C00",
      "strikethrough": false
  },
  {
      "tag": "/~",
      "color": "#BBB",
      "strikethrough": true
  },
  {
      "tag": "~~",
      "color": "#BBB",
      "strikethrough": false
  }
]

Class creation
class ClassName
{
  constructor ()
  {
    // Code for constructor
  }
  // Code for class
}

The constructor function is allways placed in a class.
This is a function so we apply all function code confentions to it.
Class spacing is vieweble in the Class spacing tile.


Private variables
class ClassName
{
  constructor ()
  {
    let _isPrivate;
  }
  // Code for class
}

This is how we write a private variable in ECMAScript 6. Due to getters and setters we write our variable with _camelCase.

class ClassName
{
  constructor ()
  {
    this._isPrivate;
  }
  // Code for class
}

Due to performance we do not use truly private variables in classes. We create a public variable with private syntax.

let getPrivate = someClass._isPrivate;
someClass._isPrivate = setPrivate;

NOTE: We do not allow to call "private" variables shown as above. Even though this is possible, we want to prevent this by giving them the private syntax. This ensures that everyone knows that it is not the intention to call this variable. These variables are only used by the class they are in.


"Public" variables
class ClassName
{
  constructor ()
  {
    this.isPublic;
  }
  // Code for class
}

This is how we write a public variable in ECMAScript 6. Due to no bound getters and setters we write our variable with camelCase.
We prefer not to use a public but private, getters and setters


Getters and setters (class)
class ClassName
{
  constructor () {};

  get isPrivate0 () { return this._isPrivate0; } 
  set isPrivate0 (value) { this._isPrivate0 = value; }

  get isPrivate1 () { return this._isPrivate1; } 
  set isPrivate1 (value) { this._isPrivate1 = value; }

  // Code for class
}

We cluster the getters and setters that belong to a variable. This is how we write a getter and setter in ECMAScript 6 for a "private" variable. Due to the private we write our getter and setter with camelCase.


"Private" functions
class ClassName
{
  //    Code for class
  // !! Do not call these functions
  _FunctionName ()
  {
    // Code for "private" function
  }
}

Because there is in ECMAScript 6 a way of truly private functions but due to performance. We create public functions and give theme our "private" syntax with _PascalCase.

someClass._FunctionName();

NOTE: We do not allow to call "private" functions shown as above. Even though this is possible, we want to prevent this by giving them the private syntax. This ensures that everyone knows that it is not the intention to call this function. These functions are only used by the class they are in.


"Public" functions
class ClassName
{
  // Code for class
  FunctionName ()
  {
    // Code for "public" function
  }
}

For the public functions we use the public function syntax PascalCase


Static functions
class ClassName
{
  // Code for class
  static FunctionName ()
  {
    // Code for static function
  }
}

Because static functions are always "public" we give them the "public" PascalCase


Namespace
const NAME_SPACE = ( ()=>
{
  // Namespace code.

  return this;
})();
In javascript there is no special namespace syntax so we use HIGH_CASE for the naming and the type const. For spacing in a name space please view the namespace spacing tile. In namespaces we use truly private variables and functions.

Global variables
var variableExample0 = 0;

let variableExample1 = 1;

// Flag
const FLAGEXAMPLE0 = 1 << 0;  // int value 1

Almost all global variables are camelCased. Except the constants because they are used for flags or namespaces. Flags are using UPPERCASE unlike namespaces, they are using HIGH_CASE.


Global functions
function FunctionName ()
{
  // Code for global function
}

All global functions are PascalCased


File spacing
/**
 * License: LGPL-2.1
 *  - link: https://link.to/LICENSE
 *
 *  Author: TessavWalstijn
 *  - link: https://github.com/TessavWalstijn
 */

class CLASS {}
// ~~ OR
const NAME_SPACE = ( ()=> { return this; })();

In a file there is only a class or namespace.


File spacing

If in a file is not a class or namespace. Then the following spacing applies.

/**
 * License: LGPL-2.1
 *  - link: https://link.to/LICENSE
 *
 *  Author: TessavWalstijn
 *  - link: https://github.com/TessavWalstijn
 */

const CONSTEXAMPLE0 = 0,
  CONSTEXAMPLE1 = 1,
  CONSTEXAMPLE2 = 2;

function UsedInStart () {}

function Start () {}

// Only used when the functions are not called from an other file.
Start();

Class spacing
class ClassName
{
  constructor ()
  {
    this._isPrivate0;
    this._isPrivate1;

    this.isPublic0;
    this.isPublic1;
  }

  get isPrivate0 () { return this._isPrivate0; } 
  set isPrivate0 (value) { this._isPrivate0 = value; }

  get isPrivate1 () { return this._isPrivate1; } 
  set isPrivate1 (value) { this._isPrivate1 = value; }

  _FunctionName0 () {}

  _FunctionName1 () {}

  static FunctionName0 () {}
  FunctionName0 () {}

  static FunctionName1 () {}
  FunctionName1 () {}
}

More spacing information for getters, setters and functions at their own spacing tile.


Namespace spacing
const NAME_SPACE = ( ()=>
{  
  let _isPrivate0;
  Object.defineProperty(this, 'isPrivate0', {
    get: function() {
      return _isPrivate0;
    },
    set: function(value) {
      _isPrivate0 = value;
    }
  });
  
  let _isPrivate1;
  Object.defineProperty(this, 'isPrivate1', {
    get: function() {
      return _isPrivate1;
    },
    set: function(value) {
      _isPrivate1 = value;
    }
  });

  this.isPublic0;
  this.isPublic1;

  var _FunctionName0 = ()=> {};
  this.FunctionName0 = ()=> {};
  
  var _FunctionName1 = ()=> {};
  this.FunctionName1 = ()=> {};

  return this;
})();

More spacing information for getters, setters and functions at their own spacing tile.


Function spacing

// One line functions.
function FunctionName () { /* Only used for short functions */ }

// Multiline functions.
function FunctionName ()
{
  /*
   * From 2 lines and max 15 lines (comments are not counted).
   * The braces are below the function.
   */
}

// One line parameters are at max of 3.
// These functions have the braces behind the function
function FunctionName (param0, param1, param2) { /* One line function */ }

function FunctionName (param0, param1, param2)
{
  /* Multiline function */
}

// Multiline parameters are from 3 parameters.
function FunctionName (
  param0,
  param1,
  param2,
  param3
) { /* One line function */ }

function FunctionName (
  param0,
  param1,
  param2,
  param3
) {
  /* Multiline function */
}

Functions are always spaced between them. Except when they are static and the same function. View the class spacing as example


Loops spacing
// One line if with out else.
if (bool) doo = a; // Only used for short ifs

// One line if with else.
bool ? doo = a : doo = b;

// Multiline ifs.
// These ifs have the braces behind the if. (with out else)
if (bool) {
  /*
  * From 2 lines and max 5 lines (comments are not counted).
  * The braces are after the if.
  * When the lines are 5+ then we move them to a function and apply the one line if.
  */
}

// One line checks are at max of 3.
if (bool0 && bool1 || bool2) doo = a; //One line if

if (bool0 && bool1 || bool2) {
  /* Multiline if */
}

// One line checks are at max of 3.
if (bool0 && bool1 || bool2) doo = a; //One line if
else doo = b; //One line else

// When the one line if is to long we break them up like this:
if (bool0 && bool1 || bool2)
  do_a_lot_of_stuf = option_of_stuf_A;
else
  do_a_lot_of_stuf = option_of_stuf_B

(bool0 && bool1 || bool2)
  ? do_a_lot_of_stuf = option_of_stuf_A
  : do_a_lot_of_stuf = option_of_stuf_B;

// These ifs have the braces behind the if. (with else)
if (bool0 && bool1 || bool2) {
  /* Multiline if */
} else doo = b; //One line else

// These ifs have the braces behind the if and else.
if (bool0 && bool1 || bool2) {
  /* Multiline if */
} else { 
  /* Multiline else */
}

// Multiline checks are from 3 parameters. (official not an one line if)
if (
  bool0 &&
  bool1 ||
  bool2 &&
  bool3
) doo = a; //One line if

if (
  bool0 &&
  bool1 ||
  bool2 &&
  bool3
) {
  /* Multiline if */
}

// One exeption for multiline checks.
(bool0 && bool1 || bool2 && bool3)
  ? do_a_lot_of_stuf = option_of_stuf_A
  : do_a_lot_of_stuf = option_of_stuf_B;

If statements are always spaced between them.


Switch spacing

When a if statement has one check and more then 2 elses we switch the if to an switch.

switch (expression) {
  case 0:
    /* code block */
    break;
  case 1:
  case 2:
  case 3:
    /* code block */
    break;
  case 4:
    /* code block */
    break;
  default:
    /* code block */
    break;
}

Loops spacing
const MAX = 10;
  
// One line forLoop.
for (let i = 0; i < MAX; i++)
  console.log(i); // One line forLoop

// Multiline forLoop.
for (let i = 0; i < MAX; i++) {
  /*
  * From 2 lines and max 5 lines (comments are not counted).
  * The braces are after the forLoop.
  * When the lines are 5+ then we move them to a function.
  */
}

// doWhileLoop is never one lined.
let i = 0;
do {
  /*
  * From 2 lines and max 5 lines (comments are not counted).
  * The braces are after the doWhileLoop.
  * When the lines are 5+ then we move them to a function.
  */
} while (i < MAX);

// whileLoop
let n = 0;
while (n < 3) {
  /*
  * From 2 lines and max 5 lines (comments are not counted).
  * The braces are after the whileLoop.
  * When the lines are 5+ then we move them to a function.
  */
}

// One line forInLoop
for (variable in object)
  /* statement */;

// Multiline forInLoop
for (variable in object) {
  /*
  * From 2 lines and max 5 lines (comments are not counted).
  * The braces are after the forInLoop.
  * When the lines are 5+ then we move them to a function.
  */
}

// One line forOfLoop
for (variable of object)
  /* statement */;

// Multiline forOfLoop
for (variable of object) {
  /*
  * From 2 lines and max 5 lines (comments are not counted).
  * The braces are after the forOfLoop.
  * When the lines are 5+ then we move them to a function.
  */
}

Loop statements are always spaced between them.


Variables spacing
// If you have multiple variables with one type we declare once that type for that section code
var variableExample0 = 0,
  variableExample1 = 1,
  variableExample2 = 2;

let variableExample3 = 3,
  variableExample4 = 4,
  variableExample5 = 5;

// Flag
const FLAGEXAMPLE0 = 1 << 0, // int value 1
  FLAGEXAMPLE1 = 1 << 1,     // int value 2
  FLAGEXAMPLE2 = 1 << 2;     // int value 4

Almost all global variables are camelCased. Except the constants because thay are used for flags or namespaces. Flags are using UPPERCASE unlike namespaces, they are using HIGH_CASE.


Getter and Setter spacing
/* ~~ The following code is in one of the following objects:
 * ~~ Class
 * ~~ Namespace
 *    ?? Our own namespace syntax
 * ~~ Object      
 *    ?? Like the basic `obj = new Object` or `obj = {}`
 */

// One lined getter and setter.
get isPrivate0 () { return this._isPrivate0; }
set isPrivate0 (value) { this._isPrivate0 = value; }

// Multiline getter and setter.
get isPrivate1 () {
  // Code for getter.
  return this._isPrivate1; 
}
set isPrivate1 (value) {
  // Code for setter.
  this._isPrivate1 = value; 
}

// If it is posible we want that the accompanying "private" variable with the getters and setters.
/* First variable    */ this._isPrivate2;
/* Second getter     */ get isPrivate2() { return this._isPrivate2; }
/* As a third setter */ set isPrivate2(value) { this._isPrivate2 = value; }

Between various getters and setters there is a white space. Unlike the accompanying getters, setters and if possible the accompanying "private" variable.


Comments spacing / styling
/**
 * File:       file.name with basic information
 *  - version: [release state abbreviation] v[version code]
 *  - note:    more information about the file
 *
 * License:    [license abbreviation like: LGPL-2.1]
 *  - link:    https://link.to/LICENSE
 *
 * Author:     TessavWalstijn
 *  - link:    https://github.com/TessavWalstijn
 */

// One line comment.

/* One line block comment. */

// Multiline lined comment.
// Multiline lined comment.
// Multiline lined comment.

/**
 * Multiline block comment.
 * Multiline block comment.
 * Multiline block comment.
 */

/**
 * TODO This is how we write to do.
 *   -- This is how we list a todo.
 * 
 * /TODO This is a todo done.
 *    /- This is the list item done.
 */

// ## This is a non important comment.
// /# This is a lined non important comment.

// ?? This is an important question.
// /? This was an important question.

// ~~ This is an important comment.
// /~ This was an important comment.

// !! This is an warning comment.
// /! This was an warning comment.

/**
 * Summaries for a function or class.
 * @param  {string} param0 The use of the string.
 * @param  {number} param1 The use of a number or flag.
 * @param  {object} param2 The format of the object and the use of it.
 * @return {number}        What type the function returns.
 */

The styling commes from the Better Comments extension.



Comments styling settings

The styling commes from the Better Comments extension. Our better comments settings is shown here below.


"better-comments.tags": [
  {
      "tag": "/!",
      "color": "#FF2D00",
      "strikethrough": true
  },
  {
      "tag": "!!",
      "color": "#FF2D00",
      "strikethrough": false
  },
  {
      "tag": "/?",
      "color": "#3498DB",
      "strikethrough": true
  },
  {
      "tag": "??",
      "color": "#3498DB",
      "strikethrough": false
  },
  {
      "tag": "/#",
      "color": "#474747",
      "strikethrough": true
  },
  {
      "tag": "##",
      "color": "#474747",
      "strikethrough": false
  },
  {
      "tag": "/todo",
      "color": "#FF8C00",
      "strikethrough": true
  },
  {
      "tag": "todo",
      "color": "#FF8C00",
      "strikethrough": false
  },
  {
      "tag": "/-",
      "color": "#FF8C00",
      "strikethrough": true
  },
  {
      "tag": "--",
      "color": "#FF8C00",
      "strikethrough": false
  },
  {
      "tag": "/~",
      "color": "#BBB",
      "strikethrough": true
  },
  {
      "tag": "~~",
      "color": "#BBB",
      "strikethrough": false
  }
]