<?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: Running JavaScript&#8230; With Sneakers!</title>
	<atom:link href="http://lostechies.com/sharoncichelli/2011/11/16/running-javascript-with-sneakers/feed/" rel="self" type="application/rss+xml" />
	<link>http://lostechies.com/sharoncichelli/2011/11/16/running-javascript-with-sneakers/</link>
	<description>Sharon Cichelli&#039;s blog about software, development, teams, and projects</description>
	<lastBuildDate>Sat, 15 Jun 2013 03:11:00 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.4.2</generator>
	<item>
		<title>By: Anonymous</title>
		<link>http://lostechies.com/sharoncichelli/2011/11/16/running-javascript-with-sneakers/#comment-76</link>
		<dc:creator>Anonymous</dc:creator>
		<pubDate>Mon, 21 Nov 2011 20:34:00 +0000</pubDate>
		<guid isPermaLink="false">http://lostechies.com/sharoncichelli/?p=65#comment-76</guid>
		<description>Taking a cue from Garann Means&#039; talk at HTML5.tx, one way to simplify the JavaScript is to &lt;em&gt;replace&lt;/em&gt; it with CSS3. :) So I made a JsFiddle that uses CSS to do the background flashing. http://jsfiddle.net/scichelli/JWpeV/

However, the browser on my N810 doesn&#039;t support CSS3, and due to the existence of the N900 (and Android, sigh), it is unlikely ever to do so.</description>
		<content:encoded><![CDATA[<p>Taking a cue from Garann Means&#8217; talk at HTML5.tx, one way to simplify the JavaScript is to <em>replace</em> it with CSS3. :) So I made a JsFiddle that uses CSS to do the background flashing. http://jsfiddle.net/scichelli/JWpeV/</p>
<p>However, the browser on my N810 doesn&#8217;t support CSS3, and due to the existence of the N900 (and Android, sigh), it is unlikely ever to do so.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Anonymous</title>
		<link>http://lostechies.com/sharoncichelli/2011/11/16/running-javascript-with-sneakers/#comment-75</link>
		<dc:creator>Anonymous</dc:creator>
		<pubDate>Fri, 18 Nov 2011 17:08:00 +0000</pubDate>
		<guid isPermaLink="false">http://lostechies.com/sharoncichelli/?p=65#comment-75</guid>
		<description>Nice! Yeah, I know the app is small, but part of the exercise is writing it really cleanly, so that I can practice the big concepts--so that&#039;s exactly the kind of help I&#039;m looking for. Thanks for the extra context on &quot;why,&quot; in addition to &quot;what.&quot; This weekend I&#039;m gonna finally sit down and digest your WatchMeCode screencast on JavaScript refactoring, too.</description>
		<content:encoded><![CDATA[<p>Nice! Yeah, I know the app is small, but part of the exercise is writing it really cleanly, so that I can practice the big concepts&#8211;so that&#8217;s exactly the kind of help I&#8217;m looking for. Thanks for the extra context on &#8220;why,&#8221; in addition to &#8220;what.&#8221; This weekend I&#8217;m gonna finally sit down and digest your WatchMeCode screencast on JavaScript refactoring, too.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Derick Bailey</title>
		<link>http://lostechies.com/sharoncichelli/2011/11/16/running-javascript-with-sneakers/#comment-74</link>
		<dc:creator>Derick Bailey</dc:creator>
		<pubDate>Fri, 18 Nov 2011 02:11:00 +0000</pubDate>
		<guid isPermaLink="false">http://lostechies.com/sharoncichelli/?p=65#comment-74</guid>
		<description>The big thing I&#039;ll point out is the excessive pollution of the JavaScript global object / context. In such a small, specialized app it isn&#039;t a big deal. When you get into larger apps, apps that include more libraries, and generally have more code, this becomes a problem quickly.

There&#039;s a performance penalty every time you have to look for a global variable / function / object, because JavaScript has to first search the local scope, then the bubble up through scopes / closures, then finally get to the global context for one last search.

Worse, though, is that it&#039;s really easy to accidentally overwrite someone else&#039;s code by using a variable or function name that another chunk of code needed. Think about namespaces in other languages, and the same basic principles of organization apply here.

To combat the problems, look at the JavaScript module pattern. I introduce this a little in my most recent post on composite JavaScript apps, and there&#039;s a ton of other info out there that goes in to much more detail.

The gist of it, though, is that you can wrap up your code in a function (functions inside of functions...) and then provide a &quot;public&quot; API that is returned from the function, to kick off your app.

MyApp = (function(){
  var somePrivateVar = &quot;foo&quot;;
  var somePrivateFunction = function(){
  }

  // the public stuff
  var myApp = {};
  myApp.doStuff = function(){
  }
  // it&#039;s &quot;public&quot; because it&#039;s being returned, here
  return myApp;
})();

$(function(){
  MyApp.doStuff();
});</description>
		<content:encoded><![CDATA[<p>The big thing I&#8217;ll point out is the excessive pollution of the JavaScript global object / context. In such a small, specialized app it isn&#8217;t a big deal. When you get into larger apps, apps that include more libraries, and generally have more code, this becomes a problem quickly.</p>
<p>There&#8217;s a performance penalty every time you have to look for a global variable / function / object, because JavaScript has to first search the local scope, then the bubble up through scopes / closures, then finally get to the global context for one last search.</p>
<p>Worse, though, is that it&#8217;s really easy to accidentally overwrite someone else&#8217;s code by using a variable or function name that another chunk of code needed. Think about namespaces in other languages, and the same basic principles of organization apply here.</p>
<p>To combat the problems, look at the JavaScript module pattern. I introduce this a little in my most recent post on composite JavaScript apps, and there&#8217;s a ton of other info out there that goes in to much more detail.</p>
<p>The gist of it, though, is that you can wrap up your code in a function (functions inside of functions&#8230;) and then provide a &#8220;public&#8221; API that is returned from the function, to kick off your app.</p>
<p>MyApp = (function(){<br />
  var somePrivateVar = &#8220;foo&#8221;;<br />
  var somePrivateFunction = function(){<br />
  }</p>
<p>  // the public stuff<br />
  var myApp = {};<br />
  myApp.doStuff = function(){<br />
  }<br />
  // it&#8217;s &#8220;public&#8221; because it&#8217;s being returned, here<br />
  return myApp;<br />
})();</p>
<p>$(function(){<br />
  MyApp.doStuff();<br />
});</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Anonymous</title>
		<link>http://lostechies.com/sharoncichelli/2011/11/16/running-javascript-with-sneakers/#comment-73</link>
		<dc:creator>Anonymous</dc:creator>
		<pubDate>Thu, 17 Nov 2011 20:44:00 +0000</pubDate>
		<guid isPermaLink="false">http://lostechies.com/sharoncichelli/?p=65#comment-73</guid>
		<description>Thanks for the thoughtful feedback. Nice point about the pseudo-array for finding the workout; I&#039;ll try that out. Regarding moving &quot;doExercise&quot; to be a member of workout, I think I follow you. I am not yet at all used to object-oriented JavaScript, so I&#039;m still developing my intuitions in that regard. I&#039;ll look into that. Thanks very much for the suggestions.</description>
		<content:encoded><![CDATA[<p>Thanks for the thoughtful feedback. Nice point about the pseudo-array for finding the workout; I&#8217;ll try that out. Regarding moving &#8220;doExercise&#8221; to be a member of workout, I think I follow you. I am not yet at all used to object-oriented JavaScript, so I&#8217;m still developing my intuitions in that regard. I&#8217;ll look into that. Thanks very much for the suggestions.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Marcel Popescu</title>
		<link>http://lostechies.com/sharoncichelli/2011/11/16/running-javascript-with-sneakers/#comment-71</link>
		<dc:creator>Marcel Popescu</dc:creator>
		<pubDate>Thu, 17 Nov 2011 11:15:00 +0000</pubDate>
		<guid isPermaLink="false">http://lostechies.com/sharoncichelli/?p=65#comment-71</guid>
		<description>Interesting. I don&#039;t see anything obviously bad in the code - I wouldn&#039;t have gone the &quot;eval&quot; route, preferring just a regular pseudo-array [1] but other than that, the code is pretty clear IMO. The doExercise function looks like it wants to be a member function of the workout object but I think that&#039;s art for art&#039;s sake; this was not supposed to be enterprise-level code.

[1] Given that both the week and the day are one digit you could use a c25k[wd] indexing scheme, where w is the week and d is the day - so c25k[42] is the schedule for week 4, day 2
</description>
		<content:encoded><![CDATA[<p>Interesting. I don&#8217;t see anything obviously bad in the code &#8211; I wouldn&#8217;t have gone the &#8220;eval&#8221; route, preferring just a regular pseudo-array [1] but other than that, the code is pretty clear IMO. The doExercise function looks like it wants to be a member function of the workout object but I think that&#8217;s art for art&#8217;s sake; this was not supposed to be enterprise-level code.</p>
<p>[1] Given that both the week and the day are one digit you could use a c25k[wd] indexing scheme, where w is the week and d is the day &#8211; so c25k[42] is the schedule for week 4, day 2</p>
]]></content:encoded>
	</item>
</channel>
</rss>
