5 ms·
"Avoid lines longer than 80 characters." This one really bugs me. 80 characters doesn't fit a whole lot of stuff. In a case where a line is more than 80 chars
by nixy 17y ago
"Avoid lines longer than 80 characters."
This one really bugs me. 80 characters doesn't fit a whole lot of stuff. In a case where a line is more than 80 chars long I would rather see this:
document.getElementsByClassName("externalLinkBig")[0].setAttribute("class", "externalLinkSmall");
than this rather ugly solution:
document.getElementsByClassName("externalLinkBig")[0].setAttribute("class",
"externalLinkSmall");
- nimbix 17y agoPersonally, I find both examples from your post rather unreadable. I always chain method calls like this: document .getElementsByClassName("externalLinkBig")[0] .setAttribute("class", "externalLinkSmall");
- axod 17y agoThat's ugly (IMHO) and not a good idea in js where semicolons are optional... For all we know it may execute 'document' as a statement, and then the next lines. Not nice IMHO If you can fit 160 chars on the display, use 160.
- thenduks 17y agoHow about: document .getElementsByClassName( 'externalLinkBig' )[0] .setAttribute( 'class', 'externalLinkSmall' ); 80 columns is definitely my preferred (but not "I'll complain") line length because I don't have my editor maximized (cringe) and long lines aren't as easy to read (especially when there's several long lines in a row, it's hard to keep them straight near the far right).
- jayair 17y agoYeah chaining is a way to do it. I've recently gotten addicted to chaining though. So now a lot of my functions look like this. A listener for the timespan navigation that Cadmus has: 'onNextTimespanClick': function(e, el) { return this .onNavigationClickStopEvent(e, el) .scrollToTop() .animateNavChange( this.getSelectedNavigationEl(), $$( 'div.navigation a[href=' + this.getHashFromUrl(el.href) + ']', this.navigationContainer ) ) .refreshItems(); },
- simonw 17y agoI'd do this: document.getElementsByClassName("externalLinkBig")[0].setAttribute( "class", "externalLinkSmall" );