Changes between Version 4 and Version 5 of CodingStyle
- Timestamp:
- Aug 25, 2007, 11:36:51 PM (17 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
CodingStyle
v4 v5 255 255 Tricky code should not be commented but rewritten: In general, the use of comments should be minimized by making the code self-documenting by appropriate name choices and an explicit logical structure. 256 256 257 All comments should be written in English. 257 All comments should be written in English. Whenever possible, end comments with a period as normal phrases, and wrap long comments inside 80 characters for each line. 258 258 259 259 There should be a space after the comment identifier. 260 260 261 261 {{{ 262 // This is a comment 262 // This is a comment. NOT: //This is a comment 263 263 /** NOT: /** 264 264 * This is block *This is a block 265 * comment 265 * comment. *comment 266 266 */ */ 267 267 }}} 268 268 269 == Regular Expressions == 270 271 The '''regular expression literal''' should be used whenever possible, instead of the RegExp object, which should be used only when the regular expression pattern is not constant or depends on runtime computation. 272 273 {{{ 274 /^foo\s*/i 275 NOT 276 new RegExp( '^foo\s*', 'i' ) 277 }}} 278 279 Other than shortnesses and better readability, regular expression literals are compiled during script evaluation, which improves performance. 280 269 281 ----