<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Recent changes to JavaScriptGuidelines</title><link>https://sourceforge.net/p/tradamus/wiki/JavaScriptGuidelines/</link><description>Recent changes to JavaScriptGuidelines</description><atom:link href="https://sourceforge.net/p/tradamus/wiki/JavaScriptGuidelines/feed" rel="self"/><language>en</language><lastBuildDate>Tue, 06 Oct 2015 19:56:36 -0000</lastBuildDate><atom:link href="https://sourceforge.net/p/tradamus/wiki/JavaScriptGuidelines/feed" rel="self" type="application/rss+xml"/><item><title>JavaScriptGuidelines modified by Domhnall101</title><link>https://sourceforge.net/p/tradamus/wiki/JavaScriptGuidelines/</link><description>&lt;div class="markdown_content"&gt;&lt;pre&gt;&lt;/pre&gt;
&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Domhnall101</dc:creator><pubDate>Tue, 06 Oct 2015 19:56:36 -0000</pubDate><guid>https://sourceforge.netbce3945ab3576668e307030e34471321c4d9e227</guid></item><item><title>JavaScript Guidelines modified by Patrick</title><link>https://sourceforge.net/p/tradamus/wiki/JavaScript%2520Guidelines/</link><description>&lt;div class="markdown_content"&gt;&lt;h2 id="javascript-guidelines"&gt;JavaScript Guidelines&lt;/h2&gt;
&lt;h3 id="files"&gt;Files&lt;/h3&gt;
&lt;p&gt;A JavaScript file should start with a copyright header of this form (same as Java files):&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span class="cm"&gt;/*&lt;/span&gt;
&lt;span class="cm"&gt; * Copyright 2011-2014 Saint Louis University. Licensed under the&lt;/span&gt;
&lt;span class="cm"&gt; * Educational Community License, Version 2.0 (the &amp;quot;License&amp;quot;); you may&lt;/span&gt;
&lt;span class="cm"&gt; * not use this file except in compliance with the License. You may&lt;/span&gt;
&lt;span class="cm"&gt; * obtain a copy of the License at&lt;/span&gt;
&lt;span class="cm"&gt; *&lt;/span&gt;
&lt;span class="cm"&gt; * http://www.osedu.org/licenses/ECL-2.0&lt;/span&gt;
&lt;span class="cm"&gt; *&lt;/span&gt;
&lt;span class="cm"&gt; * Unless required by applicable law or agreed to in writing,&lt;/span&gt;
&lt;span class="cm"&gt; * software distributed under the License is distributed on an &amp;quot;AS IS&amp;quot;&lt;/span&gt;
&lt;span class="cm"&gt; * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express&lt;/span&gt;
&lt;span class="cm"&gt; * or implied. See the License for the specific language governing&lt;/span&gt;
&lt;span class="cm"&gt; * permissions and limitations under the License.&lt;/span&gt;
&lt;span class="cm"&gt; */&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;While many JavaScript files may be needed during development, these should be consolidated and minified where appropriate. In single page applications, all local code should be delivered in one call, in plugin or diverse applications, a more modular approach may be reasonable.&lt;/p&gt;
&lt;h3 id="libraries"&gt;Libraries&lt;/h3&gt;
&lt;p&gt;Libraries may fall into a variety of categories, but in every case a hosted version is preferred with a local backup if necessary. When possible, a minified version should be used.&lt;/p&gt;
&lt;h4 id="external-libraries"&gt;External Libraries&lt;/h4&gt;
&lt;p&gt;When choosing an external library several conditions must be met:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;The file is tested and established: any developer putting the responsibility of functionality onto third-party code must be prepared to defend the need and maintainability of the choice&lt;/li&gt;
&lt;li&gt;Most of the library is needed: including an entire library for a minor piece of functionality puts too much of a burden on the end user and may affect maintainability if it is later dropped from the core development&lt;/li&gt;
&lt;li&gt;There are no licensing conflicts: while rarely a problem, some 'public' libraries are released with specific terms that will not allow the free incorporation into our projects&lt;/li&gt;
&lt;/ol&gt;
&lt;h4 id="internal-libraries"&gt;Internal Libraries&lt;/h4&gt;
&lt;p&gt;It is often the case that we will want to reuse important pieces of code. While it is important that developers design their code with the general case in mind it is imperative that the second developer to notice the reusable nature of the code and build out the library at that time. If time does not allow for the general case to be retroactively implemented right away, the work should be scheduled.&lt;/p&gt;
&lt;p&gt;As library use continues, provisions should be made for generic hosting of these shared libraries.&lt;/p&gt;
&lt;h4 id="snippets"&gt;Snippets&lt;/h4&gt;
&lt;p&gt;&lt;em&gt;Any time a snippet or piece of another's code is included in CDH code, it must be cited clearly and used with permission&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;When an entire library is not needed or a piece of existing code needs to be re-purposed without being extracted to a separate file, a well-cited snippet may be appropriate. The beginning and end of this inclusion is important, since the snippet should be regarded as &lt;em&gt;read-only&lt;/em&gt; with configuration and over-riding changes made outside of the borrowed code.&lt;/p&gt;
&lt;h4 id="preferred-libraries"&gt;Preferred Libraries&lt;/h4&gt;
&lt;p&gt;Some JavaScript libraries have already been used and proven in CDH projects. Whenever possible, the most up-to-date version of the library should be used at the time of release.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;jQuery (jquery.com) - Popular and widely used library which focuses on imperative development, especially in DOM selection and manipulation. jQuery excels in cross-browser support for common functions and graphic manipulation. AJAX support with callbacks built in for success, failure, and completion.&lt;/li&gt;
&lt;li&gt;jQueryUI - extends jQuery to include a lot of popular interactions and widgets. This library allows for a host of themes as well which, while not ideal in a custom project, may assist in horizontal or throwaway prototyping.&lt;/li&gt;
&lt;li&gt;AngularJS (https://angularjs.org) - Honest MVC structure out of Google focuses on declarative development and separates data manipulation from display well. Allows for the easy development of reusable directives or custom elements and attributes and very compact, readable HTML code.&lt;/li&gt;
&lt;li&gt;AngularUI (http://angular-ui.github.io/) - extends AngularJS with community submitted interactions and custom directives and modules. Care should be taken that anything used is properly vetted as this collection is community moderated.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id="general-syntax-and-conventions"&gt;General Syntax and Conventions&lt;/h3&gt;
&lt;p&gt;&lt;a href="https://google-styleguide.googlecode.com/svn/trunk/javascriptguide.xml" rel="nofollow"&gt;https://google-styleguide.googlecode.com/svn/trunk/javascriptguide.xml&lt;/a&gt;&lt;br /&gt;
Use the Google style guide as a foul pole for most work. As we develop exceptions to these rules, we can include them here.&lt;/p&gt;
&lt;h3 id="variables"&gt;Variables&lt;/h3&gt;
&lt;p&gt;In every case, attaching a variable to the global scope is irresponsible. Creating a global namespace object to pile variables under is often evidence of poor structure, but still preferable to true globals.&lt;/p&gt;
&lt;p&gt;Variable names are camel-case, starting with a lower-case letter.&lt;/p&gt;
&lt;p&gt;Where part of a name is an abbreviation, it is all upper-case.&lt;br /&gt;
e.g. &lt;code&gt;editionID&lt;/code&gt;, not &lt;code&gt;editionId&lt;/code&gt;; &lt;code&gt;getURL&lt;/code&gt;, not &lt;code&gt;getUrl&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;Member variables get spelled out in full.&lt;br /&gt;
e.g. &lt;code&gt;currentEdition&lt;/code&gt;, not &lt;code&gt;curEdition&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;Local variables and parameters can (and should) use shorter names.&lt;br /&gt;
e.g. &lt;code&gt;edID&lt;/code&gt; for a local variable holding an edition ID&lt;/p&gt;
&lt;h3 id="constants-enums"&gt;Constants &amp;amp; Enums&lt;/h3&gt;
&lt;p&gt;Use of static final variables as constants is encouraged.&lt;/p&gt;
&lt;p&gt;Constant names and enum values are all upper-case, with components separated by underscores.&lt;br /&gt;
e.g. &lt;code&gt;CONFIRMATION_PENDING&lt;/code&gt;&lt;/p&gt;
&lt;h3 id="comments"&gt;Comments&lt;/h3&gt;
&lt;p&gt;Yes. JSDoc comments in particular.&lt;/p&gt;
&lt;p&gt;During project development, there may be the need for bookmark comments. These should be limited to those that NetBeans can create action items from such as TODO and FIXME. Process comments may be used to erect a skeleton for pending code, but obvious comments (e.g., "Increment and repeat") should be removed before public release.&lt;/p&gt;
&lt;p&gt;Keep in mind that some of these comments will be visited in versioning or accidentally released in the final code, so while everything may not be professional, it should at least be kept unoffensive and impersonal.&lt;/p&gt;
&lt;h3 id="logging-and-messages"&gt;Logging and Messages&lt;/h3&gt;
&lt;p&gt;For debugging, it may be helpful at times to put in lines for console.log(), but there is rarely a time when these lines should survive the final code cleanup. For advanced user information, throwing an error may be a more accurate action.&lt;/p&gt;
&lt;p&gt;If a message is frequently needed for the user in a modal or onscreen, consider generalizing the messaging and avoid the use of alert()s, prompt()s, and confirm()s in the final product.&lt;/p&gt;&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Patrick</dc:creator><pubDate>Tue, 24 Jun 2014 22:34:16 -0000</pubDate><guid>https://sourceforge.netab22eab01146d2caf51bccc6d5f79e1cfffed623</guid></item></channel></rss>