diff --git a/others/guide/how to write JDito code.adoc b/others/guide/how to write JDito code.adoc index aacf74650d6e7df25e0cfc8a1496ecb193b02364..428013ecebd3dffc800ea90c9fc352fcddd94968 100644 --- a/others/guide/how to write JDito code.adoc +++ b/others/guide/how to write JDito code.adoc @@ -10,30 +10,23 @@ How to write JDito code == code structure == === vars and others (var, let) === -* declaration of variables go on top (what actually happens in JS anyway by default -> hoisting) -* you can define them later * avoid `let` as much as possible because you cannot debug these variables -Example: -[source,javascript] ----- -import("system.result"); -import("system.vars"); - -var data, cond, i, resStr; - -data = vars.get....... ----- - === brackets === -* `{` are placed at the end of the expression +* `{` are placed on a new line Example: [source,javascript] ---- -for (i = 0, i < dataLen; i++) { +for (i = 0, i < dataLen; i++) +{ //code here } + +myArray.forEach(function(item) +{ + // Do something +}); ---- === loops === @@ -44,14 +37,18 @@ Even better would be a good and describing name. Example: [source,javascript] ---- -for (i = 0, i < dataLen; i++) { - for (ii = 0, ii < dataLen[i].length; ii++) { +for (i = 0, i < dataLen; i++) +{ + for (ii = 0, ii < dataLen[i].length; ii++) + { //code... } } -for (row = 0, row < dataLen; row++) { - for (col = 0, col < dataLen[row].length; col++) { +for (row = 0, row < dataLen; row++) +{ + for (col = 0, col < dataLen[row].length; col++) + { //code... } } @@ -80,7 +77,8 @@ function CommValidationUtil(){}<1> * returns a blueprint for validation extensions; these extensions are needed for validating comm data and can be passed to other functions * @return {object} a object with properties that have a specific default value; normally you want to overwrite that value */ -CommValidationUtil.getExtensionsBlueprint = function() {<2> +CommValidationUtil.getExtensionsBlueprint = function() <2> +{ return { countryCode: null }; @@ -113,7 +111,8 @@ Definition: * @param {String} [alias=the current alias] the database alias where the condition shall be executed later (important for column types of preparedStatements) <2> * @example //TODO: add missing example <3> */ -function SqlCondition(alias) {<4> +function SqlCondition(alias) <4> +{ //setting null is only needed to provide autocomplete for the ADITO-designer this.preparedValues = null; this._init();//the properties are initalized in an extra function because init is nearly the same as resetting (clearing) the SqlConditions @@ -124,7 +123,8 @@ function SqlCondition(alias) {<4> * @param {String} cond the condition string which shall be appended * @return {Object} current SqlCondition-object */ -SqlCondition.prototype.and = function(cond) {<5> +SqlCondition.prototype.and = function(cond) <5> +{ if (!cond) return this; if (this._sqlStorage) @@ -160,7 +160,8 @@ Required parameter: alias * @example Here is an example * @class */ -function SqlCondition(alias) { +function SqlCondition(alias) +{ ... } ---- diff --git a/others/guide/instanceableLibExample.adoc b/others/guide/instanceableLibExample.adoc index 56e7760a7945b7e99403e223818663e3f2a77017..e1e1ae37b954697046e8b949cfbcde21319fc558 100644 --- a/others/guide/instanceableLibExample.adoc +++ b/others/guide/instanceableLibExample.adoc @@ -15,7 +15,8 @@ import("..."); * @example var myUtil = new UtilClass("-"); * @class */ -function UtilClass(param1) { +function UtilClass(param1) +{ // here is the constructor. // create class variables like this: this.myVariable = param1; @@ -31,7 +32,8 @@ function UtilClass(param1) { * * @return {String} a result */ -UtilClass.prototype.myFunction = function(param1, param2) { +UtilClass.prototype.myFunction = function(param1, param2) +{ return this._privateStaticFunction1(param1, param2, this.myVariable); } @@ -45,8 +47,10 @@ UtilClass.prototype.myFunction = function(param1, param2) { * @return {String} a result * @ignore */ -UtilClass.prototype._myPrivateFunction = function(param1, param2, param3) { - if(param1 && param2 && param3) { +UtilClass.prototype._myPrivateFunction = function(param1, param2, param3) +{ + if(param1 && param2 && param3) + { ... return param1 + param3 + param2; } diff --git a/others/guide/staticLibExample.adoc b/others/guide/staticLibExample.adoc index 90003eb7f69fca6763016432e1feb16d8953e47e..8e705d48912e4ebf7eea79ab5c7e7afb75c50805 100644 --- a/others/guide/staticLibExample.adoc +++ b/others/guide/staticLibExample.adoc @@ -25,7 +25,8 @@ function ExampleUtils() {} // leave this function empty! A constructor is not ne * * @return {String} a result */ -ExampleUtils.staticFunction1 = function(param1, param2) { +ExampleUtils.staticFunction1 = function(param1, param2) +{ return this._privateStaticFunction1(param1, param2, "-") } @@ -41,8 +42,10 @@ ExampleUtils.staticFunction1 = function(param1, param2) { * @return {String} a result * @ignore */ -ExampleUtils._privateStaticFunction1 = function(param1, param2, param3) { - if(param1 && param2) { +ExampleUtils._privateStaticFunction1 = function(param1, param2, param3) +{ + if(param1 && param2) + { ... return param1 + param3 + param2; }