<?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>Jorge Manrubia</title>
	<atom:link href="http://jorgemanrubia.net/feed/" rel="self" type="application/rss+xml" />
	<link>http://jorgemanrubia.net</link>
	<description>Personal Page</description>
	<lastBuildDate>Sun, 14 Feb 2010 17:52:09 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>On Eclispe buddy class loading and performance problems</title>
		<link>http://jorgemanrubia.net/2010/02/09/on-eclispe-buddy-class-loading-and-performance-problems/</link>
		<comments>http://jorgemanrubia.net/2010/02/09/on-eclispe-buddy-class-loading-and-performance-problems/#comments</comments>
		<pubDate>Tue, 09 Feb 2010 21:42:50 +0000</pubDate>
		<dc:creator>jorge</dc:creator>
				<category><![CDATA[Development]]></category>

		<guid isPermaLink="false">http://jorgemanrubia.net/?p=322</guid>
		<description><![CDATA[At work we have been experiencing serious performance problems with the Eclipse feature we are developing. We have just solved the problem and I would like to share the chain of events that caused it. I will elaborate on this a little bit, but in a few words:


If you want to wait for jobs in [...]]]></description>
			<content:encoded><![CDATA[<p>At work we have been experiencing serious performance problems with the Eclipse feature we are developing. We have just solved the problem and I would like to share the chain of events that caused it. I will elaborate on this a little bit, but in a few words:</p>

<ul>
<li>If you want to wait for jobs in Eclipse Junit Plugin tests, <a href="https://jira.jboss.org/jira/browse/JBIDE-2128">use this method</a> instead of the proposed in the second edition of the book <a href="http://www.amazon.com/exec/obidos/ASIN/0321228472/ref=nosim/jorgmanrpersp-20"><em>Eclipse: Building Commercial-Quality Plug-Ins</em></a>.</li>
<li>The <code>global</code> buddy class loading policy can affect performance seriously. It is logical and they warn you about it. I can confirm it is true. </li>
</ul>

<h3>Waiting for jobs in Eclipse JUnit Plugin Tests</h3>

<p>The <a href="http://www.eclipse.org/pde/">Eclipse PDE</a> provides a launcher that let you test your plugins using JUnit. It basically instantiates a new Eclipse workbench and, when it is up, the tests are run inside it. When writing tests, a common need is waiting for jobs to finish. After launching a job for testing its results, the job is run in a separate thread, so the test code will continue running if you don&#8217;t stop it.</p>

<p>The book <a href="http://www.amazon.com/exec/obidos/ASIN/0321228472/ref=nosim/jorgmanrpersp-20"><em>Eclipse: Building Commercial-Quality Plug-Ins</em></a> is an excellent resource for learning Eclipse plugin development. It proposes some utility methods for using with Eclipse Plugin tests. One of this methods is indeed <code>waitForJobs()</code>:</p>

<div class="codecolorer-container java blackboard" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> waitForJobs<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; <span style="color: #000000; font-weight: bold;">while</span> <span style="color: #009900;">&#40;</span>Platform.<span style="color: #006633;">getJobManager</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">currentJob</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">!=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; delay<span style="color: #009900;">&#40;</span>1000<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span></div></div>

<p>This implementation worked well for us until one day we decided to divide a plugin that had become too big. I started by creating a new plugin extracting some code of the plugin along with its tests. But the tests always failed launching a <code>NoClassDefFoundError</code> exception. I was totally convinced that this problem was related to the way we had configured class dependencies between plugins. We use Groovy and the exception was always launched from the groovy libraries referenced from groovy compiled code. I spend a lot of time trying to figure out what was going on. It was a colleague who pointed out that it seemed that the test code was not waiting for the job under test to finish. And he was right. After searching in google I found <a href="waitforjobs">a more robust implementation of the <code>waitForJobs()</code></a> method:</p>

<div class="codecolorer-container java blackboard" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">void</span> waitForJobs<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; <span style="color: #000066; font-weight: bold;">long</span> start <span style="color: #339933;">=</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Asystem+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">System</span></a>.<span style="color: #006633;">currentTimeMillis</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; <span style="color: #000000; font-weight: bold;">while</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>Job.<span style="color: #006633;">getJobManager</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">isIdle</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; delay<span style="color: #009900;">&#40;</span>500<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #009900;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Asystem+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">System</span></a>.<span style="color: #006633;">currentTimeMillis</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-</span>start<span style="color: #009900;">&#41;</span> <span style="color: #339933;">&gt;</span> MAX_IDLE <span style="color: #009900;">&#41;</span> <br />
&nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">throw</span> <span style="color: #000000; font-weight: bold;">new</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Aruntimeexception+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">RuntimeException</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;A long running task detected&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; <span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span></div></div>

<p>Using this approach solved the problem. This would had nothing to do with performance if I hadn&#8217;t messed up with the class loading configuration trying to solve it. Basically I made many of our plugins to use a <code>global</code> buddy class loading policy and, once the problem was solved, I didn&#8217;t undo it. And, while we perceived a poor performance in our plugin, it wasn&#8217;t until recently that we discovered the cause was precisely that <code>global</code> policy (we thought it was a problem with the development installation of the system our product connects to). And this brings me to the next section.</p>

<h3>Eclipse Buddy Class Loading</h3>

<p>The Eclipse core platform runs on a sophisticated runtime for Java components (<a href="http://www.eclipse.org/equinox/">Equinox</a>, an <a href="http://en.wikipedia.org/wiki/Osgi">OSGI</a> implementation). This runtime provides a powerful architecture for installing and running Java modules (bundles or plugins). For doing so, it redefines completely the class loading system of the Standard Java Platform. When running inside Eclipse, each bundle has its own class loader. Bundles declare in their manifests how do they relate to other bundles, so their class loaders know how to locate external classes.</p>

<p>When a bundle <em>A</em> depends on a bundle <em>B</em> it can access its exported classes with no problem. The problem comes when it is <em>B</em> who wants to load classes from <em>A</em> dynamically,  but it can&#8217;t depend on it (because it would create a circular dependence, or just because it doesn&#8217;t make sense). For example, the <em>Log4j</em> bundle can&#8217;t depend on a bundle that provides a <code>log4.properties</code> configuration file but it still wants to locate it in execution time. We have a number of scenarios like this in our application, where some bundles need to load classes/resources from other bundles they don&#8217;t know in execution time.</p>

<p>In these situations <a href="http://wiki.eclipse.org/index.php/Context_Class_Loader_Enhancements#Buddy_Policy">Eclipse Buddy Class Loading</a> come to the rescue (another approach, better but more complex, is to use <a href="http://www.eclipsezone.com/articles/extensions-vs-services/">extension points</a> for allowing plugins to be extended in execution time). Buddy policies allow one bundle to declare that it needs to load classes from other bundles (buddies). When a bundle class loader fails to locate some class, it starts searching for it in the declared buddies. The system can configure a number of policies that determine the way classes are searched:</p>

<ul>
<li><code>dependent</code>: search in bundles that directly or indirectly depend on the bundle.</li>
<li><code>required</code>: search in bundles that explicitly declare themselves as buddies of the caller bundle.</li>
<li><code>global</code>: search in all the bundles.</li>
</ul>

<p>There are <a href="http://wiki.eclipse.org/index.php/Context_Class_Loader_Enhancements#Buddy_Policy_2">others policies available</a> but I think the first two are the most common. Buddy policies are configured in the <code>MANIFEST.MF</code> file of the bundle that needs to load the classes. For example, in the manifest of the <code>org.apache.log4j</code> plugin you can find this:</p>

<div class="codecolorer-container properties blackboard" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="properties codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">Eclipse-BuddyPolicy: registered</div></div>

<p>Since it uses a <code>registered</code> policy, if you want your bundle to provide a properties file for log4j, you should declare your bundle as a buddy of Log4J.</p>

<div class="codecolorer-container properties blackboard" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="properties codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">Eclipse-RegisterBuddy: org.apache.log4j</div></div>

<p>With a <code>dependent</code> policy this last step is not necessary. As it is obvious, <code>registered</code> is more efficient than <code>dependent</code>, and this one is more efficient than <code>global</code>. In a product like our feature, which is big but not huge, when we changed from <code>global</code> to <code>dependent</code> we observed a huge performance boost, specially the first time the product functions were launched (which is when classes are loaded).</p>

<p>When you try to solve a mysterious bug for long time enough, you are so satisfied when yo do it that you don&#8217;t spend too much time blaming yourself for having produced it. And that was my state after this one&#8230;</p>]]></content:encoded>
			<wfw:commentRss>http://jorgemanrubia.net/2010/02/09/on-eclispe-buddy-class-loading-and-performance-problems/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using macros to create custom example groups in RSpec</title>
		<link>http://jorgemanrubia.net/2010/01/16/using-macros-to-create-custom-example-groups-in-rspec/</link>
		<comments>http://jorgemanrubia.net/2010/01/16/using-macros-to-create-custom-example-groups-in-rspec/#comments</comments>
		<pubDate>Sat, 16 Jan 2010 01:25:54 +0000</pubDate>
		<dc:creator>jorge</dc:creator>
				<category><![CDATA[Development]]></category>

		<guid isPermaLink="false">http://jorgemanrubia.net/2010/01/16/using-macros-to-create-custom-example-groups-in-rspec/</guid>
		<description><![CDATA[I am involved in a personal project where I am developing a web application with Rails. I am using RSpec and Cucumber, and I am following an outside-in, behavior-driven development approach, as recommended in the excellent RSpec Book. In this post I would like to share a problem I found and how I solved it.

It [...]]]></description>
			<content:encoded><![CDATA[<p>I am involved in a personal project where I am developing a web application with <a href="http://rubyonrails.org/">Rails</a>. I am using <a href="http://rspec.info/">RSpec</a> and <a href="http://cukes.info/">Cucumber</a>, and I am following an outside-in, behavior-driven development approach, as recommended in <a href="http://pragprog.com/titles/achbd/the-rspec-book">the excellent RSpec Book</a>. In this post I would like to share a problem I found and how I solved it.</p>

<p>It started when I tried to refactor some duplicated code in my controllers specs. It was related to the authentication system. Specs should test their behavior in both authenticated and insecure contexts, to be sure that anything happens if an anonymous user sends a <code>POST</code> action to your <code>WorldDestroyerController</code>. For example:</p>

<div class="codecolorer-container ruby blackboard" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="ruby codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">describe UserSessionsController, <span style="color:#996600;">&quot;DELETE destroy&quot;</span> <span style="color:#9966CC; font-weight:bold;">do</span><br />
&nbsp; should_require_login <span style="color:#ff3333; font-weight:bold;">:delete</span>, <span style="color:#ff3333; font-weight:bold;">:destroy</span> <br />
<br />
&nbsp; context <span style="color:#996600;">&quot;authenticated user&quot;</span> <span style="color:#9966CC; font-weight:bold;">do</span><br />
&nbsp; &nbsp; before<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:each</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#9966CC; font-weight:bold;">do</span><br />
&nbsp; &nbsp; &nbsp; login_as_user<br />
&nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">end</span><br />
<br />
&nbsp; &nbsp; it <span style="color:#996600;">&quot;should destroy the user session&quot;</span> <span style="color:#9966CC; font-weight:bold;">do</span><br />
&nbsp; &nbsp; &nbsp; <span style="color:#0066ff; font-weight:bold;">@current_user_session</span>.<span style="color:#9900CC;">should_receive</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:destroy</span><span style="color:#006600; font-weight:bold;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; delete <span style="color:#ff3333; font-weight:bold;">:destroy</span><br />
&nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">end</span><br />
<br />
&nbsp; &nbsp; it <span style="color:#996600;">&quot;should redirect to the login page&quot;</span> <span style="color:#9966CC; font-weight:bold;">do</span><br />
&nbsp; &nbsp; &nbsp; delete <span style="color:#ff3333; font-weight:bold;">:destroy</span><br />
&nbsp; &nbsp; &nbsp; response.<span style="color:#9900CC;">should</span> redirect_to login_path<br />
&nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">end</span> &nbsp;<br />
&nbsp; <span style="color:#9966CC; font-weight:bold;">end</span><br />
<span style="color:#9966CC; font-weight:bold;">end</span></div></div>

<p>The next fragment was recurrent in all my examples.</p>

<div class="codecolorer-container ruby blackboard" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="ruby codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">context <span style="color:#996600;">&quot;authenticated user&quot;</span> <span style="color:#9966CC; font-weight:bold;">do</span><br />
&nbsp; before<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:each</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#9966CC; font-weight:bold;">do</span><br />
&nbsp; &nbsp; login_as_user<br />
&nbsp; <span style="color:#9966CC; font-weight:bold;">end</span><br />
&nbsp; <br />
&nbsp; ...</div></div>

<p>For every example in the example group, it basically stubs the controller method that validates sessions in order to get a valid one when invoked (I am using <a href="http://github.com/binarylogic/authlogic">authlogic</a>). I wanted to create a macro <code>context_authenticated</code> so I could code the previous example like this:</p>

<div class="codecolorer-container ruby blackboard" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="ruby codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">describe UserSessionsController, <span style="color:#996600;">&quot;DELETE destroy&quot;</span> <span style="color:#9966CC; font-weight:bold;">do</span><br />
&nbsp; should_require_login <span style="color:#ff3333; font-weight:bold;">:delete</span>, <span style="color:#ff3333; font-weight:bold;">:destroy</span> <br />
<br />
&nbsp; context_authenticated <span style="color:#9966CC; font-weight:bold;">do</span><br />
&nbsp; &nbsp; it <span style="color:#996600;">&quot;should destroy the user session&quot;</span> <span style="color:#9966CC; font-weight:bold;">do</span><br />
&nbsp; &nbsp; &nbsp; <span style="color:#0066ff; font-weight:bold;">@current_user_session</span>.<span style="color:#9900CC;">should_receive</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:destroy</span><span style="color:#006600; font-weight:bold;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; delete <span style="color:#ff3333; font-weight:bold;">:destroy</span><br />
&nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">end</span><br />
<br />
&nbsp; &nbsp; it <span style="color:#996600;">&quot;should redirect to the login page&quot;</span> <span style="color:#9966CC; font-weight:bold;">do</span><br />
&nbsp; &nbsp; &nbsp; delete <span style="color:#ff3333; font-weight:bold;">:destroy</span><br />
&nbsp; &nbsp; &nbsp; response.<span style="color:#9900CC;">should</span> redirect_to login_path<br />
&nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">end</span> &nbsp;<br />
&nbsp; <span style="color:#9966CC; font-weight:bold;">end</span><br />
<span style="color:#9966CC; font-weight:bold;">end</span></div></div>

<p>My first attempt was to write a macro that included the before block and yielded to the block provided in the invocation:</p>

<div class="codecolorer-container ruby blackboard" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="ruby codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color:#9966CC; font-weight:bold;">def</span> context_authenticated<br />
&nbsp; context <span style="color:#996600;">&quot;authenticated user&quot;</span> <span style="color:#9966CC; font-weight:bold;">do</span><br />
&nbsp; &nbsp; before<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:each</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#9966CC; font-weight:bold;">do</span><br />
&nbsp; &nbsp; &nbsp; login_as_user<br />
&nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">end</span><br />
&nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">yield</span> <span style="color:#008000; font-style:italic;">#Wrong</span><br />
&nbsp; <span style="color:#9966CC; font-weight:bold;">end</span><br />
<span style="color:#9966CC; font-weight:bold;">end</span></div></div>

<p>The examples failed because the <code>before(:each)</code> fragment was not being invoked before executing them. To discover the problem I had to <a href="http://rspec.rubyforge.org/rspec/1.3.0/">investigate a little bit about how the RSpec <acronym title="Domain Specific Language">DSL</acronym> works</a>. Basically:</p>

<ul>
<li>Each <code>context</code> (alias for <code>describe</code>) creates a new <code>ExampleGroup</code> subclass.</li>
<li>Each <code>it</code> (alias for <code>example</code>) creates a new instance of the current <code>ExampleGroup</code> subclass where it is invoked.</li>
</ul>

<p>So the problem was related to the very nature of closures. In Ruby, a block of code (<code>proc</code> or <code>lambda</code>) maintains the bindings in effect for that closure. The bindings contains not only variable references, but also the <code>self</code> reference itself.</p>

<p>In my case, what I was doing was to submit a closure with the <code>it</code> examples to the macro. The execution context of this closure was the one where it was defined: the <code>ExampleGroup</code> subclass created by <code>describe UserSessionsController...</code>. However, inside the macro, a new <code>ExampleGroup</code> subclass was created, and the <code>before</code> block was associated with that example group. That was the reason why the the <code>before</code> code was not getting executed before the submitted examples. Once I understood this, the solution was simple:</p>

<div class="codecolorer-container ruby blackboard" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="ruby codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color:#9966CC; font-weight:bold;">def</span> context_authenticated<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&amp;</span>example_group_block<span style="color:#006600; font-weight:bold;">&#41;</span><br />
&nbsp; example_group_class = context <span style="color:#996600;">&quot;authenticated user&quot;</span> <span style="color:#9966CC; font-weight:bold;">do</span><br />
&nbsp; &nbsp; before<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:each</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#9966CC; font-weight:bold;">do</span><br />
&nbsp; &nbsp; &nbsp; login_as_user<br />
&nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">end</span><br />
&nbsp; <span style="color:#9966CC; font-weight:bold;">end</span><br />
&nbsp; example_group_class.<span style="color:#9900CC;">class_eval</span> <span style="color:#006600; font-weight:bold;">&amp;</span>example_group_block<br />
<span style="color:#9966CC; font-weight:bold;">end</span></div></div>

<p>What the previous code does is to change the evaluation context of the closure, so it get executed inside the <code>ExampleGroup</code> class created by the macro.</p>]]></content:encoded>
			<wfw:commentRss>http://jorgemanrubia.net/2010/01/16/using-macros-to-create-custom-example-groups-in-rspec/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>I have read&#8230; &#8216;The Mythical Man-Month: Essays on Software Engineering&#8217;</title>
		<link>http://jorgemanrubia.net/2010/01/09/i-have-read-the-mythical-man-month-essays-on-software-engineering/</link>
		<comments>http://jorgemanrubia.net/2010/01/09/i-have-read-the-mythical-man-month-essays-on-software-engineering/#comments</comments>
		<pubDate>Sat, 09 Jan 2010 02:18:52 +0000</pubDate>
		<dc:creator>jorge</dc:creator>
				<category><![CDATA[Books]]></category>

		<guid isPermaLink="false">http://jorgemanrubia.net/2010/01/09/i-have-read-the-mythical-man-month-essays-on-software-engineering/</guid>
		<description><![CDATA[I have decided to write my first review on my last reading: The Mythical Man-Month: Essays on Software Engineering.



The title of the book refers to the the unit of effort man-month. It is used by (I want to think &#8216;old&#8217;) metrics to estimate and schedule software development. As Brooks explains in his book, while cost [...]]]></description>
			<content:encoded><![CDATA[<p>I have decided to write my first review on my last reading: <a href="http://www.amazon.com/exec/obidos/ASIN/0201835959/ref=nosim/jorgmanrpersp-20">The Mythical Man-Month: Essays on Software Engineering</a>.</p>

<p><a href="http://www.amazon.com/exec/obidos/ASIN/0201835959/ref=nosim/jorgmanrpersp-20"><img src="http://ecx.images-amazon.com/images/I/51WIpM70FEL._SL160_.jpg" alt="Cover image of 'The Mythical Man-Month: Essays on Software Engineering'" /></a></p>

<p>The title of the book refers to the the unit of effort <em>man-month</em>. It is used by (I want to think &#8216;old&#8217;) metrics to estimate and schedule software development. As Brooks explains in his book, while <em>cost</em> varies on the product of number of people and number of months, <em>progress</em> does not. It would do it if tasks in software development could be partitioned between individuals with no communication among them. When you take into consideration the need of <em>communication</em> between parts, the effort increases as <code>n(n-1)/2</code>. The famous <a href="http://en.wikipedia.org/wiki/Brooks_Law">Brook&#8217;s Law</a> appeared in this book as an oversimplifying but eloquent way to capture the problem:</p>

<blockquote>
  <p>Adding manpower to a late software project makes it later</p>
</blockquote>

<p>If you are interested in reading about the importance of communication in software development I recommend you to read <em><a href="http://www.amazon.com/exec/obidos/ASIN/0321482751/ref=nosim/jorgmanrpersp-20">Agile Software Development: The Cooperative Game</a></em>. This book contains the most sensible discussion on the nature of software development that I have ever read. Cockburn defends that software development is <q>a cooperative game of invention and communication</q>.</p>

<p>Returning to the <em>The Mythical Man-Month</em> book, Another thing I loved is how it talks about the human factor in software development. In the chapter <em>The surgical team</em>, Fred Brooks says the following:</p>

<blockquote>
  <p>The conclusion is simple: if a 200-man project has 25 managers who are the most competent and experienced programmers, fire the 175 troops and put the managers back to programming</p>
</blockquote>

<p>When I read this sentence I was totally amazed. Notice that the author was the project manager of the massive software system of IBM System/360 (<acronym title="Operating System">OS</acronym>/360). So more than 3 decades ago, a software developer with experience in developing huge programs, didn&#8217;t emphasized the need of ceremony and heavyweight recipes for software development. Instead he could clearly see what many people can&#8217;t today. He proposed that the most expert programmers should act as surgeons leading a surgical team. The rest of the team should assist them in order to maximize their effectiveness with the core tasks of writing the specs, designing, coding and testing.</p>

<p>Fred Brooks mentions a <a href="http://portal.acm.org/citation.cfm?id=362858">1968 study</a> that concludes that the best programmers are 10 times more <em>productive</em> that the worst ones. Robert L. Glass in <a href="http://www.amazon.com/exec/obidos/ASIN/0321117425/ref=nosim/jorgmanrpersp-20">Facts and Fallacies of Software Engineering</a> talks about numbers ranging from 5 times better to 28 times better. Ignoring this fact is, in my opinion, the source of many deep problems in the spanish software development industry today. Companies don&#8217;t see technical talent as an asset to make more money, but simply like something academical.</p>

<p>Although these were the topics I enjoyed most, the book covers many other software development principles which are totally valid today: the importance of prototyping and the <a href="http://en.wikipedia.org/wiki/Wicked_problem">wicked</a> nature of the discipline, the dangers of over-designing, the need of cohesive teams with good communication mechanisms&#8230; The visionary condition of the author was proved again with his famous article <a href="http://en.wikipedia.org/wiki/No_Silver_Bullet"><em>No silver bullet</em></a>, which stated that nothing in the next 10 years (from 1986) would provide one order of magnitude improvement in software development. The article is included in the book by the way.</p>

<p>In conclusion, it is a book that I totally recommend. The principles it talks about are totally valid today and I really enjoyed reading about them considering the time the book was written. I am simply amazed by the fact that 34 years ago, someone was able to recapitulate so many true and concise ideas on software engineering, even before that software engineering, as a discipline, existed.</p>]]></content:encoded>
			<wfw:commentRss>http://jorgemanrubia.net/2010/01/09/i-have-read-the-mythical-man-month-essays-on-software-engineering/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>My book backlog</title>
		<link>http://jorgemanrubia.net/2009/12/07/my-book-backlog/</link>
		<comments>http://jorgemanrubia.net/2009/12/07/my-book-backlog/#comments</comments>
		<pubDate>Mon, 07 Dec 2009 01:30:43 +0000</pubDate>
		<dc:creator>jorge</dc:creator>
				<category><![CDATA[Books]]></category>

		<guid isPermaLink="false">http://jorgemanrubia.net/2009/12/07/my-book-backlog/</guid>
		<description><![CDATA[I have created an electronic registry of the books I read. To create it I have used the  Now Reading Reloaded extension, based in the excellent Wordpress Now Reading extension. This extension makes very easy adding books searching for them in Amazon, and retrieving their data from Amazon&#8217;s servers (including their cover image). It [...]]]></description>
			<content:encoded><![CDATA[<p>I have created an <a href="http://jorgemanrubia.net/book-backlog/">electronic registry of the books I read</a>. To create it I have used the  <a href="http://wordpress.org/extend/plugins/now-reading-reloaded/">Now Reading Reloaded extension</a>, based in the excellent <a href="http://robm.me.uk/projects/plugins/wordpress/now-reading">Wordpress Now Reading extension</a>. This extension makes very easy adding books searching for them in <a href="http://www.amazon.com/">Amazon</a>, and retrieving their data from Amazon&#8217;s servers (including their cover image). It also let you manage the life cycle of books (reading now, finished and unread).</p>

<p>So I installed this extension, went to my physical library and added the technical books I own. Then I modified the <acronym title="Pre-Hypertext Processing">PHP</acronym> templates to fit my page theme and show the results in the way I wanted.</p>

<p>My last two Amazon&#8217;s orders have been quite big (the current USD/EUR exchange rate has something to do with it), so now I have 16 books waiting to be read in my library (and a few more in <a href="http://www.amazon.com/registry/wishlist/36SJ6E0V7WWWR/ref=cm_wl_act_vv?_encoding=UTF8&amp;visitor-view=1&amp;reveal=">my Amazon&#8217;s wish list</a>). In recent times I have focused my reading mainly in agile development, ruby on rails, good programming practices and, to a lesser extent, user experience design.</p>

<p>I intend to write reviews of the books I read in the form of blog posts. I&#8217;ll link back the reviews from the <a href="http://jorgemanrubia.net/book-backlog/">book backlog</a>, using a Now Reading feature that let you associate a post number to book entries.</p>]]></content:encoded>
			<wfw:commentRss>http://jorgemanrubia.net/2009/12/07/my-book-backlog/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Evaluating code dynamically in Groovy (differences with Ruby)</title>
		<link>http://jorgemanrubia.net/2009/10/10/evaluating-code-dynamically-in-groovy/</link>
		<comments>http://jorgemanrubia.net/2009/10/10/evaluating-code-dynamically-in-groovy/#comments</comments>
		<pubDate>Sat, 10 Oct 2009 16:38:44 +0000</pubDate>
		<dc:creator>jorge</dc:creator>
				<category><![CDATA[Development]]></category>

		<guid isPermaLink="false">http://jorgemanrubia.net/2009/10/10/evaluating-code-dynamically-in-groovy/</guid>
		<description><![CDATA[This week I found out that there are important differences between Ruby and Groovy when it comes to evaluate code dynamically. In order to write the testing infrastructure of a DSL we were developing, we wanted to invoke the code contained in isolated files in the context of the caller code. We were using Groovy, [...]]]></description>
			<content:encoded><![CDATA[<p>This week I found out that there are important differences between Ruby and Groovy when it comes to evaluate code dynamically. In order to write the testing infrastructure of a <acronym title="Domain Specific Language">DSL</acronym> we were developing, we wanted to invoke the code contained in isolated files in the context of the caller code. We were using Groovy, and I wrongly assumed that it would be as easy as with Ruby.</p>

<p>Imagine you have a file named <code>say.script</code> with the next contents:</p>

<div class="codecolorer-container ruby blackboard" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="ruby codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">say <span style="color:#996600;">&quot;Hello&quot;</span></div></div>

<p>In this <acronym title="Domain Specific Language">DSL</acronym>, you can say things that are visualized in the <code>STDOUT</code>. Executing this script with Ruby is very simple: just invoke <code>eval()</code> with the code to evaluate it in a context where the <code>say()</code> method exists.</p>

<div class="codecolorer-container ruby blackboard" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="ruby codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color:#9966CC; font-weight:bold;">def</span> say<span style="color:#006600; font-weight:bold;">&#40;</span>message<span style="color:#006600; font-weight:bold;">&#41;</span><br />
&nbsp; <span style="color:#CC0066; font-weight:bold;">puts</span> message<br />
<span style="color:#9966CC; font-weight:bold;">end</span><br />
<br />
<span style="color:#CC0066; font-weight:bold;">eval</span> <span style="color:#CC00FF; font-weight:bold;">File</span>.<span style="color:#9900CC;">read</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">'say.script'</span><span style="color:#006600; font-weight:bold;">&#41;</span></div></div>

<p>If you want to evaluate the code in the context of some object (for example, an  <a href="http://martinfowler.com/bliki/ExpressionBuilder.html">expression builder</a>), you can write something like:</p>

<div class="codecolorer-container ruby blackboard" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="ruby codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color:#9966CC; font-weight:bold;">class</span> Context<br />
&nbsp; <span style="color:#9966CC; font-weight:bold;">def</span> say<span style="color:#006600; font-weight:bold;">&#40;</span>message<span style="color:#006600; font-weight:bold;">&#41;</span><br />
&nbsp; &nbsp; <span style="color:#CC0066; font-weight:bold;">puts</span> message<br />
&nbsp; <span style="color:#9966CC; font-weight:bold;">end</span><br />
<span style="color:#9966CC; font-weight:bold;">end</span><br />
<br />
context = Context.<span style="color:#9900CC;">new</span><br />
code = <span style="color:#CC00FF; font-weight:bold;">File</span>.<span style="color:#9900CC;">read</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">'say.script'</span><span style="color:#006600; font-weight:bold;">&#41;</span><br />
context.<span style="color:#9900CC;">instance_eval</span> code</div></div>

<p>However, in Groovy, the <a href="http://groovy.codehaus.org/Embedding+Groovy"><code>GroovyShell.evaluate()</code> method</a> is not equivalent to Ruby&#8217;s <code>eval()</code> method. While both mechanisms can share state between the caller and the invoked code through the concept of bindings, in Groovy the <code>evaluate()</code> method is always resolved in the context of a <code>Script</code> object. This means that <strong>the implicit invocation context is not shared</strong>. If you try to execute this code:</p>

<div class="codecolorer-container groovy blackboard" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="groovy codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">def</span> say<span style="color: #66cc66;">&#40;</span>message<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span><br />
&nbsp; <span style="color: #993399;">println</span> message<br />
<span style="color: #66cc66;">&#125;</span><br />
<br />
<span style="color: #000000; font-weight: bold;">def</span> shell <span style="color: #66cc66;">=</span> <span style="color: #000000; font-weight: bold;">new</span> GroovyShell<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><br />
<span style="color: #000000; font-weight: bold;">def</span> code <span style="color: #66cc66;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #aaaadd; font-weight: bold;">File</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;say.script&quot;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">text</span><br />
<br />
shell.<span style="color: #006600;">evaluate</span><span style="color: #66cc66;">&#40;</span>code<span style="color: #66cc66;">&#41;</span> <span style="color: #808080; font-style: italic;">//WRONG: in the script object the say() method is not defined</span></div></div>

<p>You will obtain something like:</p>

<div class="codecolorer-container text blackboard" style="border: 1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">Exception in thread &quot;main&quot; groovy.lang.MissingMethodException: No signature of method: Script1.say() is applicable for argument types: (java.lang.String) values: {&quot;Hello&quot;}</div></div>

<p>A workaround for this situation is to convert the script code into a closure. This way, the <acronym title="Domain Specific Language">DSL</acronym> code is evaluated but not executed. With the closure object you can make the invocation in the context you prefer. In the last example, code bellow will make it:</p>

<div class="codecolorer-container groovy blackboard" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="groovy codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">def</span> say<span style="color: #66cc66;">&#40;</span>message<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span><br />
&nbsp; <span style="color: #993399;">println</span> message<br />
<span style="color: #66cc66;">&#125;</span><br />
<br />
<span style="color: #000000; font-weight: bold;">def</span> shell <span style="color: #66cc66;">=</span> <span style="color: #000000; font-weight: bold;">new</span> GroovyShell<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><br />
<span style="color: #000000; font-weight: bold;">def</span> code <span style="color: #66cc66;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #aaaadd; font-weight: bold;">File</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;say.script&quot;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">text</span><br />
<br />
code <span style="color: #66cc66;">=</span> <span style="color: #ff0000;">&quot;{-&gt;${code}}&quot;</span><br />
<span style="color: #000000; font-weight: bold;">def</span> closure <span style="color: #66cc66;">=</span> shell.<span style="color: #006600;">evaluate</span><span style="color: #66cc66;">&#40;</span>code<span style="color: #66cc66;">&#41;</span><br />
closure.<span style="color: #006600;">delegate</span><span style="color: #66cc66;">=</span><span style="color: #000000; font-weight: bold;">this</span><br />
closure<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span></div></div>

<p>In the example, we wrap the code to execute with a closure syntax. In this way, when we call <code>evaluate</code> we obtain a closure object. With this closure object we can modify its delegate (invocation context) and then call it.</p>

<p>Finally, if we wanted to execute the code using a specific invocation context (something like Ruby&#8217;s <code>instance_eval</code>), we just have to modify the delegate object:</p>

<div class="codecolorer-container groovy blackboard" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="groovy codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">class</span> <span style="color: #aaaadd; font-weight: bold;">Context</span><span style="color: #66cc66;">&#123;</span><br />
&nbsp; <span style="color: #000000; font-weight: bold;">def</span> say<span style="color: #66cc66;">&#40;</span>message<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #993399;">println</span> message<br />
&nbsp; <span style="color: #66cc66;">&#125;</span><br />
<span style="color: #66cc66;">&#125;</span><br />
<br />
<span style="color: #000000; font-weight: bold;">def</span> shell <span style="color: #66cc66;">=</span> <span style="color: #000000; font-weight: bold;">new</span> GroovyShell<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><br />
<span style="color: #000000; font-weight: bold;">def</span> code <span style="color: #66cc66;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #aaaadd; font-weight: bold;">File</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;say.script&quot;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">text</span><br />
code <span style="color: #66cc66;">=</span> <span style="color: #ff0000;">&quot;{-&gt;${code}}&quot;</span><br />
<br />
<span style="color: #000000; font-weight: bold;">def</span> context <span style="color: #66cc66;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #aaaadd; font-weight: bold;">Context</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><br />
<br />
<span style="color: #000000; font-weight: bold;">def</span> closure <span style="color: #66cc66;">=</span> shell.<span style="color: #006600;">evaluate</span><span style="color: #66cc66;">&#40;</span>code<span style="color: #66cc66;">&#41;</span><br />
closure.<span style="color: #006600;">delegate</span> <span style="color: #66cc66;">=</span> context<br />
closure<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span></div></div>

<p>I don&#8217;t know of a better approach for solving this problem with Groovy. Initially I thought there will be a direct way, like in Ruby. But after hours of searching for it we didn&#8217;t find anything (which doesn&#8217;t mean it doesn&#8217;t exist, of course).</p>]]></content:encoded>
			<wfw:commentRss>http://jorgemanrubia.net/2009/10/10/evaluating-code-dynamically-in-groovy/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>About agile estimating in hours</title>
		<link>http://jorgemanrubia.net/2009/09/08/about-agile-estimating-in-hours/</link>
		<comments>http://jorgemanrubia.net/2009/09/08/about-agile-estimating-in-hours/#comments</comments>
		<pubDate>Tue, 08 Sep 2009 22:12:03 +0000</pubDate>
		<dc:creator>jorge</dc:creator>
				<category><![CDATA[Agile]]></category>

		<guid isPermaLink="false">http://jorgemanrubia.net/2009/09/08/about-estimating-in-hours/</guid>
		<description><![CDATA[In this post I would like to talk about the practice of estimating tasks in hours in the iteration planning. After more than one year applying agile estimating techniques at work, I have changed my mind about this practice, and I would like to share my conclusions.

We started the development with the following SCRUM configuration:


Iterations [...]]]></description>
			<content:encoded><![CDATA[<p>In this post I would like to talk about the practice of estimating tasks in hours in the iteration planning. After more than one year applying agile estimating techniques at work, I have changed my mind about this practice, and I would like to share my conclusions.</p>

<p>We started the development with the following SCRUM configuration:</p>

<ul>
<li>Iterations of 4 weeks.</li>
<li>The Release Backlog is composed of user stories which are estimated in story points.</li>
<li>The Iteration Backlogs are composed of the selected user stories for the iteration, which are decomposed into tasks, that are estimated in hours.</li>
</ul>

<p>This approach is supported by several books, including the <a href="http://www.amazon.com/Agile-Software-Development-Scrum/dp/0130676349/ref=sr_1_2?ie=UTF8&amp;s=books&amp;qid=1252429908&amp;sr=8-2">original Scrum book</a> and the superb Mike Cohn&#8217;s <a href="http://www.amazon.com/Agile-Estimating-Planning-Mike-Cohn/dp/0131479415/ref=sr_1_1?ie=UTF8&amp;s=books&amp;qid=1252429950&amp;sr=8-1"><em>Agile Estimating and Planning</em> book</a>. The original Scrum proposal recommends 4 weeks as the duration of each sprint (iteration). Regarding to the backlog contents, the original proposal talks about features as the main item for the product backlog, and tasks for the iteration backlog. Features would be estimated in days and tasks in hours.</p>

<p>Mike Cohn elaborated on this proposing to use user stories as the main product backlog artifact, and tasks for the iteration backlog. He proposes to estimate user stories with ideal days or story points, and tasks in hours. It is worth to notice that the user stories technique was popularized by Kent Beck in his seminar <a href="http://www.amazon.com/Extreme-Programming-Explained-Embrace-Change/dp/0201616416"><em>Extreme Programming Explained</em> book</a>. In the first edition of the book, Kent Beck proposed to estimate the size of stories with points (1,2 or 3). But in the second edition he advocates for using real time estimates. In the same way, he proposes splitting stories into tasks and says that developers should estimate them, although many XP practitioners prefer not to estimate tasks at all, or even to create stories as small as possible in order to eliminate the need for separate tasks.</p>

<p>After several weeks applying the mentioned approach, I realized that there were some aspects I didn&#8217;t like in our planning strategy. The process of splitting stories into tasks and, specially, the estimation of each task was a high time-consuming activity for the project and added little value. I think that this activity was becoming what Lean people call <em>waste</em>:</p>

<ul>
<li><p>Foreseeing estimations at the task level is, by definition, very inaccurate. It is not worth to think thoroughly about how many hours are you going to spend in implementing some subsystem and its tests. Specially if you do it one, two or three weeks before you do it. You&#8217;ll be wrong, because <a href="http://jeffsutherland.com/2002/05/agile-software-development-wicked.html">software development is a wicked problem</a>.</p></li>
<li><p>If you are going to manage inaccurate estimations at the task level, you have added no value to the story point estimations you already have. These can be converted into real time easily using your team speed so, why bother in the extra-effort?.</p></li>
<li><p>In order to determine the tasks that need to be done for implementing a story, there are two contradictory forces:</p>

<ul>
<li><p>If you don&#8217;t want to get deep in the design (after all, you are in an estimation meeting) you end up with a very similar set of tasks for many stories:  design meeting, implementation, testing, documentation&#8230;</p>

<p>Regarding to this, I found very artificial to estimate the hours you spend writing tests and implementing something. Can you separate both activities in a realistic way?</p></li>
<li><p>If you get deep in the design inside a planning meeting so you can create very specific tasks, then you are mixing two very different activities: design and planning. Each requires a very high amount of energy. I have found far more productive to postpone design discussions for late meetings where people can focus completely in the thing to be designed. When you are in a planning meeting you look at the whole number of stories from a very high point of view.</p></li>
</ul></li>
</ul>

<p>In my opinion, the main advantage of having tasks estimated in hours is that you can see how many hours are burnt daily in the sprint backlog, so it&#8217;s very clear how the team advances each day. However, only with the daily meeting and keeping the stories small you can perceive a good sprint progress information.</p>

<p>While the story-points estimations worked very well for estimating our release planning, I found that splitting and estimation of tasks with hours was very inaccurate and someway artificial.</p>

<p>So we decided to stop splitting stories into tasks (not only stop estimating them in hours, we stopped managing tasks as first-class planning artifacts). We want very small stories so we force ourselves to split them when necessary (while keeping them <a href="http://www.artima.com/intv/tracer.html">tracer bullets</a>). And I don&#8217;t really miss tasks. Certainly, there are many times where it is useful to write down the high-level tasks that are needed for implementing some story, but we are fine capturing them as informal comments with the story.</p>

<p>In this process of improving our development method, we first used <a href="http://agilesoftwaredevelopment.com/scrum/simple-product-backlog">Excel templates  for managing our backlogs</a>. After that, we used <a href="http://www.agile42.com/cms/pages/agilo/">Agilo</a>: a very nice tool based on <a href="http://trac.edgewall.org/">trac</a> that can be easily deployed as a VMWare Appliance. It supported perfectly the estimation in story points and hours for the product backlog and the sprint backlog, respectively. When we changed our planning approach we started using <a href="http://www.pivotaltracker.com/">Pivotal Tracker</a>. Pivotal Tracker is an amazing tool. Funny enough, I proposed to their creators <a href="http://getsatisfaction.com/pivotal/topics/possibility_of_specifying_tasks_for_each_story_and_estimating_them_in_hours">to have the possibility of dividing stories into tasks and estimating them in hours</a>. Many people liked this feature, which is currently <a href="http://getsatisfaction.com/pivotal/products/pivotal_tracker?page=1&amp;sort=most_me_toos&amp;style=topics">the number 8th in Pivotal Tracker Most popular topics</a>. The first topic was <a href="http://getsatisfaction.com/pivotal/topics/it_would_be_great_to_add_tasks_to_a_story">add tasks to a story</a> and they have already implemented it in a very nice and simple way (with no estimations of course).</p>

<p>In sum, in our current process:</p>

<ul>
<li>We have iterations of 2 weeks (we preferred a shorter delivery cycle)</li>
<li>We manage user stories as the only planning artifact in our backlogs (release, product and sprint).</li>
<li>We use tasks for clarification of some stories, not as a general planning item.</li>
</ul>]]></content:encoded>
			<wfw:commentRss>http://jorgemanrubia.net/2009/09/08/about-agile-estimating-in-hours/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Slides of a talk on agile development and estimation for Preparatic</title>
		<link>http://jorgemanrubia.net/2009/09/08/slides-of-a-talk-on-agile-development-and-estimation/</link>
		<comments>http://jorgemanrubia.net/2009/09/08/slides-of-a-talk-on-agile-development-and-estimation/#comments</comments>
		<pubDate>Tue, 08 Sep 2009 14:38:31 +0000</pubDate>
		<dc:creator>jorge</dc:creator>
				<category><![CDATA[Downloads]]></category>

		<guid isPermaLink="false">http://jorgemanrubia.net/2009/09/08/slides-of-a-talk-on-agile-development-and-estimation/</guid>
		<description><![CDATA[I would like to share the slides I used in a talk on agile development. I gave the talk on last July, as part of the Preparatic weekly sessions. I really enjoyed it. The people received the lecture very well and many people participated with questions and opinions making the session much more interesting.]]></description>
			<content:encoded><![CDATA[<p>I would like to share the slides I used in a talk on agile development. I gave the talk on last July, as part of the <a href="http://www.preparatic.com/">Preparatic</a> weekly sessions. I really enjoyed it. The people received the lecture very well and many people participated with questions and opinions making the session much more interesting.</p>

<table class="download"><colgroup><col class="downloadname"/><col class="downloaddescription"/><col class="downloadlanguage"/><col class="downloadlanguage"/></colgroup><tr><th>Name</th><th>Description</th><th>Language</th><th>Date</th></tr><tr><td><span lang="es"><a href="http://jorgemanrubia.net/blog/wp-content/plugins/download-monitor/download.php?id=4" hreflang="es" lang="es">2009-06-CharlaPreparaticAgil.pdf</a></span></td><td>Slides of a presentation on agile development and estimating techniques. They were presented in a <a href="http://www.preparatic.com/">Preparatic</a> session.</td><td><div style="text-align:center;"><img src="http://jorgemanrubia.net/images/languages/es.gif" alt="spanish"/></div></td><td>2009-06</td></tr></table>]]></content:encoded>
			<wfw:commentRss>http://jorgemanrubia.net/2009/09/08/slides-of-a-talk-on-agile-development-and-estimation/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The Composed Method implementation pattern</title>
		<link>http://jorgemanrubia.net/2009/06/28/the-composed-method-implementation-pattern/</link>
		<comments>http://jorgemanrubia.net/2009/06/28/the-composed-method-implementation-pattern/#comments</comments>
		<pubDate>Sun, 28 Jun 2009 17:17:06 +0000</pubDate>
		<dc:creator>jorge</dc:creator>
				<category><![CDATA[Development]]></category>

		<guid isPermaLink="false">http://jorgemanrubia.net/2009/06/28/the-composed-method-implementation-pattern/</guid>
		<description><![CDATA[Infoq is one of my favorite sources for reading general-purpose stuff on software development. Some time ago they published an excellent presentation: 10 Ways to Improve Your Code by Neal Ford. I just loved it. The first practice it focused on is the composed method implementation pattern, one of the most fundamental development practices I [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.infoq.com/">Infoq</a> is one of my favorite sources for reading general-purpose stuff on software development. Some time ago they published an excellent presentation: <a href="http://www.infoq.com/presentations/10-Ways-to-Better-Code-Neal-Ford">10 Ways to Improve Your Code</a> by <a href="http://www.nealford.com/">Neal Ford</a>. I just loved it. The first practice it focused on is the <strong>composed method</strong> implementation pattern, one of the most fundamental development practices I can think of.</p>

<p>It was formally described a lot of years ago, as a pattern, in Kent Beck&#8217;s book <a href="http://www.amazon.com/Smalltalk-Best-Practice-Patterns-Kent/dp/013476904X">Smalltalk Best Practice Patterns</a>. I havent&#8217;t read this book yet (it is arriving in my next Amazon&#8217;s order). Sincerely I don&#8217;t know anything about Smalltalk but people usually say that this book is recommendable for anyone interested in good programming practices. I&#8217;m sure I will enjoy it. I expect it to be better than <a href="http://www.amazon.com/Implementation-Patterns-Addison-Wesley-Signature-Kent/dp/0321413091">Implementation Patterns</a>, also by Kent Beck. While not a bad book, I thought it was going to be much better. In this book, it is said that you should:</p>

<blockquote>
  <p>Compose methods out of calls to other methods, each of which is at roughly the same level of abstraction</p>
</blockquote>

<p>I don&#8217;t know why but I tended to call this implementation pattern as <em>factorized code</em>. I think it has to do with the fact that the first time I realized about its importance was reading <a href="http://www.amazon.com/Refactoring-Improving-Existing-Addison-Wesley-Technology/dp/0201485672">Martin Fowler&#8217;s Refactoring book</a>. It was a lot of years ago but I remember that in some section (I guess it was in the <em>extract method</em> refactoring pattern) the book said that when you have in your code something like this:</p>

<div class="codecolorer-container java blackboard" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000066; font-weight: bold;">void</span> someMethod<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
&nbsp; <span style="color: #666666; font-style: italic;">//do some stuff</span><br />
&nbsp; line <span style="color: #cc66cc;">1</span><br />
&nbsp; line <span style="color: #cc66cc;">2</span><br />
&nbsp; line <span style="color: #cc66cc;">3</span><br />
<br />
&nbsp; <span style="color: #666666; font-style: italic;">//calculate some other stuff</span><br />
&nbsp; line <span style="color: #cc66cc;">4</span><br />
&nbsp; line <span style="color: #cc66cc;">5</span><br />
&nbsp; line <span style="color: #cc66cc;">6</span><br />
<br />
&nbsp; <span style="color: #666666; font-style: italic;">//do final stuff</span><br />
&nbsp; line <span style="color: #cc66cc;">7</span><br />
&nbsp; line <span style="color: #cc66cc;">8</span><br />
&nbsp; line <span style="color: #cc66cc;">9</span><br />
<span style="color: #009900;">&#125;</span></div></div>

<p>You should refactor to something like this:</p>

<div class="codecolorer-container java blackboard" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;height:300px;"><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000066; font-weight: bold;">void</span> someMethod<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
&nbsp; doSomeStuff<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><br />
&nbsp; calculateSomeOtherStuff<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><br />
&nbsp; doFinalStuff<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><br />
<span style="color: #009900;">&#125;</span><br />
<br />
<span style="color: #000066; font-weight: bold;">void</span> doSomeStuff<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
&nbsp; line 1<br />
&nbsp; line 2<br />
&nbsp; line 3<br />
<span style="color: #009900;">&#125;</span><br />
<br />
<span style="color: #000066; font-weight: bold;">void</span> calculateSomeOtherStuff<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
&nbsp; line 4<br />
&nbsp; line 5<br />
&nbsp; line 6&nbsp; <br />
<span style="color: #009900;">&#125;</span><br />
<br />
<span style="color: #000066; font-weight: bold;">void</span> doFinalStuff<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
&nbsp; line <span style="color: #cc66cc;">7</span><br />
&nbsp; line <span style="color: #cc66cc;">8</span><br />
&nbsp; line <span style="color: #cc66cc;">9</span>&nbsp; <br />
<span style="color: #009900;">&#125;</span></div></div>

<p>It said that, instead of having a sequence of comments and lines of code, you should extract lines of code to methods with proper names. This way you could also remove comments, as they were redundant. If I remember something of the Refactoring book, is how impressed I was about Fowler&#8217;s coding style (the catalog is full of Java code samples).</p>

<p>In my first year at the University, we were taught about procedural programming. I remember being told that when you designed a program, you had to divide high-level routines into calls to lower-level ones. By doing this recursively, you obtained a tree, where leafs represented primitive routines.</p>

<p>Watching the way many people code it seems that this fundamental principle has simply being lost. It seems like if with objects, you only have to take care of carefully design the public contract of objects and their relations. While this aspect is very important, you have to pay a lot of attention to the design of internal code.</p>

<p>Although this pattern may seem very simple, applying it correctly is not as simple as saying <q>you should divide methods into small steps</q>. I think there are three fundamental properties that should rule methods design:</p>

<ul>
<li>Cohesion</li>
<li>Clear interfaces</li>
<li>Symmetry</li>
</ul>

<p>Methods should be <strong>highly cohesive</strong>. This means that methods should focus in a single responsibility or functionality. This property comes from the software quality field, usually applied to modules or classes. Applying it when designing methods implies that you shouldn&#8217;t have methods that do many things from the point of view of the client that is using it. Who is the client depends on the abstraction level where the code is being invoked. Could be another class o just a private method inside in the same one. A method that receives five parameters is usually a bad smell.</p>

<p>Methods should have <strong>clear interfaces</strong>. In <a href="http://www.amazon.com/Writing-Solid-Code-Microsofts-Programming/dp/1556155514">Writing Solid Code</a> Steve Maguire says that the signature of all methods (functions in those days) should be clear enough in order to understand what the method is supposed to do, without any other kind of documentation. Signature means the name of the method as well as of the parameters it receives and returns (and their types). Achieving this involves many things but without cohesion is just impossible.</p>

<p>The book shows a good example of how a method should not being designed: the <a href="http://c.conclase.net/librerias/funcion.php?fun=realloc">C <code>realloc()</code> function</a>. It just does many things with a very obscure interface, which you won&#8217;t understand without the documentation. The book also contains a very representative example from the physical word, the <em>candy machine interface</em> problem: when the candy machine offers numbers for both selecting products and displaying their prices. Methods should not offer a candy machine interface.</p>

<p>The composition of methods should also be <strong>symmetric</strong>. The steps a method is divided in should be at the same level of abstraction. Abstraction is a construction that a person does in order to understand something. Jumping from one level of abstraction to another requires mental effort. If you have to keep jumping between different levels of abstraction in order to understand some code, it will be far more difficult to understand.</p>

<p>In conclusion, while this pattern will improve the quality of your software, I use it because for me it is easier to program this way. It is just the principle of <em>divide and conquer</em> working. I usually code methods following a top-down approach. Writing the top level methods calling lower-level methods before they exist. This way I can directly project the structure of steps that I, like a human, have in my head. Other people prefer to write the code without decomposing it first, and then refactorize to extract methods (I think this approach is far less effective).</p>

<p>Anyway I think that if you apply this practice exhaustively, along with using proper names for naming identifiers, your code will be like a 400% better.</p>]]></content:encoded>
			<wfw:commentRss>http://jorgemanrubia.net/2009/06/28/the-composed-method-implementation-pattern/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Slides of Agile Development and Rails Course</title>
		<link>http://jorgemanrubia.net/2009/04/12/slides-of-agile-development-and-rails-course/</link>
		<comments>http://jorgemanrubia.net/2009/04/12/slides-of-agile-development-and-rails-course/#comments</comments>
		<pubDate>Sun, 12 Apr 2009 22:17:58 +0000</pubDate>
		<dc:creator>jorge</dc:creator>
				<category><![CDATA[Downloads]]></category>

		<guid isPermaLink="false">http://jorgemanrubia.net/2009/04/12/slides-of-agile-development-and-rails-course/</guid>
		<description><![CDATA[Here it is the last version of the presentation I used in the Agile Development and Rails courses I taught in the University of Oviedo (HCI-RG group). They correspond to a 6 hours-class (the whole course was one week length). It is a very short duration to introduce both the agile development approach and the [...]]]></description>
			<content:encoded><![CDATA[<p>Here it is the last version of the presentation I used in the <a href="http://www.hci-rg.com/en-courses.htm">Agile Development and Rails courses I taught in the University of Oviedo (<acronym title="Human Computer Interaction Research Group">HCI-RG</acronym> group)</a>. They correspond to a 6 hours-class (the whole course was one week length). It is a very short duration to introduce both the agile development approach and the rails platform so I had to leave out many things. I was very interested in the part of basic good development practices because I think these are easy to learn and very worthy for everyone.</p>

<table class="download"><colgroup><col class="downloadname"/><col class="downloaddescription"/><col class="downloadlanguage"/><col class="downloadlanguage"/></colgroup><tr><th>Name</th><th>Description</th><th>Language</th><th>Date</th></tr><tr><td><span lang="es"><a href="http://jorgemanrubia.net/blog/wp-content/plugins/download-monitor/download.php?id=3" hreflang="es" lang="es">2008-04-agile-rails.pdf</a></span></td><td>Slides on <em>Agile development and Introduction to the Rails Platform</em>. They are part of the <a href="http://www.hci-rg.com/en-courses.htm">Agile Development and Rails courses</a> I participated in at the University of Oviedo.</td><td><div style="text-align:center;"><img src="http://jorgemanrubia.net/images/languages/es.gif" alt="Spanish"/></div></td><td>2008-04</td></tr></table>]]></content:encoded>
			<wfw:commentRss>http://jorgemanrubia.net/2009/04/12/slides-of-agile-development-and-rails-course/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Research Report on Model Driven Software Development (2006)</title>
		<link>http://jorgemanrubia.net/2009/04/12/research-report-on-model-driven-software-development-2006/</link>
		<comments>http://jorgemanrubia.net/2009/04/12/research-report-on-model-driven-software-development-2006/#comments</comments>
		<pubDate>Sun, 12 Apr 2009 21:46:24 +0000</pubDate>
		<dc:creator>jorge</dc:creator>
				<category><![CDATA[Downloads]]></category>

		<guid isPermaLink="false">http://jorgemanrubia.net/2009/04/12/research-report-on-model-driven-software-development-2006/</guid>
		<description><![CDATA[In 2006 I got a FICYT Research Grant in Software Engineering. As the results of my research I wrote a document I would like to share. Since it was written three years ago it is quite outdated but perhaps somebody can find it useful.

The report shows very well my evolution during the research period. First, [...]]]></description>
			<content:encoded><![CDATA[<p>In 2006 I got a <a href="http://www.ficyt.es/">FICYT</a> Research Grant in Software Engineering. As the results of my research I wrote a document I would like to share. Since it was written three years ago it is quite outdated but perhaps somebody can find it useful.</p>

<p>The report shows very well my evolution during the research period. First, I was very interested in evaluating the possibilities of <a href="http://martinfowler.com/bliki/UmlAsProgrammingLanguage.html">UML for specifying software formally</a>. As result there is a very long chapter on the foundations of the language. Then I learned the benefits of the multi-<acronym title="Domain Specific Language">DSL</acronym> proposal (and the inconveniences of the UML-centric one), and the basics on model to model transformations and formal languages definition through their metamodels, and I focused my research on these topics.
<table class="download"><colgroup><col class="downloadname"/><col class="downloaddescription"/><col class="downloadlanguage"/><col class="downloadlanguage"/></colgroup><tr><th>Name</th><th>Description</th><th>Language</th><th>Date</th></tr><tr><td><span lang="es"><a href="http://jorgemanrubia.net/blog/wp-content/plugins/download-monitor/download.php?id=2" hreflang="es" lang="es">2006-MDSD-FICYT.pdf</a></span></td><td>Report on Model Driven Software Development. Written during the research period corresponding to a <a href="http://www.ficyt.es/">FICYT</a> Research Grant in Software Engineering.</td><td><div style="text-align:center;"><img src="http://jorgemanrubia.net/images/languages/es.gif" alt="spanish"/></div></td><td>2006</td></tr></table></p>]]></content:encoded>
			<wfw:commentRss>http://jorgemanrubia.net/2009/04/12/research-report-on-model-driven-software-development-2006/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
