<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Cynshard&#039;s Blog</title>
	<atom:link href="http://cynshard.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://cynshard.wordpress.com</link>
	<description>Just another WordPress.com weblog</description>
	<lastBuildDate>Mon, 20 Jul 2009 03:08:03 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='cynshard.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Cynshard&#039;s Blog</title>
		<link>http://cynshard.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://cynshard.wordpress.com/osd.xml" title="Cynshard&#039;s Blog" />
	<atom:link rel='hub' href='http://cynshard.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Software development becoming a commodity?</title>
		<link>http://cynshard.wordpress.com/2009/07/15/software-development-becoming-a-commodity/</link>
		<comments>http://cynshard.wordpress.com/2009/07/15/software-development-becoming-a-commodity/#comments</comments>
		<pubDate>Thu, 16 Jul 2009 00:59:21 +0000</pubDate>
		<dc:creator>cynshard</dc:creator>
				<category><![CDATA[process]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://cynshard.wordpress.com/?p=45</guid>
		<description><![CDATA[I had an interesting conversation today about the direction of our industry and the possible (or probable!) commoditization of software development. One of the gentlemen that I was speaking with is convinced that software development is well on the road to becoming a commodity and therefore an unprofitable profession in the US. His argument was [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cynshard.wordpress.com&amp;blog=8354129&amp;post=45&amp;subd=cynshard&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I had an interesting conversation today about the direction of our industry and the possible (or probable!) commoditization of software development. </p>
<p>One of the gentlemen that I was speaking with is convinced that software development is well on the road to becoming a commodity and therefore an unprofitable profession in the US. His argument was that there are tools, on the market today, that allow business people to design and generate things as technical as SOAP interfaces. And that because these tools exist today and will only become more sophisticated that our job as developers will quickly become to expensive to support stateside.</p>
<p>Obviously this is of great concern to me, but I&#8217;m not convinced. I countered this statement with a question about quality. How could such a process deliver a level of quality worthy of trading out a local team for an overseas consulting firm? How is acceptance handled? Who is there to judge quality?</p>
<p>In response, I received the reply that these new tools are starting to decouple the process of software development so that higher quality outsource-based development can occur; and that it <em>will</em> occur with increasing frequency as time goes on.  He went on to say that he imagined that the local team would consist of sales, marketing, product managers, project managers and architects, and that the outsource team would consist of project liasons and software developers.</p>
<p>Indeed I had heard this time and time again, although with less frequency over the past few years. It seems so obvious doesn&#8217;t it?  Software is an abstraction over hardware, and after all, hardware has become a commodity already. It&#8217;s only a matter of time, at least that&#8217;s what the CEOs of the world are hoping.</p>
<p>To anyone who actually practices software development day in and day out, all of this may sound terrifying. Or if you are like me, terribly naive.</p>
<p>I have no doubt in my mind that many attempts will be made to follow this outsourcing model of software development. Some will succeed (as they have int he past) and many will not. Part of this will be due to the general difficulty of founding a successful project, and part of it will be due to the process.  It seems to me that this outsourcing thing is a sort-of sideways evolution of Big Design Up Front (BDUF), a practice which has proven time and time again to be largely ineffective at best and a complete failure at worst.  </p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/cynshard.wordpress.com/45/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/cynshard.wordpress.com/45/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/cynshard.wordpress.com/45/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/cynshard.wordpress.com/45/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/cynshard.wordpress.com/45/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/cynshard.wordpress.com/45/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/cynshard.wordpress.com/45/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/cynshard.wordpress.com/45/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/cynshard.wordpress.com/45/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/cynshard.wordpress.com/45/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/cynshard.wordpress.com/45/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/cynshard.wordpress.com/45/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/cynshard.wordpress.com/45/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/cynshard.wordpress.com/45/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cynshard.wordpress.com&amp;blog=8354129&amp;post=45&amp;subd=cynshard&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://cynshard.wordpress.com/2009/07/15/software-development-becoming-a-commodity/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e39353a46fafa4d177fb86c5142ad2b8?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">cynshard</media:title>
		</media:content>
	</item>
		<item>
		<title>TDD exercise</title>
		<link>http://cynshard.wordpress.com/2009/07/07/tdd-exercise/</link>
		<comments>http://cynshard.wordpress.com/2009/07/07/tdd-exercise/#comments</comments>
		<pubDate>Wed, 08 Jul 2009 04:47:55 +0000</pubDate>
		<dc:creator>cynshard</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[tdd]]></category>

		<guid isPermaLink="false">http://cynshard.wordpress.com/?p=28</guid>
		<description><![CDATA[I&#8217;ve been a fan of TDD for a little while now, but I haven&#8217;t really tried doing a lot of it yet. I just haven&#8217;t found a nice introductory project to try out. Tonight I decided to implement a fuzzy clock (inspired by the nifty mac app FuzzyClock). It turned out to be a fun [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cynshard.wordpress.com&amp;blog=8354129&amp;post=28&amp;subd=cynshard&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been a fan of TDD for a little while now, but I haven&#8217;t really tried doing a lot of it yet. I just haven&#8217;t found a nice introductory project to try out. Tonight I decided to implement a fuzzy clock (inspired by the nifty mac app  <a href="http://www.objectpark.org/FuzzyClock.html">FuzzyClock</a>). It turned out to be a fun exercise. </p>
<p>I was able to keep most of the methods very short and I didn&#8217;t write much code that isn&#8217;t being used. The greatest thing of all is how much confidence I have in this little bit of code.</p>
<p>There are definitely some smells around the special cases and some of the function names, but I&#8217;m ok with that for this project.</p>
<p>Here&#8217;s the python code:</p>
<pre class="python" style="font-family:monospace;"><span style="color:#ff7700;font-weight:bold;">import</span> <span style="color:#dc143c;">unittest</span>
&nbsp;
<span style="color:#ff7700;font-weight:bold;">class</span> FuzzyClock<span style="color:black;">&#40;</span><span style="color:#008000;">object</span><span style="color:black;">&#41;</span>:
    number_map = <span style="color:black;">&#123;</span>
            <span style="color:#ff4500;">1</span> : <span style="color:#483d8b;">&quot;one&quot;</span>,
            <span style="color:#ff4500;">2</span> : <span style="color:#483d8b;">&quot;two&quot;</span>,
            <span style="color:#ff4500;">3</span> : <span style="color:#483d8b;">&quot;three&quot;</span>,
            <span style="color:#ff4500;">4</span> : <span style="color:#483d8b;">&quot;four&quot;</span>,
            <span style="color:#ff4500;">5</span> : <span style="color:#483d8b;">&quot;five&quot;</span>,
            <span style="color:#ff4500;">6</span> : <span style="color:#483d8b;">&quot;six&quot;</span>,
            <span style="color:#ff4500;">7</span> : <span style="color:#483d8b;">&quot;seven&quot;</span>,
            <span style="color:#ff4500;">8</span> : <span style="color:#483d8b;">&quot;eight&quot;</span>,
            <span style="color:#ff4500;">9</span> : <span style="color:#483d8b;">&quot;nine&quot;</span>,
            <span style="color:#ff4500;">10</span>: <span style="color:#483d8b;">&quot;ten&quot;</span>,
            <span style="color:#ff4500;">11</span>: <span style="color:#483d8b;">&quot;eleven&quot;</span>,
            <span style="color:#ff4500;">12</span>: <span style="color:#483d8b;">&quot;twelve&quot;</span>,
            <span style="color:#ff4500;">15</span>: <span style="color:#483d8b;">&quot;quarter&quot;</span>,
            <span style="color:#ff4500;">20</span>: <span style="color:#483d8b;">&quot;twenty&quot;</span>,
            <span style="color:#ff4500;">25</span>: <span style="color:#483d8b;">&quot;twentyfive&quot;</span>,
            <span style="color:#ff4500;">30</span>: <span style="color:#483d8b;">&quot;half&quot;</span>
            <span style="color:black;">&#125;</span>
&nbsp;
    <span style="color:#ff7700;font-weight:bold;">def</span> _convert_hour<span style="color:black;">&#40;</span><span style="color:#008000;">self</span>, hour, minute<span style="color:black;">&#41;</span>:
&nbsp;
        <span style="color:#ff7700;font-weight:bold;">if</span> minute <span style="color:#66cc66;">&gt;</span> 30:
            hour += 1
&nbsp;
        <span style="color:#ff7700;font-weight:bold;">if</span> hour <span style="color:#66cc66;">&gt;</span> 23:
            hour = 0
&nbsp;
        <span style="color:#ff7700;font-weight:bold;">if</span> hour == 12:
            <span style="color:#ff7700;font-weight:bold;">return</span> <span style="color:#483d8b;">&quot;noon&quot;</span>
&nbsp;
        <span style="color:#ff7700;font-weight:bold;">if</span> hour == 0:
            <span style="color:#ff7700;font-weight:bold;">return</span> <span style="color:#483d8b;">&quot;midnight&quot;</span>
&nbsp;
        hour = hour <span style="color:#66cc66;">%</span> 12
&nbsp;
        <span style="color:#ff7700;font-weight:bold;">return</span> <span style="color:#008000;">self</span>.<span style="color:black;">number_map</span><span style="color:black;">&#91;</span>hour<span style="color:black;">&#93;</span>
&nbsp;
    <span style="color:#ff7700;font-weight:bold;">def</span> _get_half<span style="color:black;">&#40;</span><span style="color:#008000;">self</span>, minute<span style="color:black;">&#41;</span>:
        <span style="color:#ff7700;font-weight:bold;">if</span> minute <span style="color:#66cc66;">&lt;</span> 31:
            <span style="color:#ff7700;font-weight:bold;">return</span> <span style="color:#483d8b;">&quot;past&quot;</span>
        <span style="color:#ff7700;font-weight:bold;">else</span>:
            <span style="color:#ff7700;font-weight:bold;">return</span> <span style="color:#483d8b;">&quot;to&quot;</span>
&nbsp;
    <span style="color:#ff7700;font-weight:bold;">def</span> _round_minute<span style="color:black;">&#40;</span><span style="color:#008000;">self</span>, minute<span style="color:black;">&#41;</span>:
        remainder = minute <span style="color:#66cc66;">%</span> 5
        <span style="color:#ff7700;font-weight:bold;">if</span> remainder <span style="color:#66cc66;">&gt;</span> 2:
            <span style="color:#ff7700;font-weight:bold;">return</span> <span style="color:black;">&#40;</span>minute - remainder<span style="color:black;">&#41;</span> + 5
        <span style="color:#ff7700;font-weight:bold;">else</span>:
            <span style="color:#ff7700;font-weight:bold;">return</span> minute - remainder
&nbsp;
    <span style="color:#ff7700;font-weight:bold;">def</span> _shave_minute<span style="color:black;">&#40;</span><span style="color:#008000;">self</span>, minute<span style="color:black;">&#41;</span>:
        <span style="color:#ff7700;font-weight:bold;">if</span> minute <span style="color:#66cc66;">&lt;</span>= 30:
            <span style="color:#ff7700;font-weight:bold;">return</span> minute
        <span style="color:#ff7700;font-weight:bold;">else</span>:
            <span style="color:#ff7700;font-weight:bold;">return</span> 60 - minute
&nbsp;
    <span style="color:#ff7700;font-weight:bold;">def</span> _fetch_minute<span style="color:black;">&#40;</span><span style="color:#008000;">self</span>, minute<span style="color:black;">&#41;</span>:
        <span style="color:#ff7700;font-weight:bold;">return</span> <span style="color:#008000;">self</span>.<span style="color:black;">number_map</span><span style="color:black;">&#91;</span><span style="color:#008000;">self</span>._round_minute<span style="color:black;">&#40;</span><span style="color:#008000;">self</span>._shave_minute<span style="color:black;">&#40;</span>minute<span style="color:black;">&#41;</span><span style="color:black;">&#41;</span><span style="color:black;">&#93;</span>
&nbsp;
    <span style="color:#ff7700;font-weight:bold;">def</span> _convert_minute<span style="color:black;">&#40;</span><span style="color:#008000;">self</span>, hour, minute<span style="color:black;">&#41;</span>:
        <span style="color:#ff7700;font-weight:bold;">if</span> hour <span style="color:#66cc66;">%</span> 12 == 0 <span style="color:#ff7700;font-weight:bold;">and</span> minute == 0:
            <span style="color:#ff7700;font-weight:bold;">return</span> <span style="color:#483d8b;">&quot;&quot;</span>
&nbsp;
        <span style="color:#ff7700;font-weight:bold;">if</span> minute == 0:
            <span style="color:#ff7700;font-weight:bold;">return</span> <span style="color:#483d8b;">&quot;o'clock&quot;</span>
        <span style="color:#ff7700;font-weight:bold;">if</span> minute <span style="color:#66cc66;">&lt;</span> 5:
            <span style="color:#ff7700;font-weight:bold;">return</span> <span style="color:#483d8b;">&quot;shortly after&quot;</span>
        <span style="color:#ff7700;font-weight:bold;">if</span> minute <span style="color:#66cc66;">&gt;</span> 55:
            <span style="color:#ff7700;font-weight:bold;">return</span> <span style="color:#483d8b;">&quot;nearly&quot;</span>
&nbsp;
        <span style="color:#ff7700;font-weight:bold;">return</span> <span style="color:#483d8b;">&quot;%s %s&quot;</span> <span style="color:#66cc66;">%</span> <span style="color:black;">&#40;</span><span style="color:#008000;">self</span>._fetch_minute<span style="color:black;">&#40;</span>minute<span style="color:black;">&#41;</span>, <span style="color:#008000;">self</span>._get_half<span style="color:black;">&#40;</span>minute<span style="color:black;">&#41;</span><span style="color:black;">&#41;</span>
&nbsp;
    <span style="color:#ff7700;font-weight:bold;">def</span> _order_parts<span style="color:black;">&#40;</span><span style="color:#008000;">self</span>, hour, minute<span style="color:black;">&#41;</span>:
        <span style="color:#ff7700;font-weight:bold;">if</span> minute == <span style="color:#483d8b;">&quot;o'clock&quot;</span>:
            <span style="color:#ff7700;font-weight:bold;">return</span> <span style="color:black;">&#40;</span>hour,minute<span style="color:black;">&#41;</span>
        <span style="color:#ff7700;font-weight:bold;">elif</span> minute == <span style="color:#483d8b;">&quot;&quot;</span>:
            <span style="color:#ff7700;font-weight:bold;">return</span> <span style="color:black;">&#40;</span>hour,<span style="color:black;">&#41;</span>
        <span style="color:#ff7700;font-weight:bold;">else</span>:
            <span style="color:#ff7700;font-weight:bold;">return</span> <span style="color:black;">&#40;</span>minute,hour<span style="color:black;">&#41;</span>
&nbsp;
    <span style="color:#ff7700;font-weight:bold;">def</span> convert<span style="color:black;">&#40;</span><span style="color:#008000;">self</span>, hour, minute<span style="color:black;">&#41;</span>:
        formatted_hour = <span style="color:#008000;">self</span>._convert_hour<span style="color:black;">&#40;</span>hour, minute<span style="color:black;">&#41;</span>
        formatted_minute = <span style="color:#008000;">self</span>._convert_minute<span style="color:black;">&#40;</span>hour, minute<span style="color:black;">&#41;</span>
&nbsp;
        <span style="color:#ff7700;font-weight:bold;">return</span> <span style="color:#483d8b;">&quot; &quot;</span>.<span style="color:black;">join</span><span style="color:black;">&#40;</span><span style="color:#008000;">self</span>._order_parts<span style="color:black;">&#40;</span>formatted_hour,formatted_minute<span style="color:black;">&#41;</span><span style="color:black;">&#41;</span>
&nbsp;
<span style="color:#ff7700;font-weight:bold;">class</span> TestFuzzyClock<span style="color:black;">&#40;</span><span style="color:#dc143c;">unittest</span>.<span style="color:black;">TestCase</span><span style="color:black;">&#41;</span>:
&nbsp;
    <span style="color:#ff7700;font-weight:bold;">def</span> setUp<span style="color:black;">&#40;</span><span style="color:#008000;">self</span><span style="color:black;">&#41;</span>:
        <span style="color:#008000;">self</span>.<span style="color:black;">clock</span> = FuzzyClock<span style="color:black;">&#40;</span><span style="color:black;">&#41;</span>
        <span style="color:#008000;">self</span>.<span style="color:black;">hour</span> = 21
        <span style="color:#008000;">self</span>.<span style="color:black;">minute</span> = 0
&nbsp;
    <span style="color:#ff7700;font-weight:bold;">def</span> _set_hour<span style="color:black;">&#40;</span><span style="color:#008000;">self</span>, hour<span style="color:black;">&#41;</span>:
        <span style="color:#008000;">self</span>.<span style="color:black;">hour</span> = hour
&nbsp;
    <span style="color:#ff7700;font-weight:bold;">def</span> _set_minute<span style="color:black;">&#40;</span><span style="color:#008000;">self</span>, minute<span style="color:black;">&#41;</span>:
        <span style="color:#008000;">self</span>.<span style="color:black;">minute</span> = minute
&nbsp;
    <span style="color:#ff7700;font-weight:bold;">def</span> _time_should_be<span style="color:black;">&#40;</span><span style="color:#008000;">self</span>, expected<span style="color:black;">&#41;</span>:
        <span style="color:#008000;">self</span>.<span style="color:black;">assertEqual</span><span style="color:black;">&#40;</span><span style="color:#008000;">self</span>.<span style="color:black;">clock</span>.<span style="color:black;">convert</span><span style="color:black;">&#40;</span><span style="color:#008000;">self</span>.<span style="color:black;">hour</span>, <span style="color:#008000;">self</span>.<span style="color:black;">minute</span><span style="color:black;">&#41;</span>, expected<span style="color:black;">&#41;</span>
&nbsp;
    <span style="color:#ff7700;font-weight:bold;">def</span> test_whole_number<span style="color:black;">&#40;</span><span style="color:#008000;">self</span><span style="color:black;">&#41;</span>:
        <span style="color:#008000;">self</span>._time_should_be<span style="color:black;">&#40;</span><span style="color:#483d8b;">&quot;nine o'clock&quot;</span><span style="color:black;">&#41;</span>
&nbsp;
    <span style="color:#ff7700;font-weight:bold;">def</span> test_shortly_after<span style="color:black;">&#40;</span><span style="color:#008000;">self</span><span style="color:black;">&#41;</span>:
        <span style="color:#008000;">self</span>._set_minute<span style="color:black;">&#40;</span>1<span style="color:black;">&#41;</span>
        <span style="color:#008000;">self</span>._time_should_be<span style="color:black;">&#40;</span><span style="color:#483d8b;">&quot;shortly after nine&quot;</span><span style="color:black;">&#41;</span>
&nbsp;
    <span style="color:#ff7700;font-weight:bold;">def</span> test_five_past<span style="color:black;">&#40;</span><span style="color:#008000;">self</span><span style="color:black;">&#41;</span>:
        <span style="color:#008000;">self</span>._set_minute<span style="color:black;">&#40;</span>5<span style="color:black;">&#41;</span>
        <span style="color:#008000;">self</span>._time_should_be<span style="color:black;">&#40;</span><span style="color:#483d8b;">&quot;five past nine&quot;</span><span style="color:black;">&#41;</span>
&nbsp;
    <span style="color:#ff7700;font-weight:bold;">def</span> test_seven_past<span style="color:black;">&#40;</span><span style="color:#008000;">self</span><span style="color:black;">&#41;</span>:
        <span style="color:#008000;">self</span>._set_minute<span style="color:black;">&#40;</span>7<span style="color:black;">&#41;</span>
        <span style="color:#008000;">self</span>._time_should_be<span style="color:black;">&#40;</span><span style="color:#483d8b;">&quot;five past nine&quot;</span><span style="color:black;">&#41;</span>
&nbsp;
    <span style="color:#ff7700;font-weight:bold;">def</span> test_ten_past<span style="color:black;">&#40;</span><span style="color:#008000;">self</span><span style="color:black;">&#41;</span>:
        <span style="color:#008000;">self</span>._set_minute<span style="color:black;">&#40;</span>10<span style="color:black;">&#41;</span>
        <span style="color:#008000;">self</span>._time_should_be<span style="color:black;">&#40;</span><span style="color:#483d8b;">&quot;ten past nine&quot;</span><span style="color:black;">&#41;</span>
&nbsp;
    <span style="color:#ff7700;font-weight:bold;">def</span> test_twelve_past<span style="color:black;">&#40;</span><span style="color:#008000;">self</span><span style="color:black;">&#41;</span>:
        <span style="color:#008000;">self</span>._set_minute<span style="color:black;">&#40;</span>12<span style="color:black;">&#41;</span>
        <span style="color:#008000;">self</span>._time_should_be<span style="color:black;">&#40;</span><span style="color:#483d8b;">&quot;ten past nine&quot;</span><span style="color:black;">&#41;</span>
&nbsp;
    <span style="color:#ff7700;font-weight:bold;">def</span> test_fourteen_past<span style="color:black;">&#40;</span><span style="color:#008000;">self</span><span style="color:black;">&#41;</span>:
        <span style="color:#008000;">self</span>._set_minute<span style="color:black;">&#40;</span>14<span style="color:black;">&#41;</span>
        <span style="color:#008000;">self</span>._time_should_be<span style="color:black;">&#40;</span><span style="color:#483d8b;">&quot;quarter past nine&quot;</span><span style="color:black;">&#41;</span>
&nbsp;
    <span style="color:#ff7700;font-weight:bold;">def</span> test_quarter_past<span style="color:black;">&#40;</span><span style="color:#008000;">self</span><span style="color:black;">&#41;</span>:
        <span style="color:#008000;">self</span>._set_minute<span style="color:black;">&#40;</span>15<span style="color:black;">&#41;</span>
        <span style="color:#008000;">self</span>._time_should_be<span style="color:black;">&#40;</span><span style="color:#483d8b;">&quot;quarter past nine&quot;</span><span style="color:black;">&#41;</span>
&nbsp;
    <span style="color:#ff7700;font-weight:bold;">def</span> test_eighteen_past<span style="color:black;">&#40;</span><span style="color:#008000;">self</span><span style="color:black;">&#41;</span>:
        <span style="color:#008000;">self</span>._set_minute<span style="color:black;">&#40;</span>18<span style="color:black;">&#41;</span>
        <span style="color:#008000;">self</span>._time_should_be<span style="color:black;">&#40;</span><span style="color:#483d8b;">&quot;twenty past nine&quot;</span><span style="color:black;">&#41;</span>
&nbsp;
    <span style="color:#ff7700;font-weight:bold;">def</span> test_twenty_past<span style="color:black;">&#40;</span><span style="color:#008000;">self</span><span style="color:black;">&#41;</span>:
        <span style="color:#008000;">self</span>._set_minute<span style="color:black;">&#40;</span>20<span style="color:black;">&#41;</span>
        <span style="color:#008000;">self</span>._time_should_be<span style="color:black;">&#40;</span><span style="color:#483d8b;">&quot;twenty past nine&quot;</span><span style="color:black;">&#41;</span>
&nbsp;
    <span style="color:#ff7700;font-weight:bold;">def</span> test_twenty_five_past<span style="color:black;">&#40;</span><span style="color:#008000;">self</span><span style="color:black;">&#41;</span>:
        <span style="color:#008000;">self</span>._set_minute<span style="color:black;">&#40;</span>25<span style="color:black;">&#41;</span>
        <span style="color:#008000;">self</span>._time_should_be<span style="color:black;">&#40;</span><span style="color:#483d8b;">&quot;twentyfive past nine&quot;</span><span style="color:black;">&#41;</span>
&nbsp;
    <span style="color:#ff7700;font-weight:bold;">def</span> test_twenty_nine_past<span style="color:black;">&#40;</span><span style="color:#008000;">self</span><span style="color:black;">&#41;</span>:
        <span style="color:#008000;">self</span>._set_minute<span style="color:black;">&#40;</span>29<span style="color:black;">&#41;</span>
        <span style="color:#008000;">self</span>._time_should_be<span style="color:black;">&#40;</span><span style="color:#483d8b;">&quot;half past nine&quot;</span><span style="color:black;">&#41;</span>
&nbsp;
    <span style="color:#ff7700;font-weight:bold;">def</span> test_half_past<span style="color:black;">&#40;</span><span style="color:#008000;">self</span><span style="color:black;">&#41;</span>:
        <span style="color:#008000;">self</span>._set_minute<span style="color:black;">&#40;</span>30<span style="color:black;">&#41;</span>
        <span style="color:#008000;">self</span>._time_should_be<span style="color:black;">&#40;</span><span style="color:#483d8b;">&quot;half past nine&quot;</span><span style="color:black;">&#41;</span>
&nbsp;
    <span style="color:#ff7700;font-weight:bold;">def</span> test_twenty_five_to<span style="color:black;">&#40;</span><span style="color:#008000;">self</span><span style="color:black;">&#41;</span>:
        <span style="color:#008000;">self</span>._set_minute<span style="color:black;">&#40;</span>35<span style="color:black;">&#41;</span>
        <span style="color:#008000;">self</span>._time_should_be<span style="color:black;">&#40;</span><span style="color:#483d8b;">&quot;twentyfive to ten&quot;</span><span style="color:black;">&#41;</span>
&nbsp;
    <span style="color:#ff7700;font-weight:bold;">def</span> test_twenty_to<span style="color:black;">&#40;</span><span style="color:#008000;">self</span><span style="color:black;">&#41;</span>:
        <span style="color:#008000;">self</span>._set_minute<span style="color:black;">&#40;</span>40<span style="color:black;">&#41;</span>
        <span style="color:#008000;">self</span>._time_should_be<span style="color:black;">&#40;</span><span style="color:#483d8b;">&quot;twenty to ten&quot;</span><span style="color:black;">&#41;</span>
&nbsp;
    <span style="color:#ff7700;font-weight:bold;">def</span> test_quarter_to<span style="color:black;">&#40;</span><span style="color:#008000;">self</span><span style="color:black;">&#41;</span>:
        <span style="color:#008000;">self</span>._set_minute<span style="color:black;">&#40;</span>45<span style="color:black;">&#41;</span>
        <span style="color:#008000;">self</span>._time_should_be<span style="color:black;">&#40;</span><span style="color:#483d8b;">&quot;quarter to ten&quot;</span><span style="color:black;">&#41;</span>
&nbsp;
    <span style="color:#ff7700;font-weight:bold;">def</span> test_ten_to<span style="color:black;">&#40;</span><span style="color:#008000;">self</span><span style="color:black;">&#41;</span>:
        <span style="color:#008000;">self</span>._set_minute<span style="color:black;">&#40;</span>50<span style="color:black;">&#41;</span>
        <span style="color:#008000;">self</span>._time_should_be<span style="color:black;">&#40;</span><span style="color:#483d8b;">&quot;ten to ten&quot;</span><span style="color:black;">&#41;</span>
&nbsp;
    <span style="color:#ff7700;font-weight:bold;">def</span> test_seven_to<span style="color:black;">&#40;</span><span style="color:#008000;">self</span><span style="color:black;">&#41;</span>:
        <span style="color:#008000;">self</span>._set_minute<span style="color:black;">&#40;</span>53<span style="color:black;">&#41;</span>
        <span style="color:#008000;">self</span>._time_should_be<span style="color:black;">&#40;</span><span style="color:#483d8b;">&quot;five to ten&quot;</span><span style="color:black;">&#41;</span>
&nbsp;
    <span style="color:#ff7700;font-weight:bold;">def</span> test_five_to<span style="color:black;">&#40;</span><span style="color:#008000;">self</span><span style="color:black;">&#41;</span>:
        <span style="color:#008000;">self</span>._set_minute<span style="color:black;">&#40;</span>55<span style="color:black;">&#41;</span>
        <span style="color:#008000;">self</span>._time_should_be<span style="color:black;">&#40;</span><span style="color:#483d8b;">&quot;five to ten&quot;</span><span style="color:black;">&#41;</span>
&nbsp;
    <span style="color:#ff7700;font-weight:bold;">def</span> test_nearly<span style="color:black;">&#40;</span><span style="color:#008000;">self</span><span style="color:black;">&#41;</span>:
        <span style="color:#008000;">self</span>._set_minute<span style="color:black;">&#40;</span>58<span style="color:black;">&#41;</span>
        <span style="color:#008000;">self</span>._time_should_be<span style="color:black;">&#40;</span><span style="color:#483d8b;">&quot;nearly ten&quot;</span><span style="color:black;">&#41;</span>
&nbsp;
    <span style="color:#ff7700;font-weight:bold;">def</span> test_thirteen_hundred<span style="color:black;">&#40;</span><span style="color:#008000;">self</span><span style="color:black;">&#41;</span>:
        <span style="color:#008000;">self</span>._set_hour<span style="color:black;">&#40;</span>13<span style="color:black;">&#41;</span>
        <span style="color:#008000;">self</span>._time_should_be<span style="color:black;">&#40;</span><span style="color:#483d8b;">&quot;one o'clock&quot;</span><span style="color:black;">&#41;</span>
&nbsp;
    <span style="color:#ff7700;font-weight:bold;">def</span> test_five_to_noon<span style="color:black;">&#40;</span><span style="color:#008000;">self</span><span style="color:black;">&#41;</span>:
        <span style="color:#008000;">self</span>._set_hour<span style="color:black;">&#40;</span>11<span style="color:black;">&#41;</span>
        <span style="color:#008000;">self</span>._set_minute<span style="color:black;">&#40;</span>55<span style="color:black;">&#41;</span>
        <span style="color:#008000;">self</span>._time_should_be<span style="color:black;">&#40;</span><span style="color:#483d8b;">&quot;five to noon&quot;</span><span style="color:black;">&#41;</span>
&nbsp;
    <span style="color:#ff7700;font-weight:bold;">def</span> test_noon<span style="color:black;">&#40;</span><span style="color:#008000;">self</span><span style="color:black;">&#41;</span>:
        <span style="color:#008000;">self</span>._set_hour<span style="color:black;">&#40;</span>12<span style="color:black;">&#41;</span>
        <span style="color:#008000;">self</span>._time_should_be<span style="color:black;">&#40;</span><span style="color:#483d8b;">&quot;noon&quot;</span><span style="color:black;">&#41;</span>
&nbsp;
    <span style="color:#ff7700;font-weight:bold;">def</span> test_five_to_midnight<span style="color:black;">&#40;</span><span style="color:#008000;">self</span><span style="color:black;">&#41;</span>:
        <span style="color:#008000;">self</span>._set_hour<span style="color:black;">&#40;</span>23<span style="color:black;">&#41;</span>
        <span style="color:#008000;">self</span>._set_minute<span style="color:black;">&#40;</span>55<span style="color:black;">&#41;</span>
        <span style="color:#008000;">self</span>._time_should_be<span style="color:black;">&#40;</span><span style="color:#483d8b;">&quot;five to midnight&quot;</span><span style="color:black;">&#41;</span>
&nbsp;
    <span style="color:#ff7700;font-weight:bold;">def</span> test_two_to_midnight<span style="color:black;">&#40;</span><span style="color:#008000;">self</span><span style="color:black;">&#41;</span>:
        <span style="color:#008000;">self</span>._set_hour<span style="color:black;">&#40;</span>23<span style="color:black;">&#41;</span>
        <span style="color:#008000;">self</span>._set_minute<span style="color:black;">&#40;</span>58<span style="color:black;">&#41;</span>
        <span style="color:#008000;">self</span>._time_should_be<span style="color:black;">&#40;</span><span style="color:#483d8b;">&quot;nearly midnight&quot;</span><span style="color:black;">&#41;</span>
&nbsp;
    <span style="color:#ff7700;font-weight:bold;">def</span> test_midnight<span style="color:black;">&#40;</span><span style="color:#008000;">self</span><span style="color:black;">&#41;</span>:
        <span style="color:#008000;">self</span>._set_hour<span style="color:black;">&#40;</span>0<span style="color:black;">&#41;</span>
        <span style="color:#008000;">self</span>._time_should_be<span style="color:black;">&#40;</span><span style="color:#483d8b;">&quot;midnight&quot;</span><span style="color:black;">&#41;</span>
&nbsp;
    <span style="color:#ff7700;font-weight:bold;">def</span> test_two_past_midnight<span style="color:black;">&#40;</span><span style="color:#008000;">self</span><span style="color:black;">&#41;</span>:
        <span style="color:#008000;">self</span>._set_hour<span style="color:black;">&#40;</span>0<span style="color:black;">&#41;</span>
        <span style="color:#008000;">self</span>._set_minute<span style="color:black;">&#40;</span>2<span style="color:black;">&#41;</span>
        <span style="color:#008000;">self</span>._time_should_be<span style="color:black;">&#40;</span><span style="color:#483d8b;">&quot;shortly after midnight&quot;</span><span style="color:black;">&#41;</span>
&nbsp;
    <span style="color:#ff7700;font-weight:bold;">def</span> test_five_past_midnight<span style="color:black;">&#40;</span><span style="color:#008000;">self</span><span style="color:black;">&#41;</span>:
        <span style="color:#008000;">self</span>._set_hour<span style="color:black;">&#40;</span>0<span style="color:black;">&#41;</span>
        <span style="color:#008000;">self</span>._set_minute<span style="color:black;">&#40;</span>5<span style="color:black;">&#41;</span>
        <span style="color:#008000;">self</span>._time_should_be<span style="color:black;">&#40;</span><span style="color:#483d8b;">&quot;five past midnight&quot;</span><span style="color:black;">&#41;</span>
&nbsp;
<span style="color:#ff7700;font-weight:bold;">if</span> __name__ == <span style="color:#483d8b;">&quot;__main__&quot;</span>:
    <span style="color:#dc143c;">unittest</span>.<span style="color:black;">main</span><span style="color:black;">&#40;</span><span style="color:black;">&#41;</span>
&nbsp;</pre>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/cynshard.wordpress.com/28/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/cynshard.wordpress.com/28/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/cynshard.wordpress.com/28/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/cynshard.wordpress.com/28/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/cynshard.wordpress.com/28/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/cynshard.wordpress.com/28/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/cynshard.wordpress.com/28/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/cynshard.wordpress.com/28/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/cynshard.wordpress.com/28/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/cynshard.wordpress.com/28/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/cynshard.wordpress.com/28/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/cynshard.wordpress.com/28/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/cynshard.wordpress.com/28/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/cynshard.wordpress.com/28/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cynshard.wordpress.com&amp;blog=8354129&amp;post=28&amp;subd=cynshard&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://cynshard.wordpress.com/2009/07/07/tdd-exercise/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e39353a46fafa4d177fb86c5142ad2b8?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">cynshard</media:title>
		</media:content>
	</item>
		<item>
		<title>Specifications</title>
		<link>http://cynshard.wordpress.com/2009/06/29/specifications/</link>
		<comments>http://cynshard.wordpress.com/2009/06/29/specifications/#comments</comments>
		<pubDate>Mon, 29 Jun 2009 04:11:23 +0000</pubDate>
		<dc:creator>cynshard</dc:creator>
				<category><![CDATA[process]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://cynshard.wordpress.com/?p=14</guid>
		<description><![CDATA[I was recently subjected to the news that I would soon be responsible for producing mounds of rigorous technical specifications. The idea being that [one of] the main sources of difficulty with producing quality software was that we simply are not trying hard enough to produce quality documentation at every step of the process. Additionally, [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cynshard.wordpress.com&amp;blog=8354129&amp;post=14&amp;subd=cynshard&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I was recently subjected to the news that I would soon be responsible for producing mounds of rigorous technical specifications.  The idea being that [one of] the main sources of difficulty with producing quality software was that we simply are not trying hard enough to produce quality documentation at every step of the process.</p>
<p>Additionally, it was also brought to my attention that I could expect nothing less from the product owners of our project(s).  The idea again being that we have a bunch of product managers who are causing havok with requirements documents that lack quality.</p>
<p>Now there may be some truth to both of these things, but I find it somewhat confusing that anyone could put much value on incredibly detailed technical specification documents for source code. Especially when the vast majority of the work does not pertain to any sort of public API.</p>
<p>Don&#8217;t get me wrong, I think we need specifications, and they should be detailed. I just disagree with the format. What&#8217;s the point in writing something in a static document that will be shelved, collect dust and never be visited by anyone other than the poor sap who is forced to update it whenever something changes? There is no point; we should be designing our implementations through unit tests, using the tests <em>as</em> the specification. The benefits are substantial. Here are a few of the major reasons why I think that no technical specification should be anything other than tests:</p>
<h4>executable</h4>
<p>The single biggest benefit of unit tests are their executability. This allows for constant monitoring of adherence to the specification (the tests <em>are</em> the specification) by the software. Something a document can never provide.</p>
<h4>safe</h4>
<p>Tests provide a safety net of sorts that allows for incremental improvements to be made to the codebase with confidence. It&#8217;s trivial to become aware of regressions and failures with enough tests wrapped around the code. </p>
<h4>demonstrative</h4>
<p>This point is probably the only area in which a document can compete with a test. Unit tests give programmers who are attempting to learn a system some concrete examples of how the system actually works and how it was intended to be used. A very detailed document <em>can</em> provide this information as well, but what do you think is used to convey examples? That&#8217;s right, code. And if you are going to be writing code why not put it in a test suite and have it constantly verify the implementation rather than rot on a shelf (or in some sort of document repository)?</p>
<p>This leads me to a question; what is the common attitude by upper management? Do documents make high level managers feel warm and fuzzy about the quality of work being done by the developers, quality assurance staff and product managers? If so, why? Is it actually successful, or is it just less terrible than not doing documentation and not doing tests either?</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/cynshard.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/cynshard.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/cynshard.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/cynshard.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/cynshard.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/cynshard.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/cynshard.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/cynshard.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/cynshard.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/cynshard.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/cynshard.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/cynshard.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/cynshard.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/cynshard.wordpress.com/14/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cynshard.wordpress.com&amp;blog=8354129&amp;post=14&amp;subd=cynshard&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://cynshard.wordpress.com/2009/06/29/specifications/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e39353a46fafa4d177fb86c5142ad2b8?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">cynshard</media:title>
		</media:content>
	</item>
		<item>
		<title>rst2pdf shell script</title>
		<link>http://cynshard.wordpress.com/2009/05/12/rst2pdf-shell-script/</link>
		<comments>http://cynshard.wordpress.com/2009/05/12/rst2pdf-shell-script/#comments</comments>
		<pubDate>Tue, 12 May 2009 16:58:00 +0000</pubDate>
		<dc:creator>cynshard</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://cynshard.wordpress.com/2009/05/12/rst2pdf-shell-script/</guid>
		<description><![CDATA[I&#8217;ve recently started working on all documentation in the format of reStructuredText. I really love the simplicity of the format. The fact that it is plain text means I get to use one of the greatest tools out there to work with, vim! There are lots of tools to convert rst formatted files into more [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cynshard.wordpress.com&amp;blog=8354129&amp;post=11&amp;subd=cynshard&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve recently started working on all documentation in the format of <a href="http://docutils.sourceforge.net/rst.html">reStructuredText</a>. I really love the simplicity of the format. The fact that it is plain text means I get to use one of the greatest tools out there to work with, <a href="http://www.vim.org/">vim</a>!
<div></div>
<div>There are lots of tools to convert rst formatted files into more presentable formats but I couldn&#8217;t find any easy ways to convert an rst directly into a pdf file so I wrote this shell script to do it for me:</div>
<p><code><br />#!/bin/bash<br />NAME=`basename $1 | sed 's/\(.*\)\..*/\1/'` <br />rst2latex $1 | latex 1&gt;/dev/null<br />dvipdf texput.dvi <br />mv texput.pdf $NAME.pdf <br />rm texput.*<br /></code></p>
<p>You&#8217;ll need dvipdf and latex available on your system for the script to work.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/cynshard.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/cynshard.wordpress.com/11/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/cynshard.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/cynshard.wordpress.com/11/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/cynshard.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/cynshard.wordpress.com/11/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/cynshard.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/cynshard.wordpress.com/11/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/cynshard.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/cynshard.wordpress.com/11/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/cynshard.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/cynshard.wordpress.com/11/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/cynshard.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/cynshard.wordpress.com/11/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cynshard.wordpress.com&amp;blog=8354129&amp;post=11&amp;subd=cynshard&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://cynshard.wordpress.com/2009/05/12/rst2pdf-shell-script/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e39353a46fafa4d177fb86c5142ad2b8?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">cynshard</media:title>
		</media:content>
	</item>
		<item>
		<title>Arduino NTP Fun</title>
		<link>http://cynshard.wordpress.com/2009/04/09/arduino-ntp-fun/</link>
		<comments>http://cynshard.wordpress.com/2009/04/09/arduino-ntp-fun/#comments</comments>
		<pubDate>Thu, 09 Apr 2009 01:22:00 +0000</pubDate>
		<dc:creator>cynshard</dc:creator>
				<category><![CDATA[arduino]]></category>

		<guid isPermaLink="false">http://cynshard.wordpress.com/2009/04/09/arduino-ntp-fun/</guid>
		<description><![CDATA[Phizone pointed out a post on the arduino forum where billfrog was trying to talk to an NTP server by doing UDP with the ethshield. Billfrog was using the UDP library by Bjorn Hartmann to try to fetch time from time.nist.gov but hadn&#8217;t had much luck yet. This got me interested so I set myself [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cynshard.wordpress.com&amp;blog=8354129&amp;post=10&amp;subd=cynshard&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Phizone pointed out a <a href="http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1238769028">post</a> on the <a href="http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl">arduino forum</a> where billfrog was trying to talk to an NTP server by doing UDP with the <a href="http://www.arduino.cc/en/Main/ArduinoEthernetShield">ethshield</a>. </p>
<p>Billfrog was using the <a href="http://bitbucket.org/bjoern/arduino_osc/">UDP library</a> by Bjorn Hartmann to try to fetch time from time.nist.gov but hadn&#8217;t had much luck yet. This got me interested so I set myself to the task of figuring it out.</p>
<p>After several hours of hacking and learning about UDP and the NTP protocol I managed to fetch time from time.nist.gov. I had to cut some corners since the timestamps come back as 64bit floating point numbers. I decided to throw away the fractional portion and just keep the whole part as an unsigned long.</p>
<p>Some of the fun things you can do with this is synchronize your clock using the <a href="http://www.arduino.cc/playground/Code/DateTime">DateTime</a> library by Mem. So far it seems like the clock is accurate to within a few seconds. I also played with periodic resynchronizing.</p>
<p>I decided to package it up into an easy to use library. The code is <a href="http://github.com/cynshard/arduino-ntp/tree/master">hosted on github</a>.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/cynshard.wordpress.com/10/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/cynshard.wordpress.com/10/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/cynshard.wordpress.com/10/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/cynshard.wordpress.com/10/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/cynshard.wordpress.com/10/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/cynshard.wordpress.com/10/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/cynshard.wordpress.com/10/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/cynshard.wordpress.com/10/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/cynshard.wordpress.com/10/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/cynshard.wordpress.com/10/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/cynshard.wordpress.com/10/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/cynshard.wordpress.com/10/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/cynshard.wordpress.com/10/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/cynshard.wordpress.com/10/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cynshard.wordpress.com&amp;blog=8354129&amp;post=10&amp;subd=cynshard&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://cynshard.wordpress.com/2009/04/09/arduino-ntp-fun/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e39353a46fafa4d177fb86c5142ad2b8?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">cynshard</media:title>
		</media:content>
	</item>
		<item>
		<title>What is eighty percent anyway?</title>
		<link>http://cynshard.wordpress.com/2009/02/09/what-is-eighty-percent-anyway/</link>
		<comments>http://cynshard.wordpress.com/2009/02/09/what-is-eighty-percent-anyway/#comments</comments>
		<pubDate>Mon, 09 Feb 2009 02:00:00 +0000</pubDate>
		<dc:creator>cynshard</dc:creator>
				<category><![CDATA[process]]></category>

		<guid isPermaLink="false">http://cynshard.wordpress.com/2009/02/09/what-is-eighty-percent-anyway/</guid>
		<description><![CDATA[I&#8217;ve been poking around in Code Complete and I ran across a quote I&#8217;ve heard over and over: One common rule of thumb is to plan to specify about 80 percent of the requirements up front. Now, I&#8217;ve heard this many times before I read it in this book but I have a feeling Steve [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cynshard.wordpress.com&amp;blog=8354129&amp;post=9&amp;subd=cynshard&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been poking around in <em>Code Complete</em> and I ran across a quote I&#8217;ve heard over and over:</p>
<blockquote><p>One common rule of thumb is to plan to specify about 80 percent of the requirements up front.</p></blockquote>
<p>Now, I&#8217;ve heard this many times before I read it in this book but I have a feeling Steve McConnel&#8217;s incredibly popular book was the root of the quote (in most of the cases anyhow). I guess my question is, what in the world is 80%?  It seems to me that most folks I talk to are O.K. with this notion of specifying 80% of the requirements before beginning <em>actual</em> work.</p>
<p>Bear with me a moment.  It struck me the other day that if one knows what eighty percent of something is, they must know what 100% of that something is.  Maybe I&#8217;m just not getting it, but I&#8217;ve never worked on anything where I felt it was absolutely complete. I&#8217;ve stopped working on things before, but usually the software isn&#8217;t completely void of requirements; they just keep showing up.</p>
<p>If someone asked you to draw 80% of a line, what would you do? How would you know when you reached 80% of the length of the line? Would you ask them, &#8220;What is the total length of the line?&#8221;. Do you see where I&#8217;m going?</p>
<p>It seems to me that the most logical approach is to try very hard to keep your project flexible in the face of changing requirements and <em>new</em> requirements. It&#8217;s simply impossible to know the future.</p>
<p>That said, I do see a lot of value in doing some design up front, and that knowing when to stop designing and start coding is more of an art than a science. It&#8217;s good to build a plan if for no other reason than to think about what problems you <em>do</em> know.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/cynshard.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/cynshard.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/cynshard.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/cynshard.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/cynshard.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/cynshard.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/cynshard.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/cynshard.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/cynshard.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/cynshard.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/cynshard.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/cynshard.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/cynshard.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/cynshard.wordpress.com/9/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cynshard.wordpress.com&amp;blog=8354129&amp;post=9&amp;subd=cynshard&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://cynshard.wordpress.com/2009/02/09/what-is-eighty-percent-anyway/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e39353a46fafa4d177fb86c5142ad2b8?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">cynshard</media:title>
		</media:content>
	</item>
		<item>
		<title>Books I read in 2008</title>
		<link>http://cynshard.wordpress.com/2008/12/28/books-i-read-in-2008/</link>
		<comments>http://cynshard.wordpress.com/2008/12/28/books-i-read-in-2008/#comments</comments>
		<pubDate>Sun, 28 Dec 2008 07:38:00 +0000</pubDate>
		<dc:creator>cynshard</dc:creator>
				<category><![CDATA[books]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://cynshard.wordpress.com/2008/12/28/books-i-read-in-2008/</guid>
		<description><![CDATA[The following is a list of software engineering books that I read this year: The Pragmatic Programmer Practices of an Agile Developer Head First Design Patterns Ship It! Release It! Don&#8217;t Make Me Think Effective Java Test-Driven Development Refactoring Learning the vi and Vim editors Git Internals Twisted Network Programming Essentials Pragmatic Version Control Using [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cynshard.wordpress.com&amp;blog=8354129&amp;post=8&amp;subd=cynshard&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>The following is a list of software engineering books that I read this year:
<ul>
<li><a href="http://www.pragprog.com/titles/tpp/the-pragmatic-programmer">The Pragmatic Programmer</a></li>
<li><a href="http://www.pragprog.com/titles/pad/practices-of-an-agile-developer">Practices of an Agile Developer</a></li>
<li><a href="http://oreilly.com/catalog/9780596007126/">Head First Design Patterns</a></li>
<li><a href="http://www.pragprog.com/titles/prj/ship-it">Ship It!</a></li>
<li><a href="http://www.pragprog.com/titles/mnee/release-it">Release It!</a></li>
<li><a href="http://www.sensible.com/buythebook.html">Don&#8217;t Make Me Think</a></li>
<li><a href="http://java.sun.com/docs/books/effective/">Effective Java</a></li>
<li><a onclick="return mugicPopWin(this,event);" oncontextmenu="mugicRightClick(this);" href="http://www.amazon.com/Test-Driven-Development-Addison-Wesley-Signature/dp/0321146530">Test-Driven Development</a></li>
<li><a onclick="return mugicPopWin(this,event);" oncontextmenu="mugicRightClick(this);" href="http://www.amazon.com/exec/obidos/ASIN/0201485672">Refactoring</a></li>
<li><a href="http://oreilly.com/catalog/9780596529833/index.html">Learning the vi and Vim editors</a></li>
<li><a href="http://peepcode.com/products/git-internals-pdf">Git Internals</a></li>
<li><a onclick="return mugicPopWin(this,event);" oncontextmenu="mugicRightClick(this);" href="http://www.amazon.com/exec/obidos/ASIN/0596100329/httpitamorg-20?creative=327641&amp;camp=14573&amp;link_code=as1">Twisted Network Programming Essentials</a></li>
<li><a href="http://www.pragprog.com/titles/tsgit/pragmatic-version-control-using-git">Pragmatic Version Control Using Git</a></li>
<li><a href="http://www.pragprog.com/titles/ahptl/pragmatic-thinking-and-learning">Pragmatic Thinking and Learning</a></li>
<li><a onclick="return mugicPopWin(this,event);" oncontextmenu="mugicRightClick(this);" href="http://www.amazon.com/exec/obidos/ASIN/0321437381/poppendieckco-20">Implementing   Lean Software Development:   From Concept to Cash </a></li>
</ul>
<p>The following are the books I have started reading but haven&#8217;t finished yet:
<ul>
<li><a href="http://cc2e.com/">Code Complete</a></li>
<li><a href="http://www.pragprog.com/titles/kpiod/interface-oriented-design">Interface-Oriented Design</a></li>
<li><a href="http://www.google.com/url?sa=t&amp;source=web&amp;ct=res&amp;cd=1&amp;url=http%3A%2F%2Fjcip.net%2F&amp;ei=qDBXSZ90ooG3B-es0bQO&amp;usg=AFQjCNGfVFlaL57UbmlcANk1PMGBj9TbLw&amp;sig2=0eueL-71Db5Y6URM1UelUQ">Java Concurrency In Practice</a></li>
<li><a href="http://djangobook.com/">The Definitive Guide to Django</a></li>
<li><a href="http://www.google.com/url?sa=t&amp;source=web&amp;ct=res&amp;cd=1&amp;url=http%3A%2F%2Fwww.amazon.com%2FSoftware-Development-Principles-Patterns-Practices%2Fdp%2F0135974445&amp;ei=2DBXSefOBYOftwfIr4znBg&amp;usg=AFQjCNFnbEs9Sc-zQJcd-oJzuJmF2NgRoA&amp;sig2=dPw8wMuJxdI0RzrvOMh8Cw">Agile Software Development</a></li>
</ul>
<p>This list if of the books I want to read but don&#8217;t have yet:
<ul>
<li><a onclick="return mugicPopWin(this,event);" oncontextmenu="mugicRightClick(this);" href="http://www.amazon.com/Enterprise-Scrum-Ken-Schwaber/dp/0735623376/ref=pd_ys_ir_b_8">The Enterprise and Scrum</a></li>
<li><a onclick="return mugicPopWin(this,event);" oncontextmenu="mugicRightClick(this);" href="http://www.amazon.com/Lean-Software-Development-Agile-Toolkit/dp/0321150783/ref=pd_ys_ir_b_12">Lean Software Development: an Agile Toolkit</a></li>
<li><a onclick="return mugicPopWin(this,event);" oncontextmenu="mugicRightClick(this);" href="http://www.amazon.com/Programming-Pearls-2nd-ACM-Press/dp/0201657880/ref=pd_ys_ir_b_49">Programming Pearls</a></li>
</ul>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/cynshard.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/cynshard.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/cynshard.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/cynshard.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/cynshard.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/cynshard.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/cynshard.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/cynshard.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/cynshard.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/cynshard.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/cynshard.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/cynshard.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/cynshard.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/cynshard.wordpress.com/8/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cynshard.wordpress.com&amp;blog=8354129&amp;post=8&amp;subd=cynshard&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://cynshard.wordpress.com/2008/12/28/books-i-read-in-2008/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e39353a46fafa4d177fb86c5142ad2b8?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">cynshard</media:title>
		</media:content>
	</item>
		<item>
		<title>Working with an Arduino remotely</title>
		<link>http://cynshard.wordpress.com/2008/12/01/working-with-an-arduino-remotely/</link>
		<comments>http://cynshard.wordpress.com/2008/12/01/working-with-an-arduino-remotely/#comments</comments>
		<pubDate>Mon, 01 Dec 2008 01:12:00 +0000</pubDate>
		<dc:creator>cynshard</dc:creator>
				<category><![CDATA[arduino]]></category>

		<guid isPermaLink="false">http://cynshard.wordpress.com/2008/12/01/working-with-an-arduino-remotely/</guid>
		<description><![CDATA[I&#8217;ve been indirectly playing with a freeduino serial 2.0 lately. Phizone has the actual hardware and I&#8217;ve been helping him debug some sketches. Today I managed to compile and run a sketch on the freeduino from the command line over ssh. There are some terse instructions on how to do this at the arduino site. [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cynshard.wordpress.com&amp;blog=8354129&amp;post=7&amp;subd=cynshard&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been indirectly playing with a freeduino serial 2.0 lately. Phizone has the actual hardware and I&#8217;ve been helping him debug some sketches. Today I managed to compile and run a sketch on the freeduino from the command line over ssh.</p>
<p>There are some <a href="http://arduino.cc/en/Hacking/CommandLine">terse instructions</a> on how to do this at the <a href="http://arduino.cc/">arduino site</a>.</p>
<p>The remote machine I&#8217;m using already had all the avr tools installed so I figured it&#8217;d be straightforward to get a sketch compiled and running, and I was mostly right.</p>
<p>The idea is to simply copy the Makefile packaged in the command line hacking guide tarball into your sketch folder and customize it for the sketch. This usually amounts to configuring the name of your sketch, the serial port you want to use, the microcontroller you are using and a few other options.</p>
<p>So I cracked open the Makefile and made the changes I thought were appropriate to run the <a href="http://arduino.cc/en/Tutorial/Blink">Blink sketch</a>. Here are the configurable bits in the Makefile that I started with:</p>
<p><code><br />TARGET = Blink2<br />INSTALL_DIR = ~/arduino-0012<br />PORT = /dev/ttyS0<br />UPLOAD_RATE = 19200<br />AVRDUDE_PROGRAMMER = stk500v1<br />MCU = atmega168<br />F_CPU = 16000000<br /></code></p>
<p>I ran `make` and received a page full of errors. Apparently my install of the arduino IDE wasn&#8217;t configured just right for using this make file so I put things where the Makefile was looking.</p>
<p>This amounted to adding an tools/avr/bin and tools/avr/etc directory and symlinking in the executables necessary to build. These were:</p>
<p><code><br />avr-ar  avrdude  avr-g++  avr-gcc  avr-objcopy  avr-size<br /></code></p>
<p>In the tools/avr/etc directory I put the avrdude.conf file that came with the ide install.</p>
<p>After doing that I ran `make clean all` again and was successful.</p>
<p><code><br /> text    data     bss     dec     hex filename<br />    0    1118       0    1118     45e applet/Blink2.hex<br /></code></p>
<p>Now I wanted to upload to the freeduino. So I took another peek at the Makefile and found the &#8216;upload&#8217; directive. So I gave it a shot:</p>
<p><code><br />avrdude: stk500_recv(): programmer is not responding<br />avrdude: stk500_recv(): programmer is not responding<br />make: *** [upload] Error 1<br /></code></p>
<p>Bummer. Apparently you have to reset the thing before you can upload a new sketch. The newest IDE does this for you by toggling the DTS bit on the serial device before uploading a new sketch so I built a small python app to do that for me.</p>
<p><code><br />#!/usr/bin/env python<br />import time<br />import serial</p>
<p>ser = serial.Serial('/dev/ttyS0', 19200, timeout=1)<br />ser.setDTR(0)<br />time.sleep(0.1)<br />ser.setDTR(1)<br />ser.close()<br /></code></p>
<p>The serial library is <a href="http://pyserial.wiki.sourceforge.net/pySerial">here</a>; or in Debian you can do apt-get install python-serial.</p>
<p>So I toggle the bit and give it another shot. No go. What gives? At this point I ask Phizone to figure out exactly how the IDE is using avrdude and compare it to the Makefile.</p>
<p>IDE<br /><code><br />/arduino-0012$ hardware/tools/avrdude -Chardware/tools/avrdude.conf -v -v -v -v -pm168 -cstk500v1 -P/dev/ttyS0 -b19200 -D -Uflash:w:/home/phizone/sketchbook/Blink2/applet/Blink2.hex:i</code></p>
<p>Makefile<br /><code><br />/arduino-0012$ hardware/tools/avrdude -V -F -C hardware/tools/avrdude.conf -p atmega168 -c stk500v1 -P /dev/ttyS0 -b 19200 -U flash:w:/home/wcoyote/sketchbook/Blink2/applet/Blink2.hex</code></p>
<p>Well it isn&#8217;t terribly different, but it is different. So I hacked the Makefile again to make the commands the same:</p>
<p><code><br />AVRDUDE_WRITE_FLASH = -Uflash:w:applet/$(TARGET).hex:i<br />AVRDUDE_FLAGS = -v -v -v -v -C$(INSTALL_DIR)/hardware/tools/avr/etc/avrdude.<br />-p$(MCU) -P$(AVRDUDE_PORT) -c$(AVRDUDE_PROGRAMMER) \<br />-b$(UPLOAD_RATE) -D<br /></code></p>
<p>And try it again&#8230;</p>
<p><code><br />avrdude done.  Thank you.<br /></code></p>
<p>And, according to phizone, I had a blinking LED.</p>
<p>One last note, I&#8217;m not sure why the -p option used by the IDE is <code>m168</code> and not <code>atmega168</code> but if you don&#8217;t use <code>atmega168</code> compilation seems to fail.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/cynshard.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/cynshard.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/cynshard.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/cynshard.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/cynshard.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/cynshard.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/cynshard.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/cynshard.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/cynshard.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/cynshard.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/cynshard.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/cynshard.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/cynshard.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/cynshard.wordpress.com/7/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cynshard.wordpress.com&amp;blog=8354129&amp;post=7&amp;subd=cynshard&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://cynshard.wordpress.com/2008/12/01/working-with-an-arduino-remotely/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e39353a46fafa4d177fb86c5142ad2b8?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">cynshard</media:title>
		</media:content>
	</item>
		<item>
		<title>Comprehensions and Generators</title>
		<link>http://cynshard.wordpress.com/2008/11/22/comprehensions-and-generators/</link>
		<comments>http://cynshard.wordpress.com/2008/11/22/comprehensions-and-generators/#comments</comments>
		<pubDate>Sat, 22 Nov 2008 02:22:00 +0000</pubDate>
		<dc:creator>cynshard</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://cynshard.wordpress.com/2008/11/22/comprehensions-and-generators/</guid>
		<description><![CDATA[Here are a couple nifty ways to compress iteration in python. List Comprehensions Generator Expressions They are both similar to one another; the main difference is that list comprehensions return a list and generator expressions return a generator. Here are a few examples [1]: &#62;&#62;&#62; x = [chr(i) for i in range(65,91)] &#62;&#62;&#62; x ['A', [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cynshard.wordpress.com&amp;blog=8354129&amp;post=6&amp;subd=cynshard&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Here are a couple nifty ways to compress iteration in python.</p>
<ol class="arabic simple">
<li><a class="reference external" href="http://docs.python.org/tutorial/datastructures.html#list-comprehensions">List Comprehensions</a></li>
<li><a class="reference external" href="http://docs.python.org/tutorial/classes.html#generator-expressions">Generator Expressions</a></li>
</ol>
<p>They are both similar to one another; the main difference is that list comprehensions return a list and generator expressions return a generator.</p>
<p>Here are a few examples <a id="id1" class="footnote-reference" href="#id2">[1]</a>:</p>
<p><code>&gt;&gt;&gt; x = [chr(i) for i in range(65,91)]<br />
&gt;&gt;&gt; x<br />
['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O',<br />
'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z']<br />
</code></p>
<p>This is a short and elegant way to write the following:</p>
<p><code>x = []<br />
for i in range(65,91):<br />
x.append( chr(i) )<br />
</code></p>
<p>Here&#8217;s the same thing in generator form:</p>
<p><code>&gt;&gt;&gt; y = (chr(i) for i in range(65,91))<br />
&gt;&gt;&gt; y</code></p>
<p>&gt;&gt;&gt; list(y)<br />
['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O',<br />
'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z']</p>
<p>Here is a more pragmatic use of a generator expression.</p>
<p><code>&gt;&gt;&gt; unencoded = "foo=bar&amp;baz=boo"<br />
&gt;&gt;&gt; "".join("%s" % hex(ord(c))[2:] for c in unencoded)<br />
'666f6f3d6261722662617a3d626f6f'<br />
</code></p>
<p>Here&#8217;s the above example in a more verbose format:</p>
<p><code>tmp = []<br />
for c in unencoded:<br />
bin_hex = "%s" % hex(ord(c))[2:]<br />
tmp.append(bin_hex)<br />
"".join(tmp) </code></p>
<p>And here is one final example with some <a class="reference external" href="http://www.mathcam.org/CoolNumbers/CoolNumbers.html">math geekery</a>:<br />
<code>&gt;&gt;&gt; [x ** 2 + x + 41 for x in range(1,42)]<br />
[43, 47, 53, 61, 71, 83, 97, 113, 131, 151, 173, 197, 223, 251, 281, 313,<br />
347, 383, 421, 461, 503, 547, 593, 641, 691, 743, 797, 853, 911, 971, 1033,<br />
    1097, 1163, 1231, 1301, 1373, 1447, 1523, 1601, 1681, 1763]<br />
</code></p>
<h4>Footnotes</h4>
<p><a href="#id1">[1]</a></p>
<p>The first two examples are a little contrived. These tasks might be simpler solved by using the <a class="reference external" href="http://docs.python.org/library/functions.html#map">map</a> builtin or the <a class="reference external" href="http://docs.python.org/library/itertools.html#itertools.imap">imap</a> function in the <a class="reference external" href="http://docs.python.org/library/itertools.html">itertools</a> module.</p>
<p> <code>&gt;&gt;&gt; map(chr, range(65, 91))<br />
['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N',<br />
'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z']<br />
</code></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/cynshard.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/cynshard.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/cynshard.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/cynshard.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/cynshard.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/cynshard.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/cynshard.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/cynshard.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/cynshard.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/cynshard.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/cynshard.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/cynshard.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/cynshard.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/cynshard.wordpress.com/6/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cynshard.wordpress.com&amp;blog=8354129&amp;post=6&amp;subd=cynshard&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://cynshard.wordpress.com/2008/11/22/comprehensions-and-generators/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e39353a46fafa4d177fb86c5142ad2b8?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">cynshard</media:title>
		</media:content>
	</item>
		<item>
		<title>vim2gtksourceview2 script</title>
		<link>http://cynshard.wordpress.com/2007/12/02/vim2gtksourceview2-script/</link>
		<comments>http://cynshard.wordpress.com/2007/12/02/vim2gtksourceview2-script/#comments</comments>
		<pubDate>Sun, 02 Dec 2007 05:23:00 +0000</pubDate>
		<dc:creator>cynshard</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://cynshard.wordpress.com/2007/12/02/vim2gtksourceview2-script/</guid>
		<description><![CDATA[I played around with Ubuntu 7.10 tribe 3 and one of the cool new things for me was the upgrade of gtksourceview to version 2.0. Gtksourceview is the widget that gedit uses to display and edit text. It also provides syntax highlighting. The new version of gtksourceview allows for syntax highlighting themes like you see [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cynshard.wordpress.com&amp;blog=8354129&amp;post=5&amp;subd=cynshard&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I played around with Ubuntu 7.10 tribe 3 and one of the cool new things for me was the upgrade of gtksourceview to version 2.0. Gtksourceview is the widget that gedit uses to display and edit text. It also provides syntax highlighting. The new version of gtksourceview allows for syntax highlighting themes like you see in many other popular editors.</p>
<p>Just as Ubuntu Gutsy Gibbon was released I decided to write a script that converts vim themes to gtksourceview2 format. I opened up <a href="http://code.google.com/p/vim2gtksourceview2/">a google code project</a> for it and set up the <a href="http://vim2gtksourceview2.googlecode.com/svn/">svn repo</a> and uploaded an <a href="http://vim2gtksourceview2.googlecode.com/files/vim2gtksourceview2-0.1.tar.gz">archive</a>. The script is very simple to use and works well for me.</p>
<p>Here is the simple syntax for its use:<br />
<code>./vim2gtksourceview.py &lt; input.vim &gt; output.xml</code></p>
<p>Disclaimer: many vim themes do not implement many features provided by both vim and gtksourceview, (current line highlighting being a big one) so the converted themes may need a little tweaking afterward.</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/cynshard.wordpress.com/5/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/cynshard.wordpress.com/5/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/cynshard.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/cynshard.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/cynshard.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/cynshard.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/cynshard.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/cynshard.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/cynshard.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/cynshard.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/cynshard.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/cynshard.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/cynshard.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/cynshard.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/cynshard.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/cynshard.wordpress.com/5/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cynshard.wordpress.com&amp;blog=8354129&amp;post=5&amp;subd=cynshard&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://cynshard.wordpress.com/2007/12/02/vim2gtksourceview2-script/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e39353a46fafa4d177fb86c5142ad2b8?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">cynshard</media:title>
		</media:content>
	</item>
	</channel>
</rss>
