<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Refresh &#187; code</title>
	<atom:link href="http://www.refresh.dk/topic/code/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.refresh.dk</link>
	<description>Web programming for practitioners</description>
	<lastBuildDate>Sun, 02 May 2010 16:25:35 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Taking out node.js for a spin with Bomber</title>
		<link>http://www.refresh.dk/node-on-bomber/</link>
		<comments>http://www.refresh.dk/node-on-bomber/#comments</comments>
		<pubDate>Sat, 02 Jan 2010 21:39:59 +0000</pubDate>
		<dc:creator>Steffen Tiedemann Christensen</dc:creator>
				<category><![CDATA[Bomber]]></category>
		<category><![CDATA[Introspection]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Node.js]]></category>
		<category><![CDATA[Web servers]]></category>
		<category><![CDATA[Web services]]></category>
		<category><![CDATA[code]]></category>

		<guid isPermaLink="false">http://www.refresh.dk/?p=66</guid>
		<description><![CDATA[The node.js project has been getting a lot of good press and positive attention over the past few months. With good reason. If this is the first you&#8217;re hearing of node.js, it&#8217;s officially an &#8220;evented I/O for V8 JavaScript&#8221; but more generally it is used as a tool for writing non-blocking network servers. This means [...]]]></description>
			<content:encoded><![CDATA[<p>The <a href="http://nodejs.org/">node.js</a> project has been getting a lot of good press and positive attention over the past few months. With good reason. If this is the first you&#8217;re hearing of node.js, it&#8217;s officially an &#8220;evented I/O for V8 JavaScript&#8221; but more generally it is used as a tool for writing non-blocking network servers. This means that it can easily be made into a JavaScript-based and highly efficient web server. If you&#8217;re curious, have a look at <a href="http://simonwillison.net/2009/Nov/23/node/">Simon Willison&#8217;s nice write-up</a>.</p>
<p>Node is still in it&#8217;s infancy. For example, there&#8217;s is still a lot of discussion going on <a href="http://groups.google.com/group/nodejs">on the mailing list</a> about core API (i.e. <a href="http://groups.google.com/group/nodejs/browse_thread/thread/4a1ce27a1f588a7f/28b8fb57bb126ee2">how to handle communication between and chaining of events</a> or even <a href="http://groups.google.com/group/nodejs/browse_thread/thread/c1553dda2f860bb9">how the final file API is going to look</a>). Since node isn&#8217;t designed explicitly as a web server, there&#8217;s only low-level http support &#8212; and of course, there is no standard web application framework for handlings requests, sessions, cookies, and users. </p>
<p>The first question to be answered is if you&#8217;d actually want big web applications to run solely on node.js? But for now I&#8217;ve skipped that question entirely and simply asked how I&#8217;d approach writing such and application (hopefully reusing some of the code being currently being pushed by the node community)? </p>
<p>It seems as if every person in that community has written her or his own lightweight library for handling web requests. To name <a href="http://wiki.github.com/ry/node">a few</a>, there&#8217;s <a href="http://github.com/simonw/djangode">Djangode</a>, <a href="http://github.com/visionmedia/express">Express</a>, <a href="http://github.com/ujh/coltrane">Coltrane</a>, <a href="http://github.com/raycmorgan/vroom">Vroom</a>, and <a href="http://github.com/creationix/node-router">node-router</a>). A lot of these are obviously inspired by the approaches taken by either Django or by Rails (it&#8217;s right there in the names), but taken as a whole they&#8217;re very limited in how they approach the task. Most of the frameworks are just different syntaxes for binding a JavaScript <tt>function() {}</tt> to a URL &#8212; without the modular approach taken by their more mature counterparts. </p>
<p>This means that you can easily use any of these frameworks if you need to write up a simple &#8212; and fast! &#8212; web app in a single file with a few hundred lines of code (in that case, I&#8217;d opt for Djangode), but you&#8217;d be stomped if wanted different, re-usable applications meshing into a single project. <a href="http://benjaminthomas.org/2009-11-20/designing-a-web-framework.html">Benjamin Thomas has gone in designing mode</a> in order to come up with a mini-framework which isn&#8217;t quite as <i>mini</i> as the ones listed above. His ambition is to build&#8230;</p>
<blockquote><p>- The ability to bundle up a collection of controllers/views, models and templates into “apps” for easy portability and reuse.<br />
- Smart defaults that hide a lot of the options/power/complexity. I think this is important for getting up and running quickly.<br />
- A code base that is as small and simple as possible.<br />
- I want it to feel javascript-like. Whatever that means. </p></blockquote>
<p>The end result is <a href="http://bomber.obtdev.com/">Bomber</a>. I like how Bomber creates simple URL routing to file-based (or rather node.js module-based) views, and how it lightly extends the core <tt>http.ServerRequest</tt> and <tt>http.ServerResponse</tt> objects. It feels almost native, but you see that enough of a foundation exists for this framework to actually include the ability to handle POSTs, sessions, cookies, multiple applications within a project and so on. There are no great ambitions where the framework will suddenly include a native XML parser (just a random example, sorry), but there&#8217;s enough room to grow and spread the webby wings a bit.  </p>
<p>The Bomber project is very much in flux. In fact, it might even be dead since the last commit is a month old. And the entire project is build around an <tt><a href="http://bomber.obtdev.com/docs/action.html">Action API</a></tt> which about to be deprecated. Hopefully to be replaced with <a href="http://api.dojotoolkit.org/jsdoc/1.2/dojo.Deferred">DOJO-style</a>, native <a href="http://groups.google.com/group/nodejs/browse_thread/thread/4a1ce27a1f588a7f/28b8fb57bb126ee2">Deferreds</a>.</p>
<p>I&#8217;ve been playing around a bit by adding some extra stuff to Bomber through <a href="http://github.com/steffentchr/bomberjs">my own fork at github</a>. I&#8217;ve already tweaked a little with the app structure to allow for multiple projects to be bootstrapped with different configurations from the same Bomber library, and there is some copy-paste and bug fixes in there as well. This will likely include experiments with multi-application projects, per-application media directories, cookie and session handling and templating (although I disagree with Benjamin that Bomber should include its own templating system; this could probably be left for the programmer to choose).</p>
<p>And now, back to Jersey Shore, bitches!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.refresh.dk/node-on-bomber/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>FeatureSlider [script]</title>
		<link>http://www.refresh.dk/featureslider-script/</link>
		<comments>http://www.refresh.dk/featureslider-script/#comments</comments>
		<pubDate>Sat, 22 Mar 2008 23:46:22 +0000</pubDate>
		<dc:creator>Steffen Tiedemann Christensen</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[code]]></category>

		<guid isPermaLink="false">http://www.refresh.dk/featureslider-script/</guid>
		<description><![CDATA[
&#187; Instant Gratification Now!
If you&#8217;ve ever visited the front page of Beanstalk you&#8217;ll know that they have a very nice inline feature tour, which scrolls your across some html content on the front page. 
In a project I&#8217;ve been working on we need a similar way to browse through a series of articles, so I&#8217;ve [...]]]></description>
			<content:encoded><![CDATA[<div style="float:right; padding:0 0 20px 20px;"><a href="/examples/feature-slider/callback"><img src="/wordpress/wp-content/uploads/2008/03/billede-6.png" width="200"/></a></div>
<p><small>&raquo; <a href="/examples/feature-slider/callback">Instant Gratification Now!</a></small></p>
<p>If you&#8217;ve ever visited the front page of <a href="http://beanstalkapp.com/">Beanstalk</a> you&#8217;ll know that they have a very nice inline feature tour, which scrolls your across some html content on the front page. </p>
<p>In a project I&#8217;ve been working on we need a similar way to browse through a series of articles, so I&#8217;ve built a <i>very</i> simple Prototype (and optionally Scriptaculous, if you want the animation to work) script, which makes it trivial to include such tours: <a href="/examples/feature-slider/feature-slider.js">feature-slider.js</a></p>
<p><small>For the guys at Beanstalk, if you&#8217;re reading this: To get your tour to work correctly in Internet Explorer, simply add <tt>position:relative</tt> to the overall container. I like your temporary IE hack, but still&#8230;</small></p>
<h3>Using the code</h3>
<p>To use the code, simply do this:</p>
<p><code class="html">&lt;style&gt;<br />
&nbsp;&nbsp;#slide {width:300px; height:200px; overflow:hidden;}<br />
&lt;/style&gt;<br />
&lt;script src="feature-slider.js"&gt;&lt;/script&gt;<br />
&lt;div id="slider"&gt;<br />
&nbsp;&nbsp;&lt;div&gt;First item&lt;/div&gt;<br />
&nbsp;&nbsp;&lt;div&gt;(...)&lt;/div&gt;<br />
&nbsp;&nbsp;&lt;div&gt;(...)&lt;/div&gt;<br />
&nbsp;&nbsp;&lt;div&gt;Last item&lt;/div&gt;<br />
&lt;/div&gt;<br />
&lt;script&gt;var fs = new Slider('slider');&lt;/script&gt;</code></p>
<p>A few real-life examples:</p>
<ul>
<li><a href="/examples/feature-slider/simple">The very simple slideshow</a></li>
<li><a href="/examples/feature-slider/beatles">More advanced content with manual menus</a></li>
<li><a href="/examples/feature-slider/callback">Using callbacks to build the menu automatically</a></li>
</ul>
<p>I&#8217;ve tried to keep everything simple, which means that the script doesn&#8217;t try to build navigation for you. Usually, this is where other <a href="http://ajaxian.com/archives/prototype-carousel-widget">similar carousel scripts</a> go wrong. Instead you can use a few functions to browse the items in the <tt>FeatureSlider</tt>, or you can use callbacks to build advanced navigation:</p>
<p><tt><i>fs</i>.go(n)</tt>: Go to a given item in the <tt>FeatureSlider</tt><br />
<tt><i>fs</i>.next(n)</tt>: Go to next item<br />
<tt><i>fs</i>.previous(n)</tt>: Go to previous item<br />
<tt><i>fs</i>.first(n)</tt>: Go to first item<br />
<tt><i>fs</i>.last(n)</tt>: Go to last item</p>
<p>Initiating the code with the <tt>events</tt> arguments allows you to receive callbacks <tt>onLoad</tt> and <tt>onChange</tt>:<br />
<code class="javascript">var fs = new FeatureSlider($('slider'), {<br />
&nbsp;&nbsp;onLoad:function(obj){<br />
&nbsp;&nbsp;&nbsp;&nbsp;alert('Loaded ' + obj.items.length + ' items');<br />
&nbsp;&nbsp;},<br />
&nbsp;&nbsp;onChange:function(obj, index){<br />
&nbsp;&nbsp;&nbsp;&nbsp;alert('Showing ' + index + ' of ' + obj.items.length);<br />
&nbsp;&nbsp;}<br />
});</code></p>
]]></content:encoded>
			<wfw:commentRss>http://www.refresh.dk/featureslider-script/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Do you apologize in code comments?</title>
		<link>http://www.refresh.dk/do-you-apologize-in-code-comments/</link>
		<comments>http://www.refresh.dk/do-you-apologize-in-code-comments/#comments</comments>
		<pubDate>Sun, 30 Dec 2007 21:20:36 +0000</pubDate>
		<dc:creator>Steffen Tiedemann Christensen</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[code]]></category>

		<guid isPermaLink="false">http://www.refresh.dk/do-you-apologize-in-code-comments/</guid>
		<description><![CDATA[Apologetics in comments are usually a sign of the presence of design smell.
&#8722; from webmonkey

]]></description>
			<content:encoded><![CDATA[<blockquote><p>Apologetics in comments are usually a sign of the presence of design smell.<br/><br />
&minus; from <a href="http://www.webmonkey.com/webmonkey/06/18/index4a_page4.html?tw=multimedia">webmonkey</a>
</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.refresh.dk/do-you-apologize-in-code-comments/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
