Loading ...
Sorry, an error occurred while loading the content.

Re: [jslint] dot property name

Expand Messages
  • Michael S. Mikowski
    FWIW, here s my $0.02: Porting style from Conway s PBP, breaking before every operator and using K&R style indenting makes for very readable JS code IMO. var
    Message 1 of 9 , Sep 13, 2010
    View Source
    • 0 Attachment
      FWIW, here's my $0.02:

      Porting style from Conway's PBP, breaking before every operator and using K&R
      style indenting makes for very readable JS code IMO.

      var fnHello = function (){
      if ( ary_foo.length > 25
      || ary_foo < 5
      ){
      hash_elem.$body
      .find('div .namespace')
      .html( ''
      + '<h3>Hello</h3>
      + '<p>'
      + 'Hello World'
      + '</p>'
      )
      .end()
      .find('input')
      .css({'border-color':'#f00'})
      ;
      hash_state.sw_foo = true;
      }
      };

      Compare with the alternative:

      var fnHello = function (){
      if ( ary_foo.length > 25 ||
      ary_foo < 5
      ){
      hash_elem.
      $body.
      find('div .namespace').
      html('<h3>Hello</h3> +
      '<p>' +
      'Hello World' +
      '</p>').
      end().find('input').
      css({'border-color':'#f00'});
      hash_state.sw_foo = true;
      }
      };

      Operators on the end make them very hard to spot, not just the ., but also the
      || and the +.

      Keeping all lines below 80 characters allows me to view 3 files simultaneously
      side-by-side on my monitor. Finally, all jQuery elements are prefixed by a '$'
      sigil, a handy convention.

      YMMV.

      Cheers, Mike


      On Thursday, August 26, 2010 05:57:23 am Douglas Crockford wrote:
      > --- In jslint_com@yahoogroups.com, Frederik Dohr <fdg001@...> wrote:
      > > > Couldn't it be optional?
      > >
      > > I would prefer this as well.
      > > My colleagues and I made a conscious decision to use a trailing dot to
      > > indicate line continuation, which turned out positive in terms of code
      > > maintenance.
      >
      > I made the same decision as well, and I now believe that decision was
      > incorrect. I recommend that you update your code.


      [Non-text portions of this message have been removed]
    Your message has been successfully submitted and would be delivered to recipients shortly.