Changes between Version 27 and Version 28 of TracDev/CodingStyle
- Timestamp:
- May 3, 2015, 12:28:32 AM (9 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
TracDev/CodingStyle
v27 v28 25 25 26 26 - Use `"..."` for text meant to be read by users, 27 use `'...'` for string constants (e.g. keys in dicts, CSS class names, filenames).27 use `'...'` for string constants, eg keys in dicts, CSS class names, filenames. 28 28 The former strings will usually be translated, so be sure to play nice with the i18n conventions ([[TracL10N#ForDevelopers]]). 29 29 In fact, the only "..." strings that won't get translated are the messages for the log. … … 34 34 35 35 == Miscellaneous 36 * '''Lines shouldn't exceed a length of 79 characters.''' [[br]] 37 No, it's not because we're using VT100 terminals while developing Trac, 38 rather because the diffs look nicer on short lines, especially in side-by-side mode. 39 * ''Never'' use multiple statements on the same line, e.g. `if check: a = 0`. 36 37 * '''Lines shouldn't exceed a length of 79 characters''', so that the diffs look nicer on short lines, especially in side-by-side mode. 38 * Never use multiple statements on the same line, eg `if check: a = 0`. 40 39 * Prefer list comprehension to the built-in functions `filter()` and `map()` when appropriate. 41 40 * Use `raise TracError("message")` instead of `raise TracError, "message"` … … 55 54 !JavaScript code should follow [http://javascript.crockford.com/code.html these conventions] with the following exceptions and additions: 56 55 * Lines shouldn't exceed a length of 79 characters. 57 * Use two spaces for indentation .56 * Use two spaces for indentation and refrain from using tabs. 58 57 * Use `lowercase` for variable names. 59 58 * Use `camelCase` for functions. 60 * Define non-anonymous functions as `function fooBar() {...}` (rather than `var fooBar = function() {...}`)61 * Keep as much as possible private, by defining private functions in an inner scope. Attach functions you want to export to the $symbol.59 * Define non-anonymous functions as `function fooBar() {...}`, rather than `var fooBar = function() {...}`. 60 * Keep as much as possible private, by defining private functions in an inner scope. Attach functions you want to export to the `$` symbol. 62 61 * Use a `trac-` prefix for all id and class names. This is for new names, because changing old names would break customizations. 63 62 * Prefix variables containing a jQuery object with `$`.