|
Conventions
Coding Conventions (Issue 1)
This document may be superceded by the Y! JavaScript Conventions, should they be published. Prime Directive
Coding Style
HTML tags
<link href="http://yui.yahooapis.com/2.2.2/build/reset-fonts-grids/reset-fonts-grids.css" rel="stylesheet" type="text/css"> <script src="http://www.json.org/json.js" type="text/javascript"></script> <script src="http://yui.yahooapis.com/2.2.2/build/yahoo-dom-event/yahoo-dom-event.js" type="text/javascript"></script> <script src="http://yui.yahooapis.com/2.2.2/build/element/element-beta-min.js" type="text/javascript"></script> <link href="http://yui.yahooapis.com/2.2.2/build/logger/assets/logger.css" rel="stylesheet" type="text/css" /> <script src="http://yui.yahooapis.com/2.2.2/build/logger/logger-min.js" type="text/javascript"></script> <script src="http://yui.yahooapis.com/2.2.0/build/connection/connection-min.js" type="text/javascript"></script> <script src="http://yui.yahooapis.com/2.2.2/build/animation/animation-min.js" type="text/javascript"></script> <script src="http://yui.yahooapis.com/2.2.2/build/dragdrop/dragdrop-min.js" type="text/javascript" ></script> <link href="http://yui.yahooapis.com/2.2.2/build/container/assets/container.css" rel="stylesheet" type="text/css"/> <script src="http://yui.yahooapis.com/2.2.2/build/container/container-min.js" type="text/javascript"></script> <link href="http://yui.yahooapis.com/2.2.2/build/tabview/assets/tabview.css" rel="stylesheet" type="text/css" /> <link href="http://yui.yahooapis.com/2.2.2/build/tabview/assets/border_tabs.css" rel="stylesheet" type="text/css" /> <script src="http://yui.yahooapis.com/2.2.2/build/tabview/tabview-min.js" type="text/javascript"></script> <link href="http://yui.yahooapis.com/2.2.2/build/treeview/assets/tree.css" type="text/css" rel="stylesheet"> <script src="http://yui.yahooapis.com/2.2.2/build/treeview/treeview-min.js" type="text/javascript"></script> <script src="http://yui.yahooapis.com/2.2.2/build/datasource/datasource-beta-min.js" type="text/javascript"></script> <link href="http://yui.yahooapis.com/2.2.2/build/datatable/assets/datatable.css" rel="stylesheet" type="text/css" /> <script src="http://yui.yahooapis.com/2.2.2/build/autocomplete/autocomplete-min.js" type="text/javascript"></script> <link href="http://yui.yahooapis.com/2.2.2/build/button/assets/button.css" rel="stylesheet" type="text/css"> <script src="http://yui.yahooapis.com/2.2.2/build/button/button-beta-min.js" type="text/javascript"></script> <script src="http://yui.yahooapis.com/2.2.2/build/slider/slider-min.js" type="text/javascript"></script> <link href="http://yui.yahooapis.com/2.2.2/build/calendar/assets/calendar.css" rel="stylesheet" type="text/css"> <script src="http://yui.yahooapis.com/2.2.2/build/calendar/calendar-min.js" type="text/javascript"></script> <script src="http://yui.yahooapis.com/2.2.2/build/history/history-experimental-min.js" type="text/javascript"></script> ConstantsAs in Java, predefined values (or "constants") can be expressed as variables in all UPPER_CASE. JavaScript does not prevent these variables from being changed, and so developers must practice constraint (and observe coding conventions!). When several related constants or default values are being defined, it can be convenient to group the constants into an object. (y) YAHOO.widget.Module._EVENT_TYPES = {
"BEFORE_INIT": "beforeInit",
"INIT": "init" }YAHOO.widget.Module._DEFAULT_CONFIG = {
"VISIBLE": {
key: "visible",
value: true,
validator: YAHOO.lang.isBoolean
}When a constant is being declared for Constructor (or "Class"), assign the constant directly to the Constructor. (y) YAHOO.widget.DataTable.CLASS_BODY = "yui-dt-body"; When a property is assigned a default value that may be changed by instances of the Constructor, then assign the property to the prototype. (y) YAHOO.widget.DataTable._nCount = 0; Variable Type Prefixes
Suffixes
Other Clarifications
File FormatJavaScript files should include a copyright and license header, and documentation comments using JavaDoc style tags. Code may also be organized into a common set of regions. (y) Copyright/License Header/* Copyright (c) 2007, Husted dot Com Inc. All rights reserved. Portions Copyright (c) 2007, Yahoo!, Inc. All rights reserved. Code licensed under the BSD License: http://developer.yahoo.net/yui/license.txt */
JavaDoc Style Comments
/**
* The module object is ....
* @module
* @requires
* @optional
* @title
* @beta
* @experimental
*/
/****************************************************************************/
/****************************************************************************/
/****************************************************************************/
/**
* Class is ...
* @description (deprecated?)
* @namespace
* @class
* @method
* @property
* @event
* @uses
* @private
* @public
* @static
* @type
* @constructor
* @param {type} name Remark
* @return
*/
The JsDoc tool can be used with the YUI tags, but not to the same effect as achieved by YUI's internal tool. The JsDoc Toolkit can also be used if certain required tags and include. Other tools and taglets may be used. Common Code RegionsIf code regions are utilized, prefer the common YUI regions. (y)
///////////////////////////////////////////////////////////////////////////// // // $REGION$ // ///////////////////////////////////////////////////////////////////////////// Inline Comments
Coding Tools
Commit styleAll Subversion commits must reference an issue ticket. (So open the ticket first!). (z) Subversion commit messages are posted to the development group mailing list, for both the code and the wiki. Verbose logs are recommended so as to encourage other developers to peer-review code and documentation. (z) Notes from Zakas presentation
|
Sign in to add a comment