<?xml version="1.0" encoding="utf-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Why these jQuery worst practices aren&#8217;t.</title>
	<atom:link href="http://www.lazycoder.com/weblog/2009/05/12/why-these-jquery-worst-practices-arent/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.lazycoder.com/weblog/2009/05/12/why-these-jquery-worst-practices-arent/</link>
	<description></description>
	<lastBuildDate>Thu, 11 Mar 2010 23:04:30 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Steve Wellens</title>
		<link>http://www.lazycoder.com/weblog/2009/05/12/why-these-jquery-worst-practices-arent/comment-page-1/#comment-200568</link>
		<dc:creator>Steve Wellens</dc:creator>
		<pubDate>Fri, 05 Mar 2010 19:33:56 +0000</pubDate>
		<guid isPermaLink="false">http://www.lazycoder.com/weblog/?p=1121#comment-200568</guid>
		<description>Straw man arguments are tedious to refute.

For the record, my only problem with certain practises is that they imply, &quot;Do it this way all the time.&quot;  There are pros and cons when choosing a particular solution to a particular problem.  Slavishly following a paradigm does not always result in an optimum solution.</description>
		<content:encoded><![CDATA[<p>Straw man arguments are tedious to refute.</p>
<p>For the record, my only problem with certain practises is that they imply, &#8220;Do it this way all the time.&#8221;  There are pros and cons when choosing a particular solution to a particular problem.  Slavishly following a paradigm does not always result in an optimum solution.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: LMAO@Andrea</title>
		<link>http://www.lazycoder.com/weblog/2009/05/12/why-these-jquery-worst-practices-arent/comment-page-1/#comment-190958</link>
		<dc:creator>LMAO@Andrea</dc:creator>
		<pubDate>Thu, 14 May 2009 23:25:20 +0000</pubDate>
		<guid isPermaLink="false">http://www.lazycoder.com/weblog/?p=1121#comment-190958</guid>
		<description>Hah too funny Andrea, being critical of spelling on a blog domain entitled the &quot;lazycoder&quot;. Wow uptight much? :)</description>
		<content:encoded><![CDATA[<p>Hah too funny Andrea, being critical of spelling on a blog domain entitled the &#8220;lazycoder&#8221;. Wow uptight much? <img src='http://www.lazycoder.com/weblog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andrea</title>
		<link>http://www.lazycoder.com/weblog/2009/05/12/why-these-jquery-worst-practices-arent/comment-page-1/#comment-190936</link>
		<dc:creator>Andrea</dc:creator>
		<pubDate>Thu, 14 May 2009 10:09:59 +0000</pubDate>
		<guid isPermaLink="false">http://www.lazycoder.com/weblog/?p=1121#comment-190936</guid>
		<description>Please use a spell checker before posting articles, Scott.</description>
		<content:encoded><![CDATA[<p>Please use a spell checker before posting articles, Scott.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Scott</title>
		<link>http://www.lazycoder.com/weblog/2009/05/12/why-these-jquery-worst-practices-arent/comment-page-1/#comment-190920</link>
		<dc:creator>Scott</dc:creator>
		<pubDate>Thu, 14 May 2009 04:55:37 +0000</pubDate>
		<guid isPermaLink="false">http://www.lazycoder.com/weblog/?p=1121#comment-190920</guid>
		<description>&quot;So what you’re saying is, even if you have 50 calls, they should all be on the same “chain”?&quot;

What I said was that there was a way to make the chaining readable.  I&#039;d consider a jQuery call that contained 50 chained call to be a code smell. But if you are binding several events to the same set of elements defined by a single selector, chaining the calls is a valid choice. 

IMO, once you&#039;re inside of jQuery any kind of debugging increases in degree of difficulty.</description>
		<content:encoded><![CDATA[<p>&#8220;So what you’re saying is, even if you have 50 calls, they should all be on the same “chain”?&#8221;</p>
<p>What I said was that there was a way to make the chaining readable.  I&#8217;d consider a jQuery call that contained 50 chained call to be a code smell. But if you are binding several events to the same set of elements defined by a single selector, chaining the calls is a valid choice. </p>
<p>IMO, once you&#8217;re inside of jQuery any kind of debugging increases in degree of difficulty.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ken</title>
		<link>http://www.lazycoder.com/weblog/2009/05/12/why-these-jquery-worst-practices-arent/comment-page-1/#comment-190908</link>
		<dc:creator>ken</dc:creator>
		<pubDate>Thu, 14 May 2009 01:04:17 +0000</pubDate>
		<guid isPermaLink="false">http://www.lazycoder.com/weblog/?p=1121#comment-190908</guid>
		<description>I&#039;m only going to address #2.

First, I think his chosen example was just that, an example. Take some &quot;real-world&quot; examples, where one might use .css(), .click(), .show(), .hover(), etc. all on one chain. 

That being said, I think I agree with the original author though, and not you. I would bet money that his method is less error-prone when maintained -- that is, unless you all are elite coders whose code never needs to be maintained, (even after a change in requirements,  refactoring, etc)?

So what you&#039;re saying is, even if you have 50 calls, they should all be on the same &quot;chain&quot;? Have you ever written a chain longer than 3-4 calls? It gets even more fun when you try to inline anonymous functions and such.

Breaking up a chain lets you reorganize the chain easier. For example, say you have a long chain, and at several points you filter your collection by using .find(), do some operations, and then you return to your original collection by calling .end(). This is a maintainablity (and readability) nightmare! Sure, it may be easy for you, but reading code is like reading handwriting: its always so much easier when its your own. The poor sap who comes along after you isn&#039;t going to have a very fun time.

Breaking chains is also easier to debug. How are you going to console.log that intermediate value? How are you going to add a debugger statement right before the ajax call?

Lastly, breaking up chains would also be wise in the name of safety. Whitespace can cause all sorts of very hard to diagnose issues, including the dubious semicolon insertion problems and minifier/packer compatibility issues.

The fluent interface design pattern if immensely powerful, however, it can also let you shoot yourself in the foot very fast.</description>
		<content:encoded><![CDATA[<p>I&#8217;m only going to address #2.</p>
<p>First, I think his chosen example was just that, an example. Take some &#8220;real-world&#8221; examples, where one might use .css(), .click(), .show(), .hover(), etc. all on one chain. </p>
<p>That being said, I think I agree with the original author though, and not you. I would bet money that his method is less error-prone when maintained &#8212; that is, unless you all are elite coders whose code never needs to be maintained, (even after a change in requirements,  refactoring, etc)?</p>
<p>So what you&#8217;re saying is, even if you have 50 calls, they should all be on the same &#8220;chain&#8221;? Have you ever written a chain longer than 3-4 calls? It gets even more fun when you try to inline anonymous functions and such.</p>
<p>Breaking up a chain lets you reorganize the chain easier. For example, say you have a long chain, and at several points you filter your collection by using .find(), do some operations, and then you return to your original collection by calling .end(). This is a maintainablity (and readability) nightmare! Sure, it may be easy for you, but reading code is like reading handwriting: its always so much easier when its your own. The poor sap who comes along after you isn&#8217;t going to have a very fun time.</p>
<p>Breaking chains is also easier to debug. How are you going to console.log that intermediate value? How are you going to add a debugger statement right before the ajax call?</p>
<p>Lastly, breaking up chains would also be wise in the name of safety. Whitespace can cause all sorts of very hard to diagnose issues, including the dubious semicolon insertion problems and minifier/packer compatibility issues.</p>
<p>The fluent interface design pattern if immensely powerful, however, it can also let you shoot yourself in the foot very fast.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Scott</title>
		<link>http://www.lazycoder.com/weblog/2009/05/12/why-these-jquery-worst-practices-arent/comment-page-1/#comment-190890</link>
		<dc:creator>Scott</dc:creator>
		<pubDate>Wed, 13 May 2009 16:50:22 +0000</pubDate>
		<guid isPermaLink="false">http://www.lazycoder.com/weblog/?p=1121#comment-190890</guid>
		<description>HA, good catch Duncan. I&#039;ll update the post, otherwise that&#039;ll bug me too.</description>
		<content:encoded><![CDATA[<p>HA, good catch Duncan. I&#8217;ll update the post, otherwise that&#8217;ll bug me too.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ryan Roberts</title>
		<link>http://www.lazycoder.com/weblog/2009/05/12/why-these-jquery-worst-practices-arent/comment-page-1/#comment-190875</link>
		<dc:creator>Ryan Roberts</dc:creator>
		<pubDate>Wed, 13 May 2009 10:50:58 +0000</pubDate>
		<guid isPermaLink="false">http://www.lazycoder.com/weblog/?p=1121#comment-190875</guid>
		<description>His argument against method chaining was particularly gruesome. That might be something to do with his confessed inexperience with javascript. Otherwise he would likely have a deeply ingrained hatred of imperative nodeset twiddling.

I asked him whether he would assign to intermediate results to make his SQL &#039;clearer&#039;, or whether he would use the language to declaratively manipulate sets as intended. 

And he blocks comments, most unsporting.</description>
		<content:encoded><![CDATA[<p>His argument against method chaining was particularly gruesome. That might be something to do with his confessed inexperience with javascript. Otherwise he would likely have a deeply ingrained hatred of imperative nodeset twiddling.</p>
<p>I asked him whether he would assign to intermediate results to make his <acronym title='Structured Query Language'><span class='caps'>SQL</span></acronym> &#8216;clearer&#8217;, or whether he would use the language to declaratively manipulate sets as intended. </p>
<p>And he blocks comments, most unsporting.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Duncan Smart</title>
		<link>http://www.lazycoder.com/weblog/2009/05/12/why-these-jquery-worst-practices-arent/comment-page-1/#comment-190870</link>
		<dc:creator>Duncan Smart</dc:creator>
		<pubDate>Wed, 13 May 2009 09:28:37 +0000</pubDate>
		<guid isPermaLink="false">http://www.lazycoder.com/weblog/?p=1121#comment-190870</guid>
		<description>Nitpicking:

$(&quot;div.highlight&quot;).css({
  color:yellow,
  background-color:black,
  width:50px
});

should be:

$(&quot;div.highlight&quot;).css({
  color:&quot;yellow&quot;,
  background-color:&quot;black&quot;,
  width:&quot;50px&quot;
});</description>
		<content:encoded><![CDATA[<p>Nitpicking:</p>
<p>$(&#8220;div.highlight&#8221;).css({<br />
  color:yellow,<br />
  background-color:black,<br />
  width:50px<br />
});</p>
<p>should be:</p>
<p>$(&#8220;div.highlight&#8221;).css({<br />
  color:&#8221;yellow&#8221;,<br />
  background-color:&#8221;black&#8221;,<br />
  width:&#8221;50px&#8221;<br />
});</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Erik van Brakel</title>
		<link>http://www.lazycoder.com/weblog/2009/05/12/why-these-jquery-worst-practices-arent/comment-page-1/#comment-190864</link>
		<dc:creator>Erik van Brakel</dc:creator>
		<pubDate>Wed, 13 May 2009 08:05:12 +0000</pubDate>
		<guid isPermaLink="false">http://www.lazycoder.com/weblog/?p=1121#comment-190864</guid>
		<description>I fully agree. I didn&#039;t quite get why he called those bad practices. AFAIK, the things he mentions as bad practices are actually the way jQuery is designed/what jQuery is designed for.

Especially when you have one guy doing the markup and another doing the scripting, rule #1 is really important. You can let someone simply change the view, without breaking the scripting (as long as you keep the same names/IDs of course).</description>
		<content:encoded><![CDATA[<p>I fully agree. I didn&#8217;t quite get why he called those bad practices. <acronym title='As Far As I Know'><span class='caps'>AFAIK</span></acronym>, the things he mentions as bad practices are actually the way jQuery is designed/what jQuery is designed for.</p>
<p>Especially when you have one guy doing the markup and another doing the scripting, rule #1 is really important. You can let someone simply change the view, without breaking the scripting (as long as you keep the same names/IDs of course).</p>
]]></content:encoded>
	</item>
</channel>
</rss>
