Ext JS is a JavaScript framework. Therefore, you should follow most of the JavaScript naming conventions.
Sencha suggests following naming conventions for Ext JS application:
Convention for | Description | Example |
---|---|---|
Class | Class name should be in CamelCase | MyCustomClass |
Class name should contain alphanumeric characters. Numbers are permitted if it belongs to a technical term. | Base64 | |
Do not use underscores, hyphens, or any other non-alphanumeric characters. | ||
Class name should be with at least one unique namespace separated by dot (.). | TopLevelNamespace.MyClassName | |
Classes that are not distributed by Sencha should never use Ext as the top-level namespace. | ||
The top-level namespaces and the actual class names should be in CamelCase, everything else should be in lower-case. | TopNamespace.middnamespace.CustomClass | |
Source File | The names of the classes map directly to the file paths in which they are stored. As a result, there must only be one class per file. | Ext.util.Observable is stored in path/to/src/Ext/util/Observable.js MyTopLevelNamespace.util.JsonToXml is tored in path/to/src/MyTopLevelNamespace/util/ JsonToXml.js |
Methods | Method should always be in camelCase. | encodeUsingMd5(), getHtml() |
Variables | Variable should always be in camelCase. | var isGoodName
var base64Encoder |
Constant variable should be in upper-case | var SALARY = 1000 | |
Private variable should start with underscore ‘_’ | var _privateVariable | |
Properties | Properties should always be in camelCase. Static properties should bein upper-case. | Ext.MessageBox.YES = "Yes" |
Also, visit javascript.crockford.com for JavaScript coding conventions used in JSLint.