Changes between Version 4 and Version 5 of CodingStyle


Ignore:
Timestamp:
Aug 25, 2007, 11:36:51 PM (17 years ago)
Author:
Frederico Caldeira Knabben
Comment:

Added Regular Expressions

Legend:

Unmodified
Added
Removed
Modified
  • CodingStyle

    v4 v5  
    255255Tricky 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.
    256256
    257 All comments should be written in English.
     257All 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.
    258258
    259259There should be a space after the comment identifier.
    260260
    261261{{{
    262     // This is a comment     NOT: //This is a comment
     262    // This is a comment.    NOT: //This is a comment
    263263    /**                      NOT: /**
    264264     * This is block               *This is a block
    265      * comment                     *comment
     265     * comment.                    *comment
    266266     */                            */
    267267}}}
    268268
     269== Regular Expressions ==
     270
     271The '''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
     279Other than shortnesses and better readability, regular expression literals are compiled during script evaluation, which improves performance.
     280
    269281----
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy