Quality Management:Quality manual/Work instructions/JavaScript coding standard: Difference between revisions
(Created page with "This document is not released - Draft version only This coding standard is used for all JavaScript programming. That is, but not limited to, JavaScript and extensions to Dojo, Y...") |
No edit summary |
||
Line 12: | Line 12: | ||
All released java scripts must be validated by JSLint.com or similar tools, However, the following exceptions are allowed: | All released java scripts must be validated by JSLint.com or similar tools, However, the following exceptions are allowed: | ||
• It is not recommended to use the “ (??) | • It is not recommended to use the “ (??) | ||
Any | Any exception shall be explained in the comments to the actual code line. | ||
Furthermore, the script shall be run in Firefox and verified in the error console [[Firebug]]. [[tools, error console]] | |||
===File header=== | ===File header=== | ||
All source files must contain a file header with informations specified by the procedure for [[QM:Quality_manual/Procedures/Control_of_documents|Control of Documents]]. An practical example may be found below:[[#Document History]]. Text to copy into the source file may be found here:[[QM:Quality_manual/Work_instructions/Source file header|Source file header]]. | All source files must contain a file header with informations specified by the procedure for [[QM:Quality_manual/Procedures/Control_of_documents|Control of Documents]]. An practical example may be found below:[[#Document History]]. Text to copy into the source file may be found here: [[QM:Quality_manual/Work_instructions/Source file header|Source file header]]. | ||
Line 28: | Line 27: | ||
<syntaxhighlight lang="JavaScript"> | <syntaxhighlight lang="JavaScript"> | ||
<script type="text/javascript"> | |||
var Person = function(name){ | var Person = function(name){ | ||
this.name = name; | this.name = name; | ||
} | |||
var eljefe = new Person (Peter Stig Andersen); | var eljefe = new Person ('Peter Stig Andersen'); | ||
print(eljefe.name); | print(eljefe.name); | ||
</script> | |||
</syntaxhighlight> | </syntaxhighlight> | ||
This is to avoid programming errors where the lack of "new" would lead to use/modification of the global context. | This is to avoid programming errors where the lack of "new" would lead to use/modification of the global context. | ||
==Dojo== | ==Dojo== |
Revision as of 18:11, 13 April 2011
This document is not released - Draft version only
This coding standard is used for all JavaScript programming. That is, but not limited to, JavaScript and extensions to Dojo, YUI, jQuery and Prototype.
The scope of this document is to define coding standards related to the JavaScript language. Review and quality control is not covered herein. Please refer to Review procedure.
JavaScript
This document is under preparation, the following areas should be covered:
- xxx
Validation
All released java scripts must be validated by JSLint.com or similar tools, However, the following exceptions are allowed: • It is not recommended to use the “ (??) Any exception shall be explained in the comments to the actual code line.
Furthermore, the script shall be run in Firefox and verified in the error console Firebug. tools, error console
File header
All source files must contain a file header with informations specified by the procedure for Control of Documents. An practical example may be found below:#Document History. Text to copy into the source file may be found here: Source file header.
Function names
All functions names starts with low-case.
Constructor
The variable name of variable containing a function reference must start upper-case.
<script type="text/javascript">
var Person = function(name){
this.name = name;
}
var eljefe = new Person ('Peter Stig Andersen');
print(eljefe.name);
</script>
This is to avoid programming errors where the lack of "new" would lead to use/modification of the global context.
Dojo
References
- See all references here: References.
Document History
Version | Date | Author | Status | Purpose of update |
---|---|---|---|---|
0 | 13 Apr 2011 | PSA | Draft | New document |