<?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>Bagonca</title>
	<atom:link href="http://www.bagonca.com/blog/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.bagonca.com/blog</link>
	<description>Yet another developer blog</description>
	<lastBuildDate>Fri, 18 Jun 2010 09:28:59 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Use tap events instead of click events in iPhone browser</title>
		<link>http://www.bagonca.com/blog/2010/06/18/use-tap-events-instead-of-click-events-in-iphone-browser/</link>
		<comments>http://www.bagonca.com/blog/2010/06/18/use-tap-events-instead-of-click-events-in-iphone-browser/#comments</comments>
		<pubDate>Fri, 18 Jun 2010 09:17:28 +0000</pubDate>
		<dc:creator>Jon</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[projectplace]]></category>

		<guid isPermaLink="false">http://www.bagonca.com/blog/?p=851</guid>
		<description><![CDATA[When working on a web app for embedding in a iPhone application we came across jQTouch, a really nifty little jQuery plugin which makes it easy to create a web application UI that really resembles that of a native iPhone application.
We soon encountered a problem due to the fact that click events are rather slow [...]]]></description>
			<content:encoded><![CDATA[<p>When working on a web app for embedding in a iPhone application we came across <a title="jQTouch" href="http://jqtouch.com/">jQTouch</a>, a really nifty little jQuery plugin which makes it easy to create a web application UI that really resembles that of a native iPhone application.</p>
<p>We soon encountered a problem due to the fact that click events are rather slow to fire on the iPhone. There is a delay due to the fact that the iPhone waits for the user to complete a gesture before deciding that the intended gesture was in fact a click.</p>
<p>JQTouch uses divs to navigate between screens, so for example if you have the div</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>div id<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;primary-view&quot;</span><span style="color: #339933;">&gt;&lt;/</span>div<span style="color: #339933;">&gt;</span></pre></div></div>

<p>you can simply navigate to it through a normal anchor link, and the transition will thanks to jQTouch be really &#8220;iPhone like&#8221;.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>a href<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;#primary-view&quot;</span><span style="color: #339933;">&gt;</span>Primary view<span style="color: #339933;">&lt;/</span>a<span style="color: #339933;">&gt;</span></pre></div></div>

<p>Our main problem is that we load our content dynamically through Ajax. So our links looked like this:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>a onclick<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;fetchContent();&quot;</span> href<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;#primary-view&quot;</span><span style="color: #339933;">&gt;</span>Primary view<span style="color: #339933;">&lt;/</span>a<span style="color: #339933;">&gt;</span></pre></div></div>

<p>This resulted in a race condition. The anchor link listens to the tap event which is fired much earlier than the click event, and therefore we mostly ended up in empty views. So we needed to replace all onclicks to ontap listeners. The problem then is that we could no longer test our webapp in a normal desktop based Safari browser.</p>
<p>So, we decided to happily go along and write inline onclick events on our links and other interaction elements. But while in the iPhone we see to it that the onClicks are removed and replaced with tap listeners.</p>
<p>That function looks like this:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">function</span> rebindClicks<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
    <span style="color: #003366; font-weight: bold;">var</span> userAgent <span style="color: #339933;">=</span> navigator.<span style="color: #660066;">userAgent</span>.<span style="color: #660066;">toLowerCase</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #003366; font-weight: bold;">var</span> isIphone <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>userAgent.<span style="color: #660066;">indexOf</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'iphone'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">!=</span> <span style="color: #339933;">-</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">?</span> <span style="color: #003366; font-weight: bold;">true</span> <span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>isIphone<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #006600; font-style: italic;">// For each event with an inline onclick</span>
        $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'[onclick]'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">each</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #003366; font-weight: bold;">var</span> onclick <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'onclick'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">removeAttr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'onclick'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// Remove the onclick attribute</span>
            $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">bind</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;click&quot;</span><span style="color: #339933;">,</span> preventClickEvent<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// See to it that clicks never happen</span>
            $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">bind</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'tap'</span><span style="color: #339933;">,</span> onclick<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// Point taps to the onclick</span>
        <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">function</span> preventClickEvent<span style="color: #009900;">&#40;</span>event<span style="color: #009900;">&#41;</span>  <span style="color: #009900;">&#123;</span>
    event.<span style="color: #660066;">preventDefault</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>We now call this little function everytime the DOM is changed. If something turns up with an inline onclick. It is will be rerouted by jQuery to a tap listener instead.</p>
<p>Again, we felt we needed to do this because many of our developers do not have a Mac (and hence do not have the iPhone simulator). And testing on the iPhone can be really time consuming. So for testing during development we wanted to use onClick, and when testing on iPhone we wanted to use taps instead.</p>
<p>But the biggest bonus was without a doubt that things are overall <em>much faster</em> in the web application. Taps fire much faster than clicks in the iPhone.</p>
<p>Here&#8217;s how it looks running the same app both in desktop safari and embedded into the iPhone simulator.</p>
<p><object id="scPlayer" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="862" height="746" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="quality" value="high" /><param name="bgcolor" value="#FFFFFF" /><param name="flashVars" value="thumb=http://content.screencast.com/users/omgwtflolomg/folders/Jing/media/4df1e2fe-264d-4de7-b72c-4e83d2338601/FirstFrame.jpg&amp;containerwidth=862&amp;containerheight=746&amp;content=http://content.screencast.com/users/omgwtflolomg/folders/Jing/media/4df1e2fe-264d-4de7-b72c-4e83d2338601/00000050.swf" /><param name="allowFullScreen" value="true" /><param name="scale" value="showall" /><param name="allowScriptAccess" value="always" /><param name="base" value="http://content.screencast.com/users/omgwtflolomg/folders/Jing/media/4df1e2fe-264d-4de7-b72c-4e83d2338601/" /><param name="src" value="http://content.screencast.com/users/omgwtflolomg/folders/Jing/media/4df1e2fe-264d-4de7-b72c-4e83d2338601/jingswfplayer.swf" /><param name="flashvars" value="thumb=http://content.screencast.com/users/omgwtflolomg/folders/Jing/media/4df1e2fe-264d-4de7-b72c-4e83d2338601/FirstFrame.jpg&amp;containerwidth=862&amp;containerheight=746&amp;content=http://content.screencast.com/users/omgwtflolomg/folders/Jing/media/4df1e2fe-264d-4de7-b72c-4e83d2338601/00000050.swf" /><param name="allowfullscreen" value="true" /><embed id="scPlayer" type="application/x-shockwave-flash" width="862" height="746" src="http://content.screencast.com/users/omgwtflolomg/folders/Jing/media/4df1e2fe-264d-4de7-b72c-4e83d2338601/jingswfplayer.swf" base="http://content.screencast.com/users/omgwtflolomg/folders/Jing/media/4df1e2fe-264d-4de7-b72c-4e83d2338601/" allowscriptaccess="always" scale="showall" allowfullscreen="true" flashvars="thumb=http://content.screencast.com/users/omgwtflolomg/folders/Jing/media/4df1e2fe-264d-4de7-b72c-4e83d2338601/FirstFrame.jpg&amp;containerwidth=862&amp;containerheight=746&amp;content=http://content.screencast.com/users/omgwtflolomg/folders/Jing/media/4df1e2fe-264d-4de7-b72c-4e83d2338601/00000050.swf" bgcolor="#FFFFFF" quality="high"></embed></object></p>
]]></content:encoded>
			<wfw:commentRss>http://www.bagonca.com/blog/2010/06/18/use-tap-events-instead-of-click-events-in-iphone-browser/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Rule 4: Use Only One Dot Per Line</title>
		<link>http://www.bagonca.com/blog/2010/01/27/rule-4-use-only-one-dot-per-line/</link>
		<comments>http://www.bagonca.com/blog/2010/01/27/rule-4-use-only-one-dot-per-line/#comments</comments>
		<pubDate>Wed, 27 Jan 2010 11:08:16 +0000</pubDate>
		<dc:creator>Jon</dc:creator>
				<category><![CDATA[Developer]]></category>
		<category><![CDATA[Values]]></category>

		<guid isPermaLink="false">http://www.bagonca.com/blog/?p=823</guid>
		<description><![CDATA[Using only one dot per line? With all the help you get from IDE:s to complete long lines, why? Well because great software architecture, especiall]]></description>
			<content:encoded><![CDATA[<p>This is the fourth part of <a href="http://www.bagonca.com/blog/2010/01/21/nine-steps-to-better-software-design-today-thoughtworks-exercise/" target="_self">a series of articles starting here</a>.</p>
<p>The fourth rule of the exercise is to only use one dot per line. Why is that important? Well apart from the apparent readability increase, many dots one one line can signify that an <strong>activity is happening in the wrong place</strong>. Or maybe your object is dealing with <strong>two other objects at the same time</strong>.</p>
<p>In both these cases you are not fully implementing the object oriented paradigm. Objects are supposed to know something about their immediate &#8220;friends&#8221; but not about their friend&#8217;s friends.</p>
<p>This is an example of a quite broken implementation.</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> TimeLineObject extends UIComponent <span style="color: #000000;">&#123;</span>
    ....
    <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> redraw<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span> <span style="color: #000000;">&#123;</span>
        TimeLineDrawer.theInstance.drawTimeLine<span style="color: #000000;">&#40;</span>TimeLineDrawer.theInstance.timeLineCanvas<span style="color: #000000;">&#41;</span>;
    <span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

<p>To follow the rule of this exercise you might be tempted to remove the number of dots per line by doing something like this:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> TimeLineObject extends UIComponent <span style="color: #000000;">&#123;</span>
    ....
    <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> redraw<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span> <span style="color: #000000;">&#123;</span>
        <span style="color: #6699cc; font-weight: bold;">var</span> timeLineDrawerSingleton<span style="color: #000000; font-weight: bold;">:</span>TimeLineDrawer = TimeLineDrawer.theInstance;
        <span style="color: #6699cc; font-weight: bold;">var</span> canvas<span style="color: #000000; font-weight: bold;">:</span>Canvas = timeLineDrawerSingleton.timeLineCanvas;
        timeLineDrawerSingleton.drawTimeLine<span style="color: #000000;">&#40;</span>canvas<span style="color: #000000;">&#41;</span>;
    <span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

<p>But this is hardly the point. It is very apparent in the above example that the activity as a whole is not in the correct place. In the <code>TimeLineObject</code> we are suddenly telling some remote singleton static object to carry out things for us. Our object knows to much and the architecture has in fact failed at some earlier point.</p>
<p>The example from the Thoughtworks book is excellent. It shows the correct way to think about the exercise, namely to put activities in its right place. I will quote it below. First the &#8220;erroneous&#8221; example:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">class</span> Board <span style="color: #009900;">&#123;</span>
  ...
  <span style="color: #000000; font-weight: bold;">class</span> Piece <span style="color: #009900;">&#123;</span>
     ...
     <span style="color: #003399;">String</span> representation<span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
  <span style="color: #000000; font-weight: bold;">class</span> Location <span style="color: #009900;">&#123;</span>
      ...
      <span style="color: #006633;">Piece</span> current<span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
  <span style="color: #003399;">String</span> boardRepresentation<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #003399;">StringBuffer</span> buf <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">StringBuffer</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #000000; font-weight: bold;">for</span><span style="color: #009900;">&#40;</span>Location l <span style="color: #339933;">:</span> squares<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
      <span style="color: #009900;">&#123;</span>
          <span style="color: #666666; font-style: italic;">// Oh lord lots of dots here... :)</span>
          buf.<span style="color: #006633;">append</span><span style="color: #009900;">&#40;</span>l.<span style="color: #006633;">current</span>.<span style="color: #006633;">representation</span>.<span style="color: #006633;">substring</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span>, <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #009900;">&#125;</span>
      <span style="color: #000000; font-weight: bold;">return</span> buf.<span style="color: #006633;">toString</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Applying the rules of having one dot per line here actually means REAL refactoring. I.e putting stuff where it belongs. And that is usually in other classes. Here&#8217;s the refactored example:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">class</span> Board <span style="color: #009900;">&#123;</span>
   ...
   <span style="color: #000000; font-weight: bold;">class</span> Piece <span style="color: #009900;">&#123;</span>
      ...
      <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">String</span> representation<span style="color: #339933;">;</span>
&nbsp;
      <span style="color: #003399;">String</span> character<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
          <span style="color: #000000; font-weight: bold;">return</span> representation.<span style="color: #006633;">substring</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span>, <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #009900;">&#125;</span>
      <span style="color: #000066; font-weight: bold;">void</span> addTo<span style="color: #009900;">&#40;</span><span style="color: #003399;">StringBuffer</span> buf<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
          buf.<span style="color: #006633;">append</span><span style="color: #009900;">&#40;</span>character<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #009900;">&#125;</span>
   <span style="color: #009900;">&#125;</span>
&nbsp;
   <span style="color: #000000; font-weight: bold;">class</span> Location <span style="color: #009900;">&#123;</span>
      ...
      <span style="color: #000000; font-weight: bold;">private</span> Piece current<span style="color: #339933;">;</span>
&nbsp;
      <span style="color: #000066; font-weight: bold;">void</span> addTo<span style="color: #009900;">&#40;</span><span style="color: #003399;">StringBuffer</span> buf<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
          current.<span style="color: #006633;">addTo</span><span style="color: #009900;">&#40;</span>buf<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #009900;">&#125;</span>
   <span style="color: #009900;">&#125;</span>
&nbsp;
   <span style="color: #003399;">String</span> boardRepresentation<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
       <span style="color: #003399;">StringBuffer</span> buf <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">StringBuffer</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
       <span style="color: #000000; font-weight: bold;">for</span><span style="color: #009900;">&#40;</span>Location l <span style="color: #339933;">:</span> squares<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
           l.<span style="color: #006633;">addTo</span><span style="color: #009900;">&#40;</span>buf<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
       <span style="color: #000000; font-weight: bold;">return</span> buf.<span style="color: #006633;">toString</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>So, the lesson from this exercise is that you should put activities where they belong. Avoid using static utility classes and other &#8220;middleman&#8221; objects. And make sure that the object you are working in does not now to much about other object&#8217;s activities. Couple this with the previous rules and you have gone far in a sturdy, nice looking design.</p>
<p>Previous « <a href="http://www.bagonca.com/blog/2010/01/25/rule-3-wrap-all-primitives-and-strings/">Rule 3: Wrap All Primitives and Strings</a><br />
Next &raquo; Rule 5: Don&#8217;t Abbreviate</p>
]]></content:encoded>
			<wfw:commentRss>http://www.bagonca.com/blog/2010/01/27/rule-4-use-only-one-dot-per-line/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Rule 3: Wrap All Primitives and Strings</title>
		<link>http://www.bagonca.com/blog/2010/01/25/rule-3-wrap-all-primitives-and-strings/</link>
		<comments>http://www.bagonca.com/blog/2010/01/25/rule-3-wrap-all-primitives-and-strings/#comments</comments>
		<pubDate>Mon, 25 Jan 2010 13:11:00 +0000</pubDate>
		<dc:creator>Jon</dc:creator>
				<category><![CDATA[Developer]]></category>
		<category><![CDATA[Values]]></category>
		<category><![CDATA[software design]]></category>
		<category><![CDATA[ThoughtWorks]]></category>

		<guid isPermaLink="false">http://www.bagonca.com/blog/?p=804</guid>
		<description><![CDATA[Wrapping primitives and strings is a good habit. It increases the architectural value, and potential reuse of your code.]]></description>
			<content:encoded><![CDATA[<p>This is the third part of <a href="http://www.bagonca.com/blog/2010/01/21/nine-steps-to-better-software-design-today-thoughtworks-exercise/" target="_self">a series of articles starting here</a>.</p>
<p>Wrapping primitives (ints, floats etc) and strings is an easy way to increase maintainability and readability of your code. Also, as <strong id="commentauthor-272">Abinesh TD </strong><span id="commentauthor-272">has commented below, wrapping expresses intent of data, preventing misuse. </span>Consider for example the following pseudo-javacode:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Contact <span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">String</span> emailAddress<span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> setEmail<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> emailAddress<span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> InvalidEmailException <span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span> validateEmail<span style="color: #009900;">&#40;</span>emailAddress<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000000; font-weight: bold;">throw</span> <span style="color: #000000; font-weight: bold;">new</span> InvalidEmailException<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Uhm, that's not a valid mail address...&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
        <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">emailAddress</span> <span style="color: #339933;">=</span> emailAddress<span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">String</span> getEmail<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">return</span> emailAddress<span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">Boolean</span> validateEmail<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> emailAddress<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #666666; font-style: italic;">// TODO: validation regexp etc</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>A very simple class, containing a single field intended to hold an email address. It looks good enough, but imagine that you have other places where you would need to validate and store email addresses. You would have a tendency for code duplication right there.</p>
<p>Worst case would be that you would have a validation function in every email container class. It would be better to wrap the string intended to hold the email address in its own class, even if it only holds one field, the potential for code reuse increases exponentially.</p>
<p>A better implementation could look like this:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Contact <span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">private</span> EmailAddress emailAddress<span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> setEmail<span style="color: #009900;">&#40;</span>EmailAddress emailAddress<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">emailAddress</span> <span style="color: #339933;">=</span> emailAddress<span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> setEmail<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> emailAddress<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">emailAddress</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> EmailAddress<span style="color: #009900;">&#40;</span>emailAddress<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span>InvalidEmailException e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #666666; font-style: italic;">// Oh lord something went wrong here... :)</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">String</span> getEmail<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">return</span> emailAddress<span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>The benefits should be immediately clear. Suddenly the class EmailAddress requires the email address string to be valid to be instantiated at all. This would make it much easier to quickly zero in on bugs and also increases the potential reuse of your code.</p>
<p>Pretty much any variable you want to store, whether it is a primitive or a string &#8211; WILL need some sort of validation. This is a major reason for wrapping them. But other than that, consistently wrapping gives your object oriented code a higher degree of encapsulation.</p>
<p>Previous « <a href="http://www.bagonca.com/blog/2010/01/22/rule-2-dont-use-the-else-keyword/" target="_self">Rule 2: Don&#8217;t Use the Else Keyword</a><br />
Next » <a href="http://www.bagonca.com/blog/2010/01/27/rule-4-use-only-one-dot-per-line/" target="_self">Rule 4: Only Use One Dot Per Line</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.bagonca.com/blog/2010/01/25/rule-3-wrap-all-primitives-and-strings/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Rule 2: Don&#8217;t Use the Else Keyword</title>
		<link>http://www.bagonca.com/blog/2010/01/22/rule-2-dont-use-the-else-keyword/</link>
		<comments>http://www.bagonca.com/blog/2010/01/22/rule-2-dont-use-the-else-keyword/#comments</comments>
		<pubDate>Fri, 22 Jan 2010 00:26:55 +0000</pubDate>
		<dc:creator>Jon</dc:creator>
				<category><![CDATA[Developer]]></category>
		<category><![CDATA[Values]]></category>
		<category><![CDATA[software design]]></category>
		<category><![CDATA[ThoughtWorks]]></category>

		<guid isPermaLink="false">http://www.bagonca.com/blog/?p=773</guid>
		<description><![CDATA[This is the second part of a series of articles starting here.
The second rule of the &#8220;Nine Ways to Better Software Today&#8221; is to stop using

else

This builds on top of rule 1, to decrease the level on indentation by again focusing on minimizing complex conditionals. Within the object oriented paradigm, polymorphism is a powerful model [...]]]></description>
			<content:encoded><![CDATA[<p>This is the second part of <a href="http://www.bagonca.com/blog/2010/01/21/nine-steps-to-better-software-design-today-thoughtworks-exercise/" target="_self">a series of articles starting here</a>.</p>
<p>The second rule of the &#8220;Nine Ways to Better Software Today&#8221; is to stop using</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;"><span style="color: #ff7700;font-weight:bold;">else</span></pre></div></div>

<p>This builds on top of <a title="Rule 1. Only ONE level of indentation" href="http://www.bagonca.com/blog/2010/01/21/nine-steps-to-better-software-design-today-thoughtworks-exercise/" target="_self">rule 1, to decrease the level on indentation</a> by again focusing on minimizing complex conditionals. Within the object oriented paradigm, polymorphism is a powerful model to handle this. Regardless of programming model,  this exercise forces you as developer to find alternatives to using the else keyword and thus considerably beautifying your code.</p>
<p>Consider the following Python code</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;"><span style="color: #ff7700;font-weight:bold;">def</span> set_member_status<span style="color: black;">&#40;</span>member, status<span style="color: black;">&#41;</span>:
    <span style="color: #483d8b;">&quot;&quot;&quot; Spot the else keyword &quot;&quot;&quot;</span>
&nbsp;
    <span style="color: #ff7700;font-weight:bold;">if</span> is_active<span style="color: black;">&#40;</span>member<span style="color: black;">&#41;</span>:
        do_something<span style="color: black;">&#40;</span>member, status<span style="color: black;">&#41;</span>
    <span style="color: #ff7700;font-weight:bold;">else</span>:
        do_something_else<span style="color: black;">&#40;</span>member, status<span style="color: black;">&#41;</span></pre></div></div>

<p>There are several ways to simplify this method. For simple cases use early returns, as below. Early returns only work in methods which are short and lacking in complexity (keeping down the level of indentation helps with this). Once a method is long and contains many levels of abstraction, early returns can of course not be used. But by then you&#8217;ve failed at this exercise anyway.</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;"><span style="color: #ff7700;font-weight:bold;">def</span> set_member_status<span style="color: black;">&#40;</span>member, status<span style="color: black;">&#41;</span>:
    <span style="color: #483d8b;">&quot;&quot;&quot; Example of using early returns &quot;&quot;&quot;</span>
&nbsp;
    <span style="color: #ff7700;font-weight:bold;">if</span> is_active<span style="color: black;">&#40;</span>member<span style="color: black;">&#41;</span>:
        do_something<span style="color: black;">&#40;</span>member, status<span style="color: black;">&#41;</span>
        <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #808080; font-style: italic;"># here is the early return :)</span>
&nbsp;
    do_something_else<span style="color: black;">&#40;</span>member, status<span style="color: black;">&#41;</span></pre></div></div>

<p>In many languages it is possible to use the ternary operator. That would look something like this (in javascript):</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">/** Wrong */</span>
<span style="color: #003366; font-weight: bold;">function</span> drowned<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>timeInWater <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;</span> SURVIVABLE_TIME<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009966; font-style: italic;">/** Right */</span>
<span style="color: #003366; font-weight: bold;">function</span> drowned<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
   <span style="color: #000066; font-weight: bold;">return</span> timeInWater <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;</span> <span style="color: #CC0000;">10</span> <span style="color: #339933;">?</span> <span style="color: #003366; font-weight: bold;">false</span> <span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Guard clauses is another way of increasing readability. The following example is <a href="http://www.refactoring.com/catalog/replaceNestedConditionalWithGuardClauses.html" target="_blank">taken from here</a></p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;"><span style="color: #993333;">double</span> getPayAmount<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #993333;">double</span> result<span style="color: #339933;">;</span>
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>_isDead<span style="color: #009900;">&#41;</span> result <span style="color: #339933;">=</span> deadAmount<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>_isSeparated<span style="color: #009900;">&#41;</span> result <span style="color: #339933;">=</span> separatedAmount<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>_isRetired<span style="color: #009900;">&#41;</span> result <span style="color: #339933;">=</span> retiredAmount<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	    <span style="color: #b1b100;">else</span> result <span style="color: #339933;">=</span> normalPayAmount<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #b1b100;">return</span> result<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>	
&nbsp;
<span style="color: #993333;">double</span> getPayAmount<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>_isDead<span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">return</span> deadAmount<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>_isSeparated<span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">return</span> separatedAmount<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>_isRetired<span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">return</span> retiredAmount<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">return</span> normalPayAmount<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Previous « <a href="http://www.bagonca.com/blog/2010/01/21/nine-steps-to-better-software-design-today-thoughtworks-exercise/">Rule 1: Only Use One Level of Indentation</a><br />
Next » <a href="http://www.bagonca.com/blog/2010/01/25/rule-3-wrap-all-primitives-and-strings/" target="_self">Rule 3: Wrap All Primitives and Strings</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.bagonca.com/blog/2010/01/22/rule-2-dont-use-the-else-keyword/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>Nine Steps to Better Software Design Today: Thoughtworks Exercise</title>
		<link>http://www.bagonca.com/blog/2010/01/21/nine-steps-to-better-software-design-today-thoughtworks-exercise/</link>
		<comments>http://www.bagonca.com/blog/2010/01/21/nine-steps-to-better-software-design-today-thoughtworks-exercise/#comments</comments>
		<pubDate>Thu, 21 Jan 2010 12:51:04 +0000</pubDate>
		<dc:creator>Jon</dc:creator>
				<category><![CDATA[Developer]]></category>
		<category><![CDATA[Values]]></category>
		<category><![CDATA[software design]]></category>
		<category><![CDATA[ThoughtWorks]]></category>

		<guid isPermaLink="false">http://www.bagonca.com/blog/?p=757</guid>
		<description><![CDATA[ThoughtWorks is a really cool company. And their book the ThoughtWorks Anthology has a really cool hands on exercise which I think every programmer could benefit greatly on. This series of articles is my take on the exercise.]]></description>
			<content:encoded><![CDATA[<p>There are few companies out there more exiting to me than Thoughtworks. They sport a fantastic set of values, and have some of todays most brilliant programmers and software thinkers on board. But what strikes me as most wonderful about them is the way they communicate with programmers around the world. They really have an interest in good software, whether it is their own, or somebody else&#8217;s.</p>
<p>On reading their book, the <a title="Check out the book!" href="http://pragprog.com/titles/twa/thoughtworks-anthology" target="_blank">Thoughtworks Anthology</a> there was one chapter (Object Calisthenics by Jeff Bay)	 which struck me as extremely fun to read, it contained an exercise called &#8220;Nine Steps to Better Software Design Today&#8221;. An exercise completely focused on object oriented design quality with all that that entails, like <a title="Encapsulation @ Wikipedia" href="http://en.wikipedia.org/wiki/Encapsulation_(object-oriented_programming)" target="_blank">encapsulation</a> and appropriate use of <a title="Polymorphism @ Wikipedia" href="http://en.wikipedia.org/wiki/Polymorphism_(computer_science)">polymorphism</a>.</p>
<p>It is really a very simple exercise in many aspects, it simply provides nine rules, and asks me as a developer to do my absolute best to abide by those rules. What Thoughtworks does is so ingenious. Instead of just preaching the holy grail of object oriented programming, they ask me to be a part of the sermon. On reading the whole exercise I was instantly revving my engine to actually do the exercise. So I started up a small GWT project and forced myself to actually try and comply with the nine rules.</p>
<p>I&#8217;ve never had so much fun programming! And the process truly changed the way I will write code from now, whether it is in a purely object oriented language or not.</p>
<p>Said and done. I will start with the first rule:</p>
<h2>Rule 1 : Use only one level of indentation per method</h2>
<p>No matter which language you are working with, this is something that is very important. Check out the class, that thoughtworks uses as an example, below. It contains one function with several levels of indentation.</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">class</span> Board <span style="color: #009900;">&#123;</span>
  <span style="color: #003399;">String</span> board<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #003399;">StringBuffer</span> buf <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">StringBuffer</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> i <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;</span> <span style="color: #cc66cc;">10</span><span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> j <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> j <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;</span> <span style="color: #cc66cc;">10</span><span style="color: #339933;">;</span> j<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span>
        buf.<span style="color: #006633;">append</span><span style="color: #009900;">&#40;</span>data<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span>j<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      buf.<span style="color: #006633;">append</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #000000; font-weight: bold;">return</span> buf.<span style="color: #006633;">toString</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Now consider that after some refactoring the code could look like this:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">class</span> Board <span style="color: #009900;">&#123;</span>
 <span style="color: #003399;">String</span> board<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #003399;">StringBuffer</span> buf <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">StringBuffer</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  collectRows<span style="color: #009900;">&#40;</span>buf<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #000000; font-weight: bold;">return</span> buf.<span style="color: #006633;">toString</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 <span style="color: #009900;">&#125;</span>
&nbsp;
 <span style="color: #000066; font-weight: bold;">void</span> collectRows<span style="color: #009900;">&#40;</span><span style="color: #003399;">StringBuffer</span> buf<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> i <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;</span> <span style="color: #cc66cc;">10</span><span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span>
   collectRow<span style="color: #009900;">&#40;</span>buf, i<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 <span style="color: #009900;">&#125;</span>
&nbsp;
 <span style="color: #000066; font-weight: bold;">void</span> collectRow<span style="color: #009900;">&#40;</span><span style="color: #003399;">StringBuffer</span> buf, <span style="color: #000066; font-weight: bold;">int</span> row<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> i <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;</span> <span style="color: #cc66cc;">10</span><span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span>
   buf.<span style="color: #006633;">append</span><span style="color: #009900;">&#40;</span>data<span style="color: #009900;">&#91;</span>row<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  buf.<span style="color: #006633;">append</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>What basically has happened here is that methods have been extracted for each level of indentation. The whole class is so much more readable, unit testable, understandable&#8230; you name it. Or as the authors of the chapter puts it:</p>
<blockquote><p>Try to ensure that each method does exactly one thing. One control structure, or one block of statements per method. [Heavy indentation] in a method [is] a signal that you&#8217;re working at multiple level of abstraction, and that means you&#8217;re doing more than one thing.<br />
&#8230;<br />
Working with methods that do exactly one thing, and classes doing exactly one thing, your code begins to change, [...] increasing exponentially the level of reuse.</p></blockquote>
<p>Next time I will talk about <a href="http://www.bagonca.com/blog/2010/01/22/rule-2-dont-use-the-else-keyword/" target="_self">rule 2: <strong>Don’t use the else keyword</a></strong.> <img src='http://www.bagonca.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.bagonca.com/blog/2010/01/21/nine-steps-to-better-software-design-today-thoughtworks-exercise/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>A search on search widget</title>
		<link>http://www.bagonca.com/blog/2010/01/14/search-on-search-widget/</link>
		<comments>http://www.bagonca.com/blog/2010/01/14/search-on-search-widget/#comments</comments>
		<pubDate>Thu, 14 Jan 2010 13:15:03 +0000</pubDate>
		<dc:creator>PEZ</dc:creator>
				<category><![CDATA[Developer]]></category>
		<category><![CDATA[Search]]></category>
		<category><![CDATA[Widget]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://www.bagonca.com/blog/?p=749</guid>
		<description><![CDATA[A search on search widget. Please use on your own Wordpress blog.]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been <a href="http://en.forums.wordpress.com/topic/widget-search-on-search?replies=6">wishing for</a> a Wordpress widget that would help visitors find more blog content relevant to the search engine terms that got them to the blog in the first place. Maybe I&#8217;m just bad at googling or something, because I haven&#8217;t found one.</p>
<p>Now I&#8217;m writing my own widget, called &#8220;Search on search&#8221;. If you arrive at this blog from a search engine link you might see a section for it in the sidebar. If, not, and you&#8217;re curious you could force it by trying this search:</p>
<ul>
<li><a href="http://www.google.com/search?q=hire+the+best+and+set+them+free">http://www.google.com/search?q=hire+the+best+and+set+them+free</a></li>
</ul>
<p>And then in the Google results find a link going to this site. (The widget doesn&#8217;t appear if it can&#8217;t figure out the search engine terms.)</p>
<p>You can find the widget code as a gist on Github, namely here:</p>
<ul>
<li><a href="http://gist.github.com/275734">http://gist.github.com/275734</a></li>
</ul>
<p>It&#8217;s not rocket surgery. The main job is about figuring out what search engine terms, if any, that the user used to find the blog. But I  didn&#8217;t need to solve that one either. <a href="http://www.istanto.net/phpcatching-keyword-from-search-engine.html">Istanto had already solved it</a> for me. =)</p>
<p>I still have a bug to iron out: The links presented doesn&#8217;t get styled like the other lists. I can&#8217;t figure out why&#8230; Feel invited to help me!</p>
<p><em>Update 17 January</em>: The plugin is now available in the Wordpress.org plugin directory:</p>
<ul>
<li><a href="http://wordpress.org/extend/plugins/search-on-search/">http://wordpress.org/extend/plugins/search-on-search/</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.bagonca.com/blog/2010/01/14/search-on-search-widget/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Public Wave Invites?</title>
		<link>http://www.bagonca.com/blog/2009/11/12/public-wave-invites/</link>
		<comments>http://www.bagonca.com/blog/2009/11/12/public-wave-invites/#comments</comments>
		<pubDate>Thu, 12 Nov 2009 19:22:22 +0000</pubDate>
		<dc:creator>PEZ</dc:creator>
				<category><![CDATA[Innovation]]></category>
		<category><![CDATA[Values]]></category>
		<category><![CDATA[experiment]]></category>
		<category><![CDATA[invites]]></category>
		<category><![CDATA[public]]></category>
		<category><![CDATA[public invites]]></category>
		<category><![CDATA[trust]]></category>
		<category><![CDATA[wave]]></category>

		<guid isPermaLink="false">http://www.bagonca.com/blog/?p=746</guid>
		<description><![CDATA[I just experimented with an interesting thing on Google Wave. I made my "Invite others" wave public. Now anyone on Wave can invite people using my invites. Pretty cool. Just a minute after I made the wave public the first person entered and used two invites. It feels quite awesome. Can people handle it all the way? Will someone come in and just use up all the invites? We will soon know. =)]]></description>
			<content:encoded><![CDATA[<p>I just experimented with an interesting thing on Google Wave. I made my &#8220;Invite others&#8221; wave public. Now anyone on Wave can invite people using my invites. Pretty cool. Just a minute after I made the wave public the first person entered and used two invites. It feels quite awesome. Can people handle it all the way? Will someone come in and just use up all the invites? We will soon know. =)</p>
<p>Has anyone else done this? Are there lots of public invite waves out there?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.bagonca.com/blog/2009/11/12/public-wave-invites/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Flickr Searches in 3D</title>
		<link>http://www.bagonca.com/blog/2009/11/03/flickr-searches-in-3d/</link>
		<comments>http://www.bagonca.com/blog/2009/11/03/flickr-searches-in-3d/#comments</comments>
		<pubDate>Tue, 03 Nov 2009 20:56:13 +0000</pubDate>
		<dc:creator>PEZ</dc:creator>
				<category><![CDATA[Flex/AS]]></category>
		<category><![CDATA[Innovation]]></category>

		<guid isPermaLink="false">http://www.bagonca.com/blog/?p=744</guid>
		<description><![CDATA[I&#8217;m experimenting with tying that 3D Album I mentioned earlier to Flickr Searches. Looks like this for now
ThreeDeeGallery.swf
Work in progress, both the app and this blog post.
]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m experimenting with tying that 3D Album I mentioned earlier to Flickr Searches. Looks like this for now<br />
<a href="http://www.bagonca.com/blog/wp-content/uploads/2009/11/ThreeDeeGallery.swf">ThreeDeeGallery.swf</a><br />
Work in progress, both the app and this blog post.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.bagonca.com/blog/2009/11/03/flickr-searches-in-3d/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Innovation – the heartbeat of products</title>
		<link>http://www.bagonca.com/blog/2009/07/31/innovation-%e2%80%93-the-heartbeat-of-products/</link>
		<comments>http://www.bagonca.com/blog/2009/07/31/innovation-%e2%80%93-the-heartbeat-of-products/#comments</comments>
		<pubDate>Fri, 31 Jul 2009 04:47:29 +0000</pubDate>
		<dc:creator>Ram Sundararajan</dc:creator>
				<category><![CDATA[Social]]></category>
		<category><![CDATA[Values]]></category>

		<guid isPermaLink="false">http://www.bagonca.com/blog/?p=647</guid>
		<description><![CDATA[Lately, I have been thinking and reading articles about innovation and innovative companies and I finally got the time to jot it all down over the weekend. And here are my thoughts…
Many companies want to be perceived as innovative. But are they really innovative?
Part of any process in a company should be to focus on [...]]]></description>
			<content:encoded><![CDATA[<p>Lately, I have been thinking and reading articles about innovation and innovative companies and I finally got the time to jot it all down over the weekend. And here are my thoughts…</p>
<p>Many companies want to be perceived as innovative. But are they really innovative?</p>
<p>Part of any process in a company should be to focus on products, the end goal that forms, guides and informs innovation. Wanton innovation is wasteful. There must be something in the product to pull it all together.</p>
<p>There are many companies that develop new technologies and go in search of problems for those technologies to solve. Take the internet bubble for instance; it was defined by this kind of thinking. It was a carnival of worthless innovation. Half baked business ideas and models pumped into money burning concerns in a misguided attempt to make quick bucks and beat the competition. Entrepreneurs launched websites for selling pet foods and some built gaint warehouses for delivering groceries by van. It turned out that no one wanted to buy groceries delivered to them by web van’s warehouses. Alas! The internet bubble burst taking with it all these half baked “innovative” ideas and businesses that had developed solutions to problems that never existed.  </p>
<p>We need a very product oriented culture in companies. Lots of them have tons of great engineers and talented smart people. But ultimately there needs to be some gravitational force in the product to pull it all together. This gravity is what I feel innovation is all about.</p>
<p>I strongly believe that money is not the key for innovation. The key is the product focus and a product development cycle that has room for innovation. Microsoft for instance, spends billions of dollars in Research. Every year it invites journalists to look at its massive concrete and glass structure full of “innovations”. Yet, they end up copying things that Google or Apple does. Look at hotmail or yahoo mail apps. Its gmail mocked! Or Zune, the Microsoft variant of iPod, an obvious copy. The only product I know, correct me if I am wrong, that came out of these research facilities is the speech recognition component in Vista. Yeah it works well, but it is not a killer like gmail or iPod.</p>
<p>Talking about the key aspects of innovation, I think the company’s focus on the product is a must. If a company wants to be innovative and wants to differentiate itself from the rest, I think that it should question its products and its product development cycle. </p>
<p>As an example, let us look at Kano model of customer satisfaction.<br />
It categorizes the features built into any new product as<br />
•	Must have feaures<br />
•	Linear features<br />
•	Exciter features</p>
<p><strong>Must have</strong> features are the ones that must be in the product to be useful. Without the must haves there is no product. However, I feel that the must have features need not be fully implemented when the product is released. A “<em>just about right</em>” or “<em>lagom</em>” amount of completed must haves will do.</p>
<p>Research suggests, that although without the must have features the product will be useless, it is the linears and the exciters that gives more satisfied users. </p>
<p>Let us say, that I wanted to build a hand held music player. What are the must haves required for this tool to be useful?<br />
Let us assume, a good head set, some hard drive to store music files, a play/pause/rewind/fast forward button</p>
<p>One can of course spend a lot of time for instance to make the head set really really good. But a good enough head set would fetch us “just about satisfied” users. There are other important things that can make the player really good. So lets stop there and move on!</p>
<p><strong>The Linears</strong>, they are the ones that gives the user more satisfaction. A linear feature is the one for which “the more the merrier” holds true. It is called linear because customer satisfaction grows linearly with the quantity of these kinds of features. The more the linears in the music player the more satisfied the user gets.</p>
<p>Some examples of the linears I would like to add to the music player are<br />
1.	Good battery<br />
2.	A good display<br />
3.	A scroll wheel on the sides to browse music<br />
4.	Auto and manual lock/unlock button to lock when the user is on the move<br />
5.	Slick design<br />
6.	Light weight<br />
7.	Games, calendar, clock etc</p>
<p><strong>Exciters</strong> are the ones that add great satisfaction to the customer. It often adds a price premium to the product. However, a lack of exciters will not decrease the customer satisfaction below neutral. But I believe that exciters are the ones that will make the product be perceived as innovative and these are the ones that make the product stand out from the rest of the pack.</p>
<p>Some exciters for the music player would be<br />
1.	As soon as I plugin the music player, it will bring up the users’ default music player (whatever it might be) and sync songs both ways.<br />
2.	Charge free device that uses solar and advanced light sensitive batteries<br />
3.	Maximum of 2 clicks to access any song on the hard drive.<br />
4.	No buttons in the player. We make the whole music player a touch screen.</p>
<p>In whatever feature in a product we do, we got to have 1 or 2 real exciters. Look at gmail for instance; they have built in at least one exciter in any type of functionality you find there…that is innovation! Google&#8217;s key to beat the competitive market where yahoo mail and hotmail once ruled!</p>
<p>For a product to be innovative,  companies should integrate both linears and exciters in their feature list and make it transparent in their product development cycle. Categorizing features this way can contribute to an innovative company.</p>
<p>I believe that only innovative companies can stand in this harsh, competitive, volatile market. The more successful a company is in finding and implementing the exciters, the longer and happier the customer stays and hence stronger and faster the company grows. Many companies focus on adding a lot of linears to their application, this is not bad afterall. But they have to realize that time is wasted! Linear features increase the customer satisfaction to only a certain degree. They will not fetch greatly satisfied customers. Feature freaks got to think about it and  control their temptation!<br />
 “<em>Do you need satisfied or greatly satisfied customers?</em>” One real good exciter is better than 10 different features. To me, it is like comparing a man to monkey!</p>
<p>So, let us all build more exciters…not just features! </p>
]]></content:encoded>
			<wfw:commentRss>http://www.bagonca.com/blog/2009/07/31/innovation-%e2%80%93-the-heartbeat-of-products/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Points or days? Should we care?!</title>
		<link>http://www.bagonca.com/blog/2009/07/27/points-or-days-should-we-care/</link>
		<comments>http://www.bagonca.com/blog/2009/07/27/points-or-days-should-we-care/#comments</comments>
		<pubDate>Mon, 27 Jul 2009 06:18:33 +0000</pubDate>
		<dc:creator>Ram Sundararajan</dc:creator>
				<category><![CDATA[Social]]></category>
		<category><![CDATA[Values]]></category>
		<category><![CDATA[agile]]></category>
		<category><![CDATA[software development]]></category>

		<guid isPermaLink="false">http://www.bagonca.com/blog/?p=637</guid>
		<description><![CDATA[Some months back, I wrote a mail to you guys about the easiness and the usefulness of using points system in a story instead of calculating its size in days or hours. I thought that I should blog this discussion now as I think that it might be useful for others too.
For calculating the effort [...]]]></description>
			<content:encoded><![CDATA[<p>Some months back, I wrote a mail to you guys about the easiness and the usefulness of using points system in a story instead of calculating its size in days or hours. I thought that I should blog this discussion now as I think that it might be useful for others too.</p>
<p>For calculating the effort involved in a story we now use days as the unit. By days we actually mean “ideal” days.<br />
That is, we smartly ignore other work related things a developer does in a typical day and calculate only the amount of time s/he has to spend on the story.<br />
We have calculated an ideal day to be 60 % of the developers’ typical day. In other words, it is 4.8 hrs or let us say 5 hours to approximate.</p>
<p>I think that this ideal day system for measuring the effort or size of a story brings in some unnecessary ambiguity into our calculations.<br />
To understand what I mean, let us go back and ponder on what estimation means to us?</p>
<p><em>What are we trying to do in the estimating meetings?</em><br />
The answer I think is, during the estimation meetings we are trying to define the size of each user story. In other words, we are trying to categorize each user story based on our previous experience and calculate the effort involved to put these stories into sizes or points like S, XS, M, L and XL or 1,2,3,5, and 8 respectively.</p>
<p><em>Great, so why do you use “ideal” days?</em><br />
Well, I think that we use ideal days because we somehow wanted to relate time to effort so that we can know how many actual days a story is going to take or taken. Also, it becomes easy to express the status in number of days to the stakeholders rather than with an abstract entity called points. Yepp, true…but I think, this creates ambiguity to a very large extent when practised. For instance, an ideal day for person A need not be the same as the ideal day for Person B. So I think this system is highly subjective. It does not make sense to me to use a system that varies a lot between individuals.</p>
<p>If we wanted to measure how long a story is going to take, we should instead use the team velocity and perhaps create baselines using Burn down charts.<br />
These two measures together can give a better approximate estimate in time for a story.</p>
<p>Let me add some weight to my argument with Mike Cohn’s thoughts on estimation</p>
<p><strong>Choosing between story points and ideal days</strong><br />
With Agile methods, it is perfectly okay to use either points or ideal days as the measure of the size of a user story.<br />
But I think that the points system is more advantageous and complete. Read on&#8230;to know why?</p>
<p>According to Mike <em>(and I totally agree with him of course)</em>, below are the key advantages of using a points system<br />
a) My ideal days are not your ideal days<br />
b) Points estimate do not decay<br />
c) Points are pure measures of size<br />
d) Points estimation are usually clearer and thus faster</p>
<p><strong>a) My ideal days are not your ideal days</strong><br />
Let us say, two runners one fast and one slow are standing at the start of a trial. Each can see the whole track of the trial and can easily agree that the track is one kilometre long. They either come to the agreement because of their previous experience or by comparing it with another track. Either way the process is easy and intuitive. Tracking the length of the trial is similar to the points system. That is, one simply measures the size.</p>
<p>Now, let us bring in some ambiguity by adding more parameters…<br />
Suppose instead of discussing the length of the track, the runners wanted to calculate the time it takes to run the trial. Obviously, the time taken by the fast runner will always be lesser than the slower one. It is going to be difficult for these runners now to come to a consensus. Both of them with different numbers are correct from their point of view. They probably will never agree as to how long it will take to run the trial.</p>
<p>There is another thing that we need to pay attention too. An Ideal day between developers differ a lot because they are constantly involved with something else other than the story development. Things like support issues, big maintenance bug fixes, investigation, design for future projects all takes time.</p>
<p>So as said, the ideal days system is too subjective to be a standard.</p>
<p><strong>b) Points estimate do not decay</strong><br />
An estimate in points has a longer life span than estimates in ideal days. It is simply because the point estimate only takes into account one parameter and that is the size.</p>
<p>Let me explain this with an example. Let’s say that we are to use ideal days to estimate a story that has to use a new technology like flex. We know that none of the developers have worked with it before and we have to do a lot of investigation and learning to produce the story feature. So, let us assume that the developer estimates it will take 13 ideal days to complete the story. Great!</p>
<p>Now, let us fast forward a few sprints and ask the same developer how long another similar flex story will take to do. Obviously, the estimate will be lesser, let’s say s/he says 3 ideal days. Bingo! we got a problem here. Similar stories take different amount of days to implement.</p>
<p>Many teams tend to ignore this as a problem because they think it is only logical that the amount of ideal days decreased, because the developer knows more about the technology now than before. They also argue that measuring team velocity over time would even out this difference. But it actually won’t in reality.</p>
<p>Because&#8230;we will see that using ideal days, the team velocity always remains the same even though developers do more work. See, the developer now after a few sprints produces the same feature in 3 ideal days, where the first time it took 13 ideal days. In other words, in 13 days the developer is now capable of producing 4 such stories (4 stories X 3 ideal days = 12 ideal days). But with ideal days the developer’s velocity is always 13 even though s/he can complete 4 such 13 days stories in 13 days. So ideal days do not reflect the actual team velocity in this case. <em>(logically, after a few months the team velocity should have gone up)</em></p>
<p>With the points system, we do not take time into account…we just calculate the size. For instance, we say that the flex story is about 8 points or XL large and then after a few months, the team velocity is calculated, now we see that the velocity goes up because the team is now able to complete <em>X</em> number of more XL stories than they did previously.</p>
<p><strong>c) Points are pure measures of size</strong><br />
As said earlier, points are pure measures of size and ideal days are not. Of course, ideal days can be used as a measure of size, but with deficiencies. As in the above example, points remain the same but ideal days tend to vary depending on the developers expertise.</p>
<p>Story points being pure measure of size has a couple of advantages. First of all, story points allow the team to estimate stories with analogies. It makes the estimation easy and more fun as we are only talking about <em>“this story is like the other one” </em>and hence should be for example an L or 5 points. When we estimate in ideal days, we can use the same analogy approach, but the problem is that we tend to bring in the calendar days and measure how long a story will take to execute instead of looking at how big a story is. As said, “how long” approach has hidden problems!</p>
<p>Secondly, a story being an abstract measure of size escapes the temptation to correlate it with reality or time. Less is more!<br />
Ideal days has an inherent comparison built in <img src='http://www.bagonca.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />  That is, we tend to always end up comparing actual vs ideal time.<br />
Then this pondering eventually ends up with questions like,<em> &#8220;how the heck we &#8216;only&#8217; did 8 ideal days of work in a 14 day iteration?&#8221;</em> You know more often than not, many teams put the blame on some bully. <img src='http://www.bagonca.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p><strong>d) Points estimation are usually clearer and thus faster</strong><br />
Yes, to me it sounds obvious that it should be really easy to estimate a story on just the size. We skip detailed level of discussion and it makes things easy.<br />
So in estimation meetings, we got to decide only if a story is an XL or M?…Then arises suggestions like we got to do these and these things. Further the last time we worked on that piece of code we found that we had to re-factor it etc. We can also use our previous stories as analogies. Perhaps a similar story that was an XL involves lesser effort this time?! Maybe maybe not…that’s what we decide in estimation meetings.</p>
<p>My point here is that it is easy to talk on higher level and skip going into the details.<br />
Of course, we got to break down the story into smaller tasks. But that has nothing to do with estimating a story size.</p>
<p>Finally, I think that estimation in ideal days has some advantages. But I unfortunately can see only one obvious thing.<br />
Stakeholders want to know when a story will be finished. Is it by Aug 1 or Aug 15? Calculating ideal days might be easier<br />
to get to the date the stakeholder wants to know. But it is like a shortcut and it creates a lot of side effects for the team members.</p>
<p>So I think we gotta stick to the best practises that agile gurus suggest. That is points for a story size and velocity based on points for the team! Just as Ez as it can be <img src='http://www.bagonca.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.bagonca.com/blog/2009/07/27/points-or-days-should-we-care/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
	</channel>
</rss>
