<?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>xProgramming.com</title>
	<atom:link href="http://xprogramming.com/feed" rel="self" type="application/rss+xml" />
	<link>http://xprogramming.com</link>
	<description>an agile software development resource</description>
	<lastBuildDate>Fri, 27 Aug 2010 15:53:14 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Beyond Agile: New Principles?</title>
		<link>http://xprogramming.com/articles/beyond-agile-new-principles/</link>
		<comments>http://xprogramming.com/articles/beyond-agile-new-principles/#comments</comments>
		<pubDate>Fri, 27 Aug 2010 14:38:51 +0000</pubDate>
		<dc:creator>Ron Jeffries</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[Beyond Agile]]></category>

		<guid isPermaLink="false">http://xprogramming.com/?p=1889</guid>
		<description><![CDATA[Some people have difficulty living up to the values and principles of the Agile Manifesto. Should we improve the Manifesto? Raise your game: we meant what we said.]]></description>
			<content:encoded><![CDATA[<blockquote><p>Some people have difficulty living up to the values and principles of the Agile Manifesto. Should we improve the Manifesto? Raise your game: we meant what we said.</p></blockquote>
<p>Successful large enterprises (and less successful or smaller ones) often have practices and policies which make it difficult or impossible to follow Agile values and principles. For example, they may choose to outsource software development to low-cost inexperienced high-turnover developers on other continents or other planets. They may wish to compensate for this by providing software templates for these people to follow and learn from.</p>
<h3>It&#8217;s a good idea &#8230;</h3>
<p>Now on the one hand, if one is stuck with inexperienced developers on Mars, providing them with strict guidelines could be part of a valid approach, and providing those guidelines in the form of running tested software would surely be a good way to communicate.</p>
<h3>And it&#8217;s not so very Agile &#8230;</h3>
<p>On the other hand, there&#8217;s a good chance that this approach actually pushes against the notions behind Agility. The basic practice of extraterrestrial software development might seem counter to the Agile principles that &#8220;business people and developers must work together daily&#8221;. Providing direction in the form of software templates might seem counter to the notion that &#8220;most efficient and effective method of conveying information to and within a development team is face-to-face conversation&#8221;.</p>
<p>It&#8217;s true, of course, that an organization could value those principles, and the others that this practice seems opposed to, and still find value in providing these templates. Certainly if I want to show people something about programming, I often show them examples. The template idea may not be any different.</p>
<p>But the question comes: should we update the Manifesto so as to open the door wider to ideas such as this one, and to the many other ideas that people have about how to do something like Agile within their &#8220;real world&#8221; organizations?</p>
<p>My answer is: No. We should not broaden the Manifesto in this kind of way. Here&#8217;s why:</p>
<h3>The Manifesto is an Historical Document</h3>
<p>Seventeen individuals who shared some common ideas got together for a few days, and wrote down the values and principles they shared. It was a moment in time, documenting what those seventeen people believed.  It doesn&#8217;t make sense to rewrite history.</p>
<h3>The Manifesto is a Manifesto</h3>
<p>We wrote a manifesto: a public declaration of our opinions, objectives, and motives. We did not write a constitution for an organization or a set of laws for a group to follow. A manifesto is not subject to updates in the way that a constitution or body of laws might be.</p>
<h3>The Manifesto is Definitional</h3>
<p>As Tim Ottinger put it on the XP list, the manifesto is definitional: it <strong><em>defines </em></strong>our meaning of the term &#8220;Agile&#8221; at that moment in time. We might revise it if we discovered that it didn&#8217;t express what we thought. If it does express what we thought, we cannot revise it.</p>
<h3>The Manifesto is Already Too Broad</h3>
<p>As I look back on the fifteen years I&#8217;ve been doing this, and the decade since the Manifesto, I see more and more people wanting to fly the Agile banner without living the Agile values and principles. On my most charitable day, I might feel that they are trying to become more Agile. On my least charitable day, it&#8217;s hard to see that, because the sum of their actions seems so blatantly counter to what we teach.</p>
<p>One cause of this, in my view, is that the values and principles are perforce a bit vague. In the values, we value both sides: the question is how much. In the principles, we value things like face to face communication: the question is how much.</p>
<h2>Sources of Trouble in Applying Agile</h2>
<h3>Going too far?</h3>
<p>In principle, it is probably possible to follow any Agile value or principle too far.</p>
<p>We might favor individuals and interactions over processes and tools so much that we wrote all of our code in binary. That would usually be inappropriate.</p>
<p>We might favor face to face conversation so much that we never wrote anything down. That would usually be inappropriate.</p>
<p>In principle, therefore, an organization might apply too much Agile. However, there are checks and balances in there, such as the requirement to &#8220;deliver working software frequently&#8221;, and &#8220;to satisfy the customer&#8221;, and to &#8220;reflect on how to become more productive&#8221;. A team that did those things is not likely to code in binary for very long.</p>
<h3>Not going far enough</h3>
<p>In practice, I have never seen or heard of a team that truly followed the Agile values and principles too far. I do know of teams who adopted a kind of faux-Agile and adhered to their flawed definition in the face of delivering no software, and making no customer happy. That&#8217;s not too much Agile, that&#8217;s too little.</p>
<p>On the other side of the balance, I have seen many teams who get very little advantage from Agile, because they are doing very little of it. These teams find ways to weasel within the principles. A common variant is &#8220;We value face to face conversations highly, we really do. But the reality is that our developers are on Mars.&#8221;</p>
<p>Well, guess what. If your developers are on Mars, and you can&#8217;t be with them, you&#8217;re not going to get the benefits of doing Agile &#8212; because you are bloody <strong><em>not doing Agile very well!</em></strong></p>
<h2>Therefore, No</h2>
<p>Sorry. Changing the definition of Agile will not make Mars-based development work any better. The Agile values and principles are just fine. They state an ideal, and they state it pretty darn well when you consider the fools who wrote them.</p>
<p>Probably you&#8217;re not living up to the ideal. I often fall short of my ideals as well, in Agile, and in life. That doesn&#8217;t mean I should set lower ideals. It means I should raise my game.</p>
<p><strong><em>Raise your game, successful large enterprise. We meant what we said.</em></strong></p>
]]></content:encoded>
			<wfw:commentRss>http://xprogramming.com/articles/beyond-agile-new-principles/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Contradiction: Test Everything, but not Accessors?</title>
		<link>http://xprogramming.com/articles/contradiction-test-everything-but-not-accessors/</link>
		<comments>http://xprogramming.com/articles/contradiction-test-everything-but-not-accessors/#comments</comments>
		<pubDate>Mon, 23 Aug 2010 14:14:21 +0000</pubDate>
		<dc:creator>Ron Jeffries</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[Practices]]></category>

		<guid isPermaLink="false">http://xprogramming.com/?p=1865</guid>
		<description><![CDATA[At the Agile Developer Skills course at the Raikes School, I commented that we don't usually test accessors. But we test everything. Is this a contradiction?]]></description>
			<content:encoded><![CDATA[<blockquote><p>At the Agile Developer Skills course at the Raikes School, I commented that we don&#8217;t usually test accessors. But we test everything. Is this a contradiction?</p></blockquote>
<p>Last week, Chet, Cheezy and I presented a CSM class and an Agile Developer Skills class at the Raikes School at the University of Nebraska (Lincoln). Great fun. At the end, a concern was mentioned and I&#8217;ve decided to write about it.</p>
<p>As part of the class, we review participants&#8217; code on the screen. Naturally, we have them trying to do TDD. A number of teams had written a bunch of accessors on their classes, and had dutifully written a test for each one. I commented that I don&#8217;t generally write tests for accessors. I tried to explain that the accessors are covered by other tests, but apparently I didn&#8217;t get that across, because there was a comment about the &#8220;contradiction&#8221; at the end. So I decided I&#8217;d try to explain a little more fully here.</p>
<p>To make what I do familiar to the class participants, I&#8217;ll do my example using the payroll stories we used in the class. To make it interesting to me, I&#8217;ll do it in Scala. I&#8217;m sure readers will have no trouble following along.</p>
<p>Let me call my shot. Here&#8217;s my plan: I&#8217;m going to implement a few of our payroll stories, all in one go, with a design that will require a number of accessors. I will write no accessor tests, and at the end of the exercise, all the accessors will be tested! No accessor tests, but the accessors tested? How is this possible? Read on &#8230;</p>
<p>My proposed design is to have a &#8220;Timesheet&#8221; object and an &#8220;Employee&#8221; object, and to use them in a &#8220;Payer&#8221; object. In the final system, I imagine a Payroll object looping over employees, and providing an employee and her timesheet to the Payer, but for now, that will be done under control of the test. The three main objects should be enough to show why I don&#8217;t test accessors <strong><em>directly</em></strong>.</p>
<p>My proposed test is a bit more of a reach than I would recommend to a TDD beginner &#8230; or even to myself. As a side project, let&#8217;s see if I get into trouble. I propose that Kate Oneal makes $150 an hour and that she works 40 hours regular time, ten hours time and a half, and 5 hours double time. (Kate would never really do that: she&#8217;s too smart.) Anyway, here&#8217;s our test:</p>
<p><code> </code></p>
<p><code></p>
<pre>import org.scalatest.Spec

class PayrollTests extends Spec {
  describe ( "Payroll Testing" ) {

    it ( "should calculate Kate base pay" ) {
      val employee = new Employee("Kate", 150)
      val timesheet = new Timesheet(40,10,5)
      val payer = new Payer(employee , timesheet )
      expect(9750)(payer.grossPay)
    }
  }
}</pre>
<p></code></p>
<p>Not much to see here, really. We create an Employee, Kate, with a pay rate of 150. We build a time sheet with her hours. We create a payer on those two objects, and ask it for Kate&#8217;s gross pay. (I hope I calculated that correctly. Did you know that the Windows 7 calculator allows parentheses? It does.</p>
<p>This code does not compile, of course. So I&#8217;ll create the classes. This is quick, well within my ten minutes between running tests rule &#8230; I hope!</p>
<p><code> </code></p>
<p><code></p>
<pre>class Employee(private val _name: String, private val _payrate:Int) {

}

class Timesheet(
  private val _regularHours:Int,
  private val _ot1Hours:Int,
  private val _ot2Hours:Int) {

}

class Payer(private val _employeee:Employee, private val _timesheet:Timesheet) {

}</pre>
<p></code></p>
<p>These three classes are almost enough to let the program compile. Just one more thing: we need a grossPay method:</p>
<p><code> </code></p>
<p><code></p>
<pre>class Payer(private val employeee:Employee, private val timesheet:Timesheet) {
  <span style="color: #ff0000;">def grossPay = 666</span>
}</pre>
<p></code></p>
<p>This suffices to compile and run the test. We get, of course, &#8220;Expected 9750, but got 666&#8243;. We can continue to implement. We know, of course, that the grossPay result should be rate*regular hours + rate * 1.5 * ot1 hours + rate * 2 * ot2 hours. We type that in:</p>
<p><code> </code></p>
<p><code></p>
<pre>  def grossPay = <span style="color: #ff0000;">_timesheet.regularHours*_employee.payrate +
                 _timesheet.ot1Hours*_employee.payrate*1.5 +
	         _timesheet.ot2Hours*_employee.payrate*2</span></pre>
<p></code></p>
<p>This will not compile (no surprise) because we cannot access those values from the employee and timesheet objects. So one by one, we implement the accessors, until the compiler is quiet:</p>
<p><code> </code></p>
<p><code></p>
<pre>class Employee(private val _name: String, private val _payrate:Int) {
  <span style="color: #ff0000;">def payrate = _payrate</span>
}

class Timesheet(
  private val _regularHours:Int,
  private val _ot1Hours:Int,
  private val _ot2Hours:Int) {

  <span style="color: #ff0000;">def regularHours = _regularHours
  def ot1Hours = _ot1Hours
  def ot2Hours = _ot2Hours</span>
}</pre>
<p></code></p>
<p>At this point we run the test again &#8230; and it is green!</p>
<h3>That was a pretty big bite &#8230;</h3>
<p>Three classes, a bunch of accessors, and one method, all from one test. That&#8217;s more than I&#8217;d normally do, and more than I&#8217;d suggest to people beginning with TDD. It all went well, but it might not have, and it would likely have taken ages to debug. In this case, I had very clearly in mind what I&#8217;d do &#8230; and I was lucky. Try this at home if you like &#8230; and be aware, when it goes wrong, that smaller steps are probably better.</p>
<p>However, we got to our desired end point:</p>
<h3>Test everything &#8230; and don&#8217;t test accessors!</h3>
<p>Note the result: all the accessors are tested &#8230; but we never wrote a test for an accessor. Instead, we had a test for the operation of the feature, which required that we write certain accessors: it could only execute correctly if the accessors were present and correct.  So the test for <strong><em>function </em></strong>drove us to implement the accessors (and a bit more operational code) in order to make the test run.</p>
<p>When you find yourself wanting to test-drive an accessor, and you have no other failing test, write a test that can only be made to work if you have that accessor. Make it a test that actually advances the application, not just a simple check of a value.</p>
<p>This is not just a trick of wordplay. Whenever we find ourselves thinking we need an accessor, we hold back until the code tells us that we need it, via a failing test. Then, and only then, we write the accessor &#8230; and our existing failing test tests the accessor along the way. Working this way keeps our eye on advancing the application, not just writing simple tests for code we may someday need.</p>
]]></content:encoded>
			<wfw:commentRss>http://xprogramming.com/articles/contradiction-test-everything-but-not-accessors/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Scala &#8230; a failing test</title>
		<link>http://xprogramming.com/articles/scala-a-failing-test/</link>
		<comments>http://xprogramming.com/articles/scala-a-failing-test/#comments</comments>
		<pubDate>Thu, 05 Aug 2010 14:57:44 +0000</pubDate>
		<dc:creator>Ron Jeffries</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[Classics]]></category>
		<category><![CDATA[Practices]]></category>

		<guid isPermaLink="false">http://xprogramming.com/?p=1844</guid>
		<description><![CDATA[Jon Bettinger has found a failing test! Excellent!]]></description>
			<content:encoded><![CDATA[<blockquote><p>Jon Bettinger has found a failing test! Excellent!</p></blockquote>
<p>In a comment on an earlier article, Jon points out that the special check for a final bonus frame can trigger on the 9th frame, not just the 10th. The game can end 10-x-y with a strike in the 9th frame and an open frame in the 10th! A test that succeeds and one that fails are:</p>
<p><code></p>
<pre>    it("should count not double count tenth frame bonus rolls" ) {
    	expect(11)(Game.score(List(0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 10,1,0)))
    }

    // fails !!!
    it("should count non-mark tenth frame after strike in ninth" ) {
    	expect(12)(Game.score(List(0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 10, 1,0)))
    }</pre>
<p></code></p>
<p>My initial&#8211;but still thoughtful&#8211;reaction to this is that the current tail-recursive approach is doomed to fail without frame counting. I have a fairly simple counting fix in hand. And I suspect that a two-phase approach, parsing frames from the left and then summing, might be made to work without counting. Stylistic arguments aside, I think these count-free solutions are getting hard to understand.</p>
<p>I&#8217;d like to see one that shows up as clean and yet in full functional style.</p>
<p>I&#8217;ll show my current solution below. But first, some thoughts on helping.</p>
<h3>The Code in My Head Always Works</h3>
<p>It is fun, when someone is having trouble with a program, to suggest a &#8220;solution&#8221; that is significantly different from what they are doing, and it is tempting to declare it to work, and to be better. Recent experience here in the comments on these articles confirms the experience of my entire lifetime:</p>
<p>The code in my head always works. The code in the computer &#8230; not so much. What does this tell us about how to help some poor fool, like me, from a distance? Jon&#8217;s test is a perfect way to help, in that it&#8217;s just about the code and the fact that it doesn&#8217;t work. He didn&#8217;t even have to say &#8220;you tiny fool&#8221;.</p>
<p>But what about suggestions? It seems to me that a really good way would be to provide a little package built with tests, preferably TDD tests. A great way would be to provide an article, not like these Scala ones but like some earlier ones, showing the program, and understanding, growing bit by bit.</p>
<p>That&#8217;s really going to be time-consuming. It takes ages to write that kind of article. Great though.</p>
<p>If we want to help the other person rather than just dump an answer on them, we need to gauge just how quick they&#8217;re going to be.</p>
<p style="padding-left: 30px;">I recall the first time I paired with Ward Cunningham. We were working on an interpreter program for a DSL my team was writing. He looked at what I had and&#8211;I believe&#8211;saw that it sucked. He said &#8220;You know how to write an interpreter in Smalltalk, right?&#8221; I hope I said something like &#8220;Well, I&#8217;m not sure, what do you mean?&#8221; Ward gave a hint; I didn&#8217;t get it; he gave a stronger hint; I still didn&#8217;t get it. This repeated about down to the point where he had to say &#8220;OK, now type a star &#8230;&#8221;.</p>
<p style="padding-left: 30px;">At no time did he make me feel bad or say something to make himself feel superior. He just increased the level of help until I could get it &#8230; and not a bit more.</p>
<p style="padding-left: 30px;">I should be that good, even once. :)</p>
<p>Applying this notion here, it seems to me that a &#8220;vague&#8221; kind of help would be a snippet of code that does something that might be useful if transformed into the current domain. Another kind might be a pointer to a technique. Finally, some working code.</p>
<p>When Philip gave me that snippet of code that I built on, I was in full learning mode, so I didn&#8217;t feel threatened by his solution. And I don&#8217;t feel threatened by people who are smarter than I am anyway, as I have been around them for so long. I might be a bit unique in that. So one needs to be cautious when tossing someone a solution. They might reject the solution; they might just install it; or they might examine it and learn.</p>
<p>This is easier in an environment of pairing and conversation, and difficult in a medium like this. Anyway, just something to think about.</p>
<h3>The Current Solution</h3>
<p>My current guess is is that a frame count is absolutely necessary to the solution, because it is seems impossible to look at the last few rolls and know whether they represent one frame or two. The reason is that the final frame is special.</p>
<p>So I decided to put a frame number back in, inside my function. First I changed the tests to insert 1 (integer representing first frame) as a parameter in the score method, then made it work, then added a score(rolls) polymorphic entry point. Could have been done another way. Anyway, here&#8217;s what I have, and it works. Well &#8230; it passes all the tests.</p>
<p><code> </code></p>
<p><code></p>
<pre>object Game {
   def score(<span style="color: #ff0000;"><strong>frame: Int</strong></span>, rolls: List[Int]):Int = {
      rolls match {
           case List(first, second) =&gt; first+second

           case List(first, second, third) <span style="color: #ff0000;"><strong>if frame == 10</strong></span> =&gt; first+second+third

           case 10::second::third::theRest
              =&gt; 10+second+third + score(<span style="color: #ff0000;"><strong>frame+1</strong></span>, second::third::theRest)

           case first::second::third::theRest if (first + second == 10)
                =&gt; 10+third + score(<span style="color: #ff0000;"><strong>frame+1</strong></span>, third::theRest)

           case first::second::theRest
                 =&gt; first+second + score(<span style="color: #ff0000;"><strong>frame+1</strong></span>, theRest)
      }
   }

   <span style="color: #ff0000;"><strong>def score(rolls: List[Int]):Int = score(1, rolls)</strong></span>
}</pre>
<p></code></p>
<p>I&#8217;ve highlighted the changes. Let me know what you think, and how to do better. Thanks!</p>
]]></content:encoded>
			<wfw:commentRss>http://xprogramming.com/articles/scala-a-failing-test/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Scala Bowling … building on Philip’s approach</title>
		<link>http://xprogramming.com/articles/scala-bowling-reconstructing-philips-approach/</link>
		<comments>http://xprogramming.com/articles/scala-bowling-reconstructing-philips-approach/#comments</comments>
		<pubDate>Wed, 04 Aug 2010 02:13:27 +0000</pubDate>
		<dc:creator>Ron Jeffries</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[Practices]]></category>

		<guid isPermaLink="false">http://xprogramming.com/?p=1832</guid>
		<description><![CDATA[Philip Schwarz provided a nice-looking implementation. Let's look at it and try to build on his ideas.]]></description>
			<content:encoded><![CDATA[<blockquote><p>Philip Schwarz provided a nice-looking implementation. Let&#8217;s look at it and try to build on his ideas.</p></blockquote>
<p>Philip offered this version in a comment on an earlier article:</p>
<p><code> </code></p>
<p><code></p>
<pre>def score(rolls : List[Int]) : Int = rolls match
  {
  case List(x,y) =&gt; x + y
  case List(10,x,y) =&gt; 10 + x + y
  case List(x,y,z) =&gt; 10 + z
  case (10::x::y::rest) =&gt; 10 + x + y + score(x::y::rest)
  case (x::y::z::rest) =&gt; if((x + y) == 10)
    10 + z + score(z::rest)
    else x + y + score(z::rest)
  }</pre>
<p></code></p>
<p>Let&#8217;s see what he did. First of all, instead of that silly idea of including the total on the front of the list, he just wrote the recursion to return the total directly. That was boneheaded on my part. I can only plead youthful inexperience and ask for mercy based on my long years of service.</p>
<p>First, I&#8217;ll fix that in my version:</p>
<p><code> </code></p>
<p><code></p>
<pre>class Game(rolls: List[Int]) {
   def score = scoreReduce(rolls)

   def scoreReduce(rolls: List[Int]):Int = {
      rolls match {
           case Nil =&gt; 0

           case 10::second::third::Nil
               =&gt; 10+second+third

           case first::second::third::Nil if (first+second==10)
                =&gt; first+second+third

           case 10::second::third::theRest
              =&gt; 10+second+third + scoreReduce(second::third::theRest)

           case first::second::third::theRest if (first + second == 10)
                =&gt; 10+third + scoreReduce(third::theRest)

           case first::second::theRest
                 =&gt; first+second + scoreReduce(theRest)
      }
   }
}</pre>
<p></code></p>
<p>That works nicely. We notice that Philip coded things like x :: y :: Nil as List(x,y). That&#8217;s more clear. Let&#8217;s do that:</p>
<p><code> </code></p>
<p><code></p>
<pre>class Game(rolls: List[Int]) {
   def score = scoreReduce(rolls)

   def scoreReduce(rolls: List[Int]):Int = {
      rolls match {
           case Nil =&gt; 0

           <span style="color: #ff0000;"><strong>case List(10, second, third)
               =&gt; 10+second+third

           case List(first, second, third) if (first+second==10)
                =&gt; first+second+third</strong></span><strong>

  </strong>         case 10::second::third::theRest
              =&gt; 10+second+third + scoreReduce(second::third::theRest)

           case first::second::third::theRest if (first + second == 10)
                =&gt; 10+third + scoreReduce(third::theRest)

           case first::second::theRest
                 =&gt; first+second + scoreReduce(theRest)
      }
   }
}</pre>
<p></code></p>
<p>This works. Now notice that Philip doesn&#8217;t have quite the same cases that I have. I&#8217;m unwinding all the way down to an empty list. I&#8217;m handling the case of the last frame having three elements, but not the case of it having only two. Philip added in the case of two elements, which terminates the recursion, so he doesn&#8217;t have to deal with Nil. We can showthat as part of the next display (I&#8217;ve done it separately but will save you reading just that one bit.)</p>
<p>First, look at both his version and mine. I&#8217;ve highlighted the bit of interest in my version above. Philip gave us the trick of representing the end cases explicitly. The game always ends either with a frame of two, or a frame of three which is either a strike (10 :: first :: second) or a spare. We note, however, that the answer returned in either case is the sum of the three balls in the frame. Let&#8217;s do that, then look at the code again:</p>
<p><code> </code></p>
<p><code></p>
<pre>class Game(rolls: List[Int]) {
   def score = scoreReduce(rolls)

   def scoreReduce(rolls: List[Int]):Int = {
      rolls match {
           case List(first, second) =&gt; first+second

           <span style="color: #ff0000;"><strong>case List(first, second, third) =&gt; first+second+third</strong></span>

           case 10::second::third::theRest
              =&gt; 10+second+third + scoreReduce(second::third::theRest)

           case first::second::third::theRest if (first + second == 10)
                =&gt; 10+third + scoreReduce(third::theRest)

           case first::second::theRest
                 =&gt; first+second + scoreReduce(theRest)
      }
   }
}</pre>
<p></code></p>
<p>Now Philip handled things differently at the bottom of the match statement. I broke out strike, spare, and open frame into three cases. He broke out strike, then folded the last two of my cases into one, with an else. I think I&#8217;ll leave it my way.</p>
<p>Now there&#8217;s one more thing to do. Since the function scoreReduce doesn&#8217;t use my dim format with the total on the front, it no longer needs to be an auxiliary function, so we can let it be the score function directly. That&#8217;s a bit tricky, though, because I built Game as a class, with rolls inside it. The way things are set up now, we almost might as well move the whole function score into our test class. I&#8217;ll not go that far: I want a solution that stands alone from the tests.</p>
<p>Instead, I&#8217;ll change Game to an object with just one method, score. That makes things turn out like this. First the tests:</p>
<p><code> </code></p>
<p><code></p>
<pre>import org.scalatest.Spec

class ExampleSpec extends Spec {

  describe("A Bowling Game") {

    it("should score all gutters as zero") {
    	expect(0)(Game.score(List(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)))
    }

    it("should score all 5,4 as 90") {
    	expect(90) (Game.score(List(5,4,5,4,5,4,5,4,5,4,5,4,5,4,5,4,5,4,5,4)))
    }

    it("should score spare game 6, 4, 5, 2 as 22") {
    	expect(22)(Game.score(List(6,4,5,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)))
    }

    it("should score strike game 10, 5, 2, 7 as 31") {
    	expect(31)(Game.score(List(10,5,2,7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)))
    }

    it("should score perfect game as 300" ) {
    	expect(300)(Game.score(List(10,10,10,10,10,10,10,10,10,10,10,10)))
    }
  }
}</pre>
<p></code></p>
<p><code>Then the Game object:</p>
<p></code></p>
<p><code> </code></p>
<p><code></p>
<pre>object Game {
   def score(rolls: List[Int]):Int = {
      rolls match {
           case List(first, second) =&gt; first+second

           case List(first, second, third) =&gt; first+second+third

           case 10::second::third::theRest
              =&gt; 10+second+third + score(second::third::theRest)

           case first::second::third::theRest if (first + second == 10)
                =&gt; 10+third + score(third::theRest)

           case first::second::theRest
                 =&gt; first+second + score(theRest)
      }
   }
}</pre>
<p></code></p>
<p><code> </code></p>
<p><code>OK. That's probably more like it. I expect that this is in the range of tolerance for a functional solution, with people perhaps objecting to notation and having better ideas. I'll be very interested to see if something substantially different comes up. </code></p>
<p>Go for it!</p>
]]></content:encoded>
			<wfw:commentRss>http://xprogramming.com/articles/scala-bowling-reconstructing-philips-approach/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Scala Bowling … more function cowbell</title>
		<link>http://xprogramming.com/articles/scala-bowling-more-function-cowbell/</link>
		<comments>http://xprogramming.com/articles/scala-bowling-more-function-cowbell/#comments</comments>
		<pubDate>Wed, 04 Aug 2010 00:00:22 +0000</pubDate>
		<dc:creator>Ron Jeffries</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[Practices]]></category>

		<guid isPermaLink="false">http://xprogramming.com/?p=1820</guid>
		<description><![CDATA[My critiXXXXX advisors expected a more function-oriented solution. Here's something a bit better, perhaps ...]]></description>
			<content:encoded><![CDATA[<blockquote><p>My critiXXXXX advisors expected a more function-oriented solution. Here&#8217;s something a bit better, perhaps &#8230;</p></blockquote>
<p>I was at a loss as to how to deal with a function that scores one part of an input list and consumes a different part. Finally I got the notion of a function of two parameters, a total and a list, which adds to the total based on the scoring part and calls itself recursively with the appropriate list remainder.</p>
<p>The result is that I have dropped the Framer class, and added the recursive function to the Game class, which now looks like this:</p>
<p><code> </code></p>
<p><code></p>
<pre>class Game(rolls: List[Int]) {
   def score = scoreReduce(0,rolls)

   def scoreReduce(total: Int, rolls: List[Int]):Int = {
      rolls match {
           case Nil =&gt; total

           <span style="color: #993300;"><strong>case 10::second::third::Nil
               =&gt; total+10+second+third

           case first::second::third::Nil if (first+second==10)
                =&gt; total+first+second+third</strong></span>

           case 10::second::third::theRest
              =&gt; scoreReduce(total+10+second+third, second::third::theRest)

           case first::second::third::theRest if (first + second == 10)
                =&gt; scoreReduce(total+first+second+third, third::theRest)

           case first::second::theRest
                 =&gt; scoreReduce(total+first+second, theRest)
      }
   }
}</pre>
<p></code></p>
<p>I started with the four black cases. Those pass all my tests but for the perfect game, which was scored 320 rather than 300. What happened was that on the last strike, we score up the 300, but then we return the rest of the rolls (the bonus rolls) for one last go, as if they were a frame. In bowling, the bonus rolls only provide a bonus for a mark in the final frame: they do not constitute a frame of their own.</p>
<p>The two red cases differ from the black ones in that they are explicitly talking about the end of the list: first::second::third::Nil and so on. Instead of recurring one more time, they just return the final value.</p>
<p>So &#8230; I feel this is more in the direction of a functional solution. I can imagine going further, and perhaps I will. We have the fact of a two-part argument, the total and the rolls. We might be able to put the total in front, or on the back, and update it there. Front will be easier, as Scala prefers us to work at the head. Let&#8217;s see &#8230;</p>
<hr />Hmm, that turned out to be easier than I thought. I just put the total on the front, and adjusted all the patterns. The result now looks like this:</p>
<p><code> </code></p>
<p><code></p>
<pre>class Game(rolls: List[Int]) {
   def score = scoreReduce(0::rolls)

   def scoreReduce(rolls: List[Int]):Int = {
      rolls match {
           case total::Nil =&gt; total

           case total::10::second::third::Nil
               =&gt; total+10+second+third

           case total::first::second::third::Nil if (first+second==10)
                =&gt; total+first+second+third

           case total::10::second::third::theRest
              =&gt; scoreReduce(total+10+second+third::second::third::theRest)

           case total::first::second::third::theRest if (first + second == 10)
                =&gt; scoreReduce(total+first+second+third::third::theRest)

           case total::first::second::theRest
                 =&gt; scoreReduce(total+first+second::theRest)
      }
   }
}</pre>
<p></code></p>
<p>I think that is in some sense better. All the work is being done in the patterns, which is perhaps appropriate. The patterns are a bit opaque because of the necessity to embed the two or three rolls of interest into the middle of the list (total, rolls of interest, &#8230;). It might be possible to improve that aspect with some typographic tricks.</p>
<p>Anyway, I think it is more functional than it was and I look forward to comments. It has been a long time since I worked in a functional style. (No smart remarks now &#8230; :) )</p>
]]></content:encoded>
			<wfw:commentRss>http://xprogramming.com/articles/scala-bowling-more-function-cowbell/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>Scala Bowling, I think …</title>
		<link>http://xprogramming.com/articles/scala-bowling-i-think/</link>
		<comments>http://xprogramming.com/articles/scala-bowling-i-think/#comments</comments>
		<pubDate>Tue, 03 Aug 2010 14:20:23 +0000</pubDate>
		<dc:creator>Ron Jeffries</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[Practices]]></category>

		<guid isPermaLink="false">http://xprogramming.com/?p=1806</guid>
		<description><![CDATA[I've been working with Scala a bit, just to learn what it is. I've found it interesting, if frustrating. Here is a bowling experiment.]]></description>
			<content:encoded><![CDATA[<blockquote><p>I&#8217;ve been working with Scala a bit, just to learn what it is. I&#8217;ve found it interesting, if frustrating. Here is a bowling experiment.</p></blockquote>
<p>The bowling problem that Chet and I use for TDD demonstrations is somewhat different from the one that Bob Martin uses. Ours can be stated: &#8220;Given a list of rolls of a legal game of bowling, compute the final score of the game.&#8221; This turns out to be just big enough to be interesting and to be something we can do in about an hour, with plenty of discussion and questions.</p>
<p>I wrote this one in full TDD style, but I will present here only the final version, with some discussion. Mostly I spent the early part of the project trying to learn the Scala language and tools, and trying to work in what I hope is a Scala-like style. I&#8217;ll leave the article open for comments in case you&#8217;d like to advise me otherwise.</p>
<h3>First, the Tests</h3>
<p>Here are the tests, written in ScalaTest Spec format. I kind of like that form, as it means I don&#8217;t have to make up really weird test method names.</p>
<p><code></p>
<pre>import org.scalatest.Spec

class ExampleSpec extends Spec {

  describe("A Bowling Game") {

    it("should score all gutters as zero") {
    	val game = new Game(List(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0))
    	expect(0)(game.score)
    }

    it("should score all 5,4 as 90") {
    	val game = new Game(List(5,4,5,4,5,4,5,4,5,4,5,4,5,4,5,4,5,4,5,4))
    	expect(90) (game.score)
    }

    it("should score spare game 6, 4, 5, 2 as 22") {
    	val game = new Game(List(6,4,5,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0))
    	expect(22)(game.score)
    }

    it("should score strike game 10, 5, 2, 7 as 31") {
    	val game = new Game(List(10,5,2,7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0))
    	expect(31)(game.score)
    }

    it("should score perfect game as 300" ) {
    	val game = new Game(List(10,10,10,10,10,10,10,10,10,10,10,10))
    	expect(300)(game.score)
    }
  }
}</pre>
<p></code></p>
<p>As always, these are shown in the order created.  Nothing special here, I just create a game and expect its score. I did, of course, work one test at a time, making each one work before creating a new one.</p>
<p>I had a design in mind, as always. I think it is neither desirable, nor quite likely even possible, to work with no design in mind. The trick is to make no steps in the direction of the design until the code calls for them. You&#8217;ll have to take my word for it that I accomplished that. The point here is just to show you the result, which I think is interesting.</p>
<p>The design I had in mind is one that Chet and I tried in Java or C# last week. Under the Game object, there is a &#8220;Framer&#8221; object that steps along the sequence of rolls, positioning itself to the start of each frame, and adding the score of that frame to the game total. In Java, we wound up having that object maintain an index into the array of rolls, and it would step that index by 2 for spares and open frames, and by one for strikes. (All done one step at a time, of course.)</p>
<h3>Now, the Game</h3>
<p>The game didn&#8217;t change after I first refactored in a rudimentary framer. It goes like this:</p>
<p><code></p>
<pre>class Game(rolls: List[Int]) {
   def score = {
      val framer = new Framer(rolls)
      var total = 0
      for (frame &lt; - 1 to 10) { total += framer.score }
      total
   }
}</pre>
<p></code></p>
<p>Not much to see here. As I look at it now, I suspect there is a more Scala-like way  to do this. If you see one, please let me know.</p>
<h3>And, the Framer</h3>
<p>The Framer class has gone through a number of iterations, from a procedural, indexed approach, to this more functional one. One essential idea is that this Framer, rather than indexing through the list of rolls, actually consumes it. The other idea is that at each frame position, the Framer adds together two rolls, or three rolls, to get the frame score. An open frame scores just the two rolls of the frame, while a strike scores the one roll of the frame and the next two rolls, while a spare scores the two rolls of the frame and the next one. Since 2 + 1 equals 1 + 2, both &#8220;mark&#8221; frames wind up scoring three rolls.</p>
<p>I first had the idea of creating a tuple saying how many rolls to score, and how many to consume or &#8220;eat&#8221;. Then I hit on using Scala pattern matching to identify which kind of frame we&#8217;re dealing with.</p>
<p>Here again, I&#8217;m open to comments on style, and offers of better ways of doing it.</p>
<p><code></p>
<pre>class Framer(var rolls: List[Int]) {
   def score = scoreFrame(frameList)

   def scoreFrame(sumAndEat: Tuple2[Int,Int]) = {
      val rollsToSum = rolls.take(sumAndEat._1)
      rolls = rolls.drop(sumAndEat._2)
      rollsToSum reduceLeft (_+_)
   }   

   def frameList = {
      rolls match {
         case List(10, _*) =&gt; (3,1)
         case List(a:Int, b:Int, _*) if (a + b == 10) =&gt; (3, 2)
         case _ =&gt; (2,2)
      }
   }
}</pre>
<p></code></p>
<p>Overall, it was a somewhat frustrating experience, but mostly this was due to trying to hook together all the tools one would need. Partly, however, I found the two books I had, Wampler&#8217;s and Venkat&#8217;s, didn&#8217;t lend themselves to my style of learning, whatever that is.</p>
<p>Some of that is due to the fact that I am a Windows user and prefer to use an IDE. I realize this calls my masculinity into question, but I can live with that.</p>
<p>Anyway, that&#8217;s my report. I look forward to your comments, and I&#8217;ll probably write a few more articles about my experience with Scala. Enjoy!</p>
<hr />
<h3>Updates from Ilmari</h3>
<p>Based on Ilmari&#8217;s suggestions, we can rewrite Framer as:</p>
<p><code> </code></p>
<p><code></p>
<pre>class Framer(var rolls: List[Int]) {
   def score = scoreFrame(frameList)

   def scoreFrame(sumAndEat: (Int,Int)) = {
      val rollsToSum = rolls.take(sumAndEat._1)
      rolls = rolls.drop(sumAndEat._2)
      rollsToSum reduceLeft (_+_)
   }   

   def frameList = {
      rolls match {
         case 10 :: theRest =&gt; (3,1)
         case first :: second :: theRest if (first + second == 10) =&gt; (3, 2)
         case _ =&gt; (2,2)
      }
   }
}</pre>
<p></code></p>
<p>Frankly, I&#8217;m surprised by the match &#8230; apparently everything inside a case is taken implicitly as abstract parameters. Very interesting.</p>
<p>I couldn&#8217;t find a way to get rid of the ._1 and ._2 in the scoreFrame method: everything I tried to give those two Ints names wouldn&#8217;t compile.</p>
<p>As for Ilmari&#8217;s comment about the 1 to 10, I don&#8217;t see how to get rid of that either. Would like to learn more &#8230;</p>
<hr />
<h3>Another Pattern Match</h3>
<p>I fiddled with the pattern match a bit, making it return two lists, the rolls to sum, and the rolls to work with next time. You&#8217;ll notice I&#8217;m still referring to the rolls state variable and storing over it. The scoreFrame method is simpler now: I&#8217;m not so happy with the pattern itself. Your thoughts?</p>
<p><code>
<pre>
class Framer(var rolls: List[Int]) {
   def score = scoreFrame(frameList)

   def scoreFrame(sumAndEat: (List[Int], List[Int])) = {
      rolls = sumAndEat._2
      sumAndEat._1.reduceLeft (_+_)
   }   

   def frameList = {
      rolls match {
         case 10 :: second :: third :: theRest =>
         	(10 :: second :: third :: Nil, second::third::theRest)

         case first :: second :: third :: theRest if (first + second == 10) =>
         	(first::second::third::Nil, third::theRest)

         case first::second::theRest => (first::second::Nil, theRest)

         case Nil => (Nil, Nil)
      }
   }
}</pre>
<p></code></p>
]]></content:encoded>
			<wfw:commentRss>http://xprogramming.com/articles/scala-bowling-i-think/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>Scala Confusion</title>
		<link>http://xprogramming.com/articles/scala-confusion/</link>
		<comments>http://xprogramming.com/articles/scala-confusion/#comments</comments>
		<pubDate>Wed, 28 Jul 2010 02:36:36 +0000</pubDate>
		<dc:creator>Ron Jeffries</dc:creator>
				<category><![CDATA[Articles]]></category>

		<guid isPermaLink="false">http://xprogramming.com/?p=1790</guid>
		<description><![CDATA[Just for something to do, I'm learning? Scala. Having deep confusion making JUnit suites run. Advise me in comments if you're up for it?]]></description>
			<content:encoded><![CDATA[<blockquote><p>Just for something to do, I&#8217;m learning? Scala. Having deep confusion making JUnit suites run. Advise me in comments if you&#8217;re up for it?</p></blockquote>
<p>Reading Venkat&#8217;s book, and Dean Wampler&#8217;s book, I decided that rather than run things at the command prompt &#8230; how very last century, I&#8217;d write a bunch of JUnit tests to test and document the things I was trying. It seems to me to be a much better way to do things.</p>
<p>(Why am I not using ScalaTest or another such system? Largely because I know JUnit and felt no desire to try to learn two things at once. And yes, I know I should get a Mac.)</p>
<p>It&#8217;s going pretty well so far, or was until I tried to set up a suite of tests. I&#8217;ve got a big JUnit test file, and it was just getting irritating to add another test to it, so I started another one, thinking maybe someday they&#8217;d even get organized. But of course I&#8217;d like to run all the tests frequently just because I like the jolt of the green bar.</p>
<p>So I looked up how to do a Suite. There&#8217;s nothing really solid on the Web but I found a couple of consistent items. They are almost working but some of it has me confused. I&#8217;ll note down here what I&#8217;ve got and maybe if you grok Scala you can advise me in the comments.</p>
<p>I have my main test file. It looks like this:</p>
<pre><code>
import org.junit._
import org.junit.runner._
import org.junit.runners._
import Assert._
import StringUtil._

class TestSomething { 

	@Test def hookup() {
		assertEquals(2,2)
	}

	@Test def someArrayStuff {
		val array: Array[String] = new Array(5)
		array(0) = "abc"
		assertEquals("abc", array(0))
		assertEquals(null, array(1))
	}
        ...
}

</code></pre>
<p>There are a couple of class files, not relevant here. There&#8217;s another test file that I just started:</p>
<pre><code>
import org.junit._
import org.junit.runner._
import org.junit.runners._
import Assert._ 

class TestMore {
	@Test def hookup4 {
		assertEquals(4,4)
	}
}

</code></pre>
<p>As soon as I started with that, I realized I wanted a suite, to run everything. I have that in place, like this:</p>
<pre><code>
import org.junit._
import org.junit.runner._
import org.junit.runners._
import Assert._ 

@RunWith(classOf[Suite])
@Suite.SuiteClasses(Array(classOf[TestDummy]))
class TestEverything

class TestDummy {
	@Test def hookup {

	}
}

</code></pre>
<p>This is lifted from a couple of examples I found on the Web. I&#8217;ve fiddled a bit with what is in the RunWith class, and what is in the SuiteClasses array. None of them seems to work unless I have at least a dummy test in the same file, and I seem to require the empty class (TestEverything) as well. </p>
<p>As this stands, all the tests run and show green or red as they should. JUnit&#8217;s Eclipse GUI looks like this:</p>
<p><a href="http://xprogramming.com/wp-content/uploads/junit2.jpg"><img src="http://xprogramming.com/wp-content/uploads/junit2.jpg" alt="" title="junit" width="726" height="379" class="alignnone size-full wp-image-1797" /></a></p>
<p>Notice that TestDummy shows up twice, once in the top-level listing where the other tests are. But at that level TestDummy does not have green check marks. It shows up again, under TestEverything, and there it will have checks as appropriate. I&#8217;ve fiddled with not having any tests in the TestEverything file, and that seems to fail entirely. I&#8217;ve tried various names, or putting the names of the other test classes in the @Suite entry. In every case, I either get errors or an odd display where some of the classes show up twice, on their own or under TestEverything.</p>
<p>Advise me, please &#8230; have you a configuration of JUnit with Scala with Suites? I&#8217;d love to see how it works.</p>
<p>And OK, let me know what testing tool you&#8217;re using with Scala as well. But I&#8217;m not going to get a Mac.</p>
<p>Thanks!</p>
]]></content:encoded>
			<wfw:commentRss>http://xprogramming.com/articles/scala-confusion/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Beyond Agile: Synthesis</title>
		<link>http://xprogramming.com/articles/beyond-agile-synthesis/</link>
		<comments>http://xprogramming.com/articles/beyond-agile-synthesis/#comments</comments>
		<pubDate>Thu, 15 Jul 2010 15:03:00 +0000</pubDate>
		<dc:creator>Ron Jeffries</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[Beyond Agile]]></category>

		<guid isPermaLink="false">http://xprogramming.com/?p=1713</guid>
		<description><![CDATA["His brand is bad: my brand is good." Isn't it well past time we got over that kind of thinking? I'll take a good idea from anywhere. So should you.]]></description>
			<content:encoded><![CDATA[<blockquote><p>&#8220;His brand is bad: my brand is good.&#8221; Isn&#8217;t it well past time we got over that kind of thinking? I&#8217;ll take a good idea from anywhere. So should you.</p></blockquote>
<p>You&#8217;re interested in having projects that are more successful. At least you should be. You may well find great value in Scrum, or XP, or Lean, or Kanban, or DSDM, or whatever. I hope you do. Keep your eye on the ball, however. The point for you shouldn&#8217;t be to do Scrum or XP or whatever: it should be to do as many things as you can to be more successful, and as few as you can that get in the way. Those ideas can come from anywhere, and the  better you and your team want to be, the wider the range of ideas you need to consider.</p>
<p>When you look for help or training, however, you find yourself dealing with companies and individuals. These people often have a preferred style of &#8220;Agile&#8221;, a preferred set of approaches and practices. Everyone is like that: it&#8217;s perfectly natural. However, these companies and individuals also have selling to do. They want you to buy their training, their coaching, their ideas. This, too, is natural.</p>
<p>Unfortunately for you, the selling can get in the way of your learning. Too often, the advertising and comments from these people try to tear down the  other guy, to make their own offering look better. This is tragic, because there are good ideas everywhere. If their tearing down the other guy turns you off, as it does me, you may miss the good ideas that are lurking under the venom. If you buy into their story about the other guy, you may miss the good ideas that he has to offer.</p>
<p>Either way, you lose. Either way, the industry loses, because good ideas are what we need.</p>
<p>Your practice needs to be one of continual improvement. You&#8217;ll find yourself in places where some ideas will help, others will hurt, and very many seem to make no difference. If you choose your ideas from a larger pool of notions, you&#8217;re more likely to find one that helps.</p>
<p><strong>Continual Improvement</strong></p>
<p>One essential aspect of Agile is to reflect on what has gone before, and to adjust what we do to make things better. This is central to all those ideas about maintaining a constant rate of progress, to working together effectively, to delivering software in small increments, and so on.</p>
<p>In Scrum terms, the team must &#8220;inspect and adapt&#8221;.</p>
<p style="padding-left: 30px;">[The point of this article is <strong>synthesis</strong>, adopting good ideas from wherever we find them. This particular idea  happens to be very  nicely expressed in Scrum. This is not a game of Scrum over Your Favorite Method: it's a game of Find an Acorn, Take It Home.]</p>
<p>What does &#8220;inspect and adapt&#8221; mean? It means we pay frequent attention to what is going on, and we look for ways to improve how we&#8217;re doing. We change our process. We change what we do. We adapt.</p>
<p>To adapt, we must choose what to try. Not all choices are equally good. Sometimes it&#8217;s not easy to tell. Often we have to try something, assess how it goes, then adapt again. Let&#8217;s look at an example.</p>
<h3>Tasks Piling Up</h3>
<p>Perhaps in our team we notice that there are always a bunch of important tasks that are not getting done. This isn&#8217;t good and we must fix it. What&#8217;s going on?</p>
<p>We&#8217;re not all the same: you are good at one kind of thing, and I&#8217;m good at another. It is natural for us to focus on our kind of work. Maybe you do the GUI work, and I do the database work. Dave over there does the testing.</p>
<p>In our planning meetings, we divide the stories or features up into what are we call &#8220;technical tasks&#8221;. You grab the GUI ones, I grab the database ones, Dave grabs the testing ones &#8230; when you and I are finally ready for him to test something. When all the programming tasks for a story are done, we integrate, Dave starts his testing tasks, finds problems, we fix them, and voila! story done!</p>
<p>Often, by which I mean almost always, it doesn&#8217;t quite work out that way. We get to the end of the iteration or Sprint or deadline, and we have lots of tasks done, but not many stories. Often I&#8217;ll see teams with 90 percent of their tasks done, but only twenty-five percent of the stories done, or even fewer. And it&#8217;s not just testing, either. We may find that we have lots of tasks done but many stories aren&#8217;t even ready to be tested!</p>
<p>We aren&#8217;t doing well, so we inspect: we have a retrospective. The cause of our problem may not be obvious.  Some possible causes include:</p>
<ul>
<li>Maybe some technical tasks are necessary, but no one likes to do them. So people do other valuable things, but none of the stories get done because no one works on the nasty bits.</li>
</ul>
<ul>
<li>Maybe we have lots of GUI changes, not much database. I get all &#8220;my work&#8221; done, but you can&#8217;t get all &#8220;your work&#8221; done. This could happen on a week-to-week basis, or it could be generally true.</li>
<li>Maybe we do things in different orders. You worked on A, B, then C. You completed A and B, and didn&#8217;t quite get your C work done. Meanwhile, I worked on C, then B, then A, and didn&#8217;t quite get my A work done. Two-thirds of the tasks are done, but only one story ever gets to Dave to be tested.</li>
<li>Maybe you and I code like demons. We get &#8220;our part&#8221; of A and B and C done, and dump them on Dave. Dave does a little testing on each, but at the end of the Sprint, none of them are working well enough.</li>
</ul>
<p>These causes may call for different solutions. We might need another GUI person. We might need to &#8220;swarm&#8221; on stories, all working on first one, then the next. We might need to put more focus on the nasty tasks, maybe even doing them first. We might need more testers. Depending on how well we have identified the problem, and how creative we are about solutions, we may do better, about the same, or worse.</p>
<p>We are trying things without knowing quite what will happen. This is natural: our world looks like this:</p>
<p><a href="http://xprogramming.com/wp-content/uploads/Green-is-Good-feathers.png"><img class="alignnone size-full wp-image-1748" title="Green-is-Good-feathers" src="http://xprogramming.com/wp-content/uploads/Green-is-Good-feathers.png" alt="" width="600" height="356" /></a></p>
<p>We start in that middle drab yellow area. We have imperfect knowledge of what&#8217;s around us, just guesses. Red is bad. Green is good. Yellow is about the same.</p>
<p>Heading off to the east, things get harder and harder. But if we stick with it a while, we come upon a lovely green area of improvement! If we head north instead, we have to slog but at least things don&#8217;t get worse. West is interesting: it looks good, but if continue for long we get in trouble.</p>
<p>How could that happen? Well, let&#8217;s consider Dave and the testing.  We programmers code stuff up, get it to compile, check it a little, integrate it, and hand it to Dave, our tester. Dave tests away, files bugs, and we fix them. Meanwhile we code other things. We notice that Dave  is overloaded, because many stories are &#8220;done but not tested&#8221;. Going west means &#8220;hire another tester&#8221;.</p>
<p>Too often, &#8220;hire another tester&#8221; patches over the issue but is not sustainable. In incremental development, we need to retest the software that has already been written, to be sure we didn&#8217;t break it in building newer features. So the testing load increases, increases, increases. So our &#8220;hire another tester&#8221; strategy results in needing more and more testers. This is simply not sustainable: as Chet Hendrickson puts it, sooner or later we run out of parking spaces for testers.</p>
<h3>We need scouts. We need a better map.</h3>
<p>Because we don&#8217;t have a map of the territory, we don&#8217;t know where we are, and we surely don&#8217;t know where to go.  Other people have been here, though, and found ways to assess the path, and good paths to take. We need their help.</p>
<p>It might also be that we didn&#8217;t even recognize the right problem: it often happens that we are blind to things going on around us. A raw approach of &#8220;inspect and adapt&#8221; can miss the problem, or miss the solution, especially if we have to make everything up.</p>
<p>We need to borrow all the tools we can to assess the situation, and to get the best ideas possible to do when we hit our kind of terrain. In other words, we need good diagnosis skills to see what&#8217;s wrong, and we need good decision skills when we decide what to do. How well we do at those things depend on the quality of our tools and ideas. We need to be open to tools and ideas from anywhere!</p>
<p>Let&#8217;s look at alternative ideas about finding and diagnosing our task problem, and how to fix it:</p>
<h3>Diagnosing the Problem</h3>
<p>A &#8220;pure Scrum&#8221; approach might have the team drawing a &#8220;burn down&#8221; chart, showing tasks done versus time. Here&#8217;s a free example from Wikipedia:</p>
<p><a href="http://xprogramming.com/wp-content/uploads/800px-SampleBurndownChart.png"><img class="alignnone size-full wp-image-1730" style="margin-top: 0px; margin-bottom: 9px;" title="800px-SampleBurndownChart" src="http://xprogramming.com/wp-content/uploads/800px-SampleBurndownChart.png" alt="" width="800" height="437" /></a></p>
<p>This chart may well show regular progress toward completion, at some smooth rate. What it doesn&#8217;t show is that more and more of the tasks not done are testing tasks. Until a retrospective, the team might not even be aware of what&#8217;s happening! Even then, many of the team members may be saying &#8220;I got my part done&#8221;. This may be true, but to someone who wants features, not tasks, it&#8217;s not very helpful.</p>
<p style="padding-left: 30px;">(In the <a title="Slices" href="http://xprogramming.com/kate-oneal/aokoslices/" target="_blank">Kate Oneal story, Slices</a>, Kate says: “Features are what we’re trying to buy and features are how we measure our progress. If I came into your feature store today, planning to buy five features, there just wouldn’t be any on the shelf to buy. I’d have to go home without features, and your feature store would have to run for another week with no revenue …”. Kate has it right: part done is Not Done.)</p>
<p>The &#8220;official&#8221; Scrum answer isn&#8217;t helping us find this problem as well as it might, much less fix it. It turns out there is a good idea waiting to be borrowed from Kanban: the task board. Here&#8217;s one from Mike Cohn. Click the link for Mike&#8217;s full article.</p>
<p><a href="http://www.mountaingoatsoftware.com/scrum/task-boards" target="_blank"><img class="alignnone size-full wp-image-1733" title="MockedTaskBoard" src="http://xprogramming.com/wp-content/uploads/MockedTaskBoard.jpg" alt="" width="781" height="446" /></a></p>
<p>To maintain a task board, the team puts all the tasks on cards, and creates a board showing all the important states that a task might be in. To Do is one. Done is another. Usually, on a task board, we don&#8217;t break out things like GUI or Database: instead, we&#8217;ll just have In Process. Aboard like this can help, a bit. We might notice that early in the Sprint, none of the testing tasks are In Process. We ask why, and the answer is &#8220;There isn&#8217;t anything to test yet. &#8221; This seems plausible enough. Later on, all the testing is In Process, and all the GUI and Database tasks are moved to &#8220;Done&#8221;, or to &#8220;Waiting for Test&#8221; if we were clever enough to have that state.</p>
<p>Watching the task board, we have a chance to see what&#8217;s going on sooner. We might otherwise need to wait for a retrospective to have a chance to notice that we are blocking on testing.</p>
<p>A team that limits itself to one name brand, Scrum in this case, may not discover a task board, because they know that task boards are not part of &#8220;our method&#8221;. Nonetheless, the task board, which a team might hear about as part of some other discipline, perhaps Kanban, would be very helpful to them.</p>
<p>What we have noticed is that there is an idea, that we heard about from the Kanban side of things, that is useful. We don&#8217;t need to repudiate everything we know about whatever we were doing before&#8211;Scrum in this case&#8211;in order to pick up a good idea from Kanban. We don&#8217;t have to buy into a whole alternate worldview and start wearing Kanban t-shirts. We have work to do here. We&#8217;ll just build the darn task board.</p>
<p>And, if we&#8217;re wise, we&#8217;ll look more deeply into the knowledge space around ideas we find. The task board doesn&#8217;t stand alone&#8211;it may not even be sourced in Kanban. It&#8217;s used there because it works will with Kanban&#8217;s other ideas. What are they? How can they help us.</p>
<p>Same thing if we find a useful idea from Lean or any other realm of thought. Let&#8217;s appropriate it into our world &#8230; and let&#8217;s look more deeply at that world. Ideas are not fenced in. Ideas relate to each other. Let&#8217;s observe what we can, use what we can, and think about it all.</p>
<h2>Synthesis:  &#8221;Yes, And&#8221;. Not &#8220;Either/Or&#8221;.</h2>
<p>For our projects to be successful, we need to draw from the whole world of ideas, not just from one little part of it. So when someone starts ranting about Scrum or Kanban or Lean or XP being &#8220;the way&#8221;, let&#8217;s not drop everything and adopt a new way of walkin&#8217; and a new way of talkin&#8217;. Just look over there, find good ideas, and bring them into our own world.</p>
<p>Listen to all the gurus and vendors. Are they pushing Scrum, Lean, Kanban, or XP, or something else you don&#8217;t know all about? Great! Listen! There are good ideas there. But as they try to help you, are they also trying to tear down some other process? Don&#8217;t listen to that, that&#8217;s just their fear talking. Your success is about what you do, and you won&#8217;t get extra credit for sticking with just one brand. You&#8217;ll get extra credit for building the best process you can.</p>
<p>In the end, it&#8217;s about your world anyway. You&#8217;re here to be effective, not here to be Pure Scrum or Pure Lean or Pure Kanban. Effective. That&#8217;s the point.</p>
]]></content:encoded>
			<wfw:commentRss>http://xprogramming.com/articles/beyond-agile-synthesis/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Getting to Safety</title>
		<link>http://xprogramming.com/articles/getting-to-safety/</link>
		<comments>http://xprogramming.com/articles/getting-to-safety/#comments</comments>
		<pubDate>Tue, 13 Jul 2010 13:58:46 +0000</pubDate>
		<dc:creator>Ron Jeffries</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[Beyond Agile]]></category>

		<guid isPermaLink="false">http://xprogramming.com/?p=1752</guid>
		<description><![CDATA[Should we ease into Agile, or jump in? How fond of being eaten by bears are you?]]></description>
			<content:encoded><![CDATA[<blockquote><p>Should we ease into Agile, or jump in? How fond of being eaten by bears are you?</p></blockquote>
<p>We should be trying to be successful. We agree, I hope, that our chances of success depend in large part on what we do. Our chances depend on our practices. How quickly&#8211;or how slowly&#8211;should we adopt practices?</p>
<p>If we look at the map of the continent of all practices, Agile is a region somewhere in the middle, where all those useful practices cluster. We all agree roughly where this region is and have our favorite areas inside it, called XP and Scrum and so on.</p>
<p><a href="http://xprogramming.com/wp-content/uploads/Continent2.png"><img class="alignnone size-full wp-image-1767" title="Continent2" src="http://xprogramming.com/wp-content/uploads/Continent2.png" alt="" width="600" height="356" /></a></p>
<p>Most of us probably agree that the closer a team is to the core of the Agile region, the better things seem to go. Their chances are better as they do more and more of the practices, and do them better.</p>
<p>Today, many teams are out in the wilderness, endangered by bears or worse. I&#8217;d like to see them get to safety as quickly as possible. The best way that I know to get to safety is to do as many of the practices as we can, as well as we can, as soon as we can. The more urgent it is to get to safety, the more important it is to add practices briskly rather than ease in to things slowly. If we move too slowly, those bears may get us before we get to safety.</p>
<p><a href="http://xprogramming.com/wp-content/uploads/Continent-arrows.png"><img class="alignnone size-full wp-image-1769" title="Continent-arrows" src="http://xprogramming.com/wp-content/uploads/Continent-arrows.png" alt="" width="600" height="356" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://xprogramming.com/articles/getting-to-safety/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Can doing something anti-Agile be more effective?</title>
		<link>http://xprogramming.com/articles/can-doing-something-anti-agile-be-more-effective/</link>
		<comments>http://xprogramming.com/articles/can-doing-something-anti-agile-be-more-effective/#comments</comments>
		<pubDate>Tue, 29 Jun 2010 13:48:45 +0000</pubDate>
		<dc:creator>Ron Jeffries</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[Beyond Agile]]></category>

		<guid isPermaLink="false">http://xprogramming.com/?p=1671</guid>
		<description><![CDATA[Let's consider two "dimensions" of a project, the extent to which it adheres to "Agile" values, and the extent to which it is an effective or successful project.]]></description>
			<content:encoded><![CDATA[<p>Let&#8217;s consider two &#8220;dimensions&#8221; of a project, the extent to which it adheres to &#8220;Agile&#8221; values, and the extent to which it is an effective or successful project.</p>
<p>We all know that there have been successful projects that didn&#8217;t seem very &#8220;Agile&#8221;. And there certainly have been projects that we might have called &#8220;Agile&#8221; but that were not very successful. Now, my experience suggests to me that agility and effectiveness are correlated: use of Agile techniques tends to improve effectiveness. Maybe the &#8220;spectrum&#8221; of Agility and Effectiveness looks something like this, with good things tending toward the upper right, and not so good toward the lower left.</p>
<p><a href="http://xprogramming.com/wp-content/uploads/spectrumIL11.png"><img class="alignnone size-full wp-image-1686" title="spectrumIL1" src="http://xprogramming.com/wp-content/uploads/spectrumIL11.png" alt="" width="598" height="356" /></a></p>
<p>Considering just the &#8220;Agility&#8221; axis, let&#8217;s look at the placement of some practices, focusing on the Agile Manifesto notion of &#8220;Individuals and Interactions over Processes and Tools&#8221;.</p>
<p><a href="http://xprogramming.com/wp-content/uploads/spectrumIL21.png"><img class="alignnone size-full wp-image-1690" title="spectrumIL2" src="http://xprogramming.com/wp-content/uploads/spectrumIL21.png" alt="" width="598" height="356" /></a></p>
<p>Similarly, we can look at design. If a team builds a great design and understands it well, that&#8217;s better than if they have a design that they understand only fairly well. We believe that if they create the design they will probably understand it. Even then, that design may not be understood across all teams, and of course, not all teams produce &#8220;great&#8221; designs.</p>
<p>In any case, a well-understood good design could be better than a great design understood by only a few.</p>
<p><a href="http://xprogramming.com/wp-content/uploads/spectrumIL31.png"><img class="alignnone size-full wp-image-1693" title="spectrumIL3" src="http://xprogramming.com/wp-content/uploads/spectrumIL31.png" alt="" width="598" height="356" /></a></p>
<p>So on our Agility/Effectiveness chart, we can think about an &#8220;Agile Direction&#8221;, where moving right is better, and an &#8220;Effectiveness Direction&#8221;, where moving up is better. Agilists believe that moving more toward Agility is likely to move you more toward Effectiveness.</p>
<p><a href="http://xprogramming.com/wp-content/uploads/spectrumIL4.png"><img class="alignnone size-full wp-image-1695" title="spectrumIL4" src="http://xprogramming.com/wp-content/uploads/spectrumIL4.png" alt="" width="598" height="356" /></a></p>
<p>Are there exceptions? Perhaps! It depends where you start, and what you change.</p>
<p>Sure, a highly skilled team can produce a design that is hard to beat, shown at top right in the picture below. But a team with low skills cannot produce a good design, no matter how self-organized they are, as shown by the blob in the lower left.</p>
<p><a href="http://xprogramming.com/wp-content/uploads/spectrumIL5.png"><img class="alignnone size-full wp-image-1697" title="spectrumIL5" src="http://xprogramming.com/wp-content/uploads/spectrumIL5.png" alt="" width="598" height="356" /></a></p>
<p>So what if we gave that low-skill team a good design to work with, made it easy to apply, and helped them understand it? The team might well be more effective, moving upward, while being less &#8220;Agile&#8221;, and moving toward the left!</p>
<p><a href="http://xprogramming.com/wp-content/uploads/spectrumIL6.png"><img class="alignnone size-full wp-image-1698" title="spectrumIL6" src="http://xprogramming.com/wp-content/uploads/spectrumIL6.png" alt="" width="598" height="356" /></a></p>
<p>I find this notion at least credible, and certainly we can imagine a situation where we do not have the time or ability to upgrade the team by hiring or training, and we must do something. And maybe the team do learn something from being given this design.</p>
<p>Every Agile team uses some provided tools, and reuses design ideas, most of which are &#8220;owned&#8221; by the team members. This is only a bit different, in that the team members probably didn&#8217;t own this design until someone gave it to them.</p>
<p>So what conclusion should we draw? One possibility is that there are projects, or teams, or situations, where Agile will not work. I wouldn&#8217;t go that far: what we have here is a case where we chose not to follow the Agile path.</p>
<p>From the Agile viewpoint, what we have here is a fundamental violation of the Scrum principle that the software must be done by a cross-functional team: a team that has all the skills needed to do the project. This team doesn&#8217;t have the design skills to do the project &#8230; and therefore they are not an Agile team at all!</p>
<p>That doesn&#8217;t mean they are evil, or that they can&#8217;t succeed. If you don&#8217;t have an Agile team, and can&#8217;t get one, well, try things that make sense. Investing in the Agile direction is likely to pay off more, but it may be difficult to impossible to invest, and it could take time. In the meantime, do what you will &#8230; and please don&#8217;t call it &#8220;Agile&#8221;. It just isn&#8217;t.</p>
]]></content:encoded>
			<wfw:commentRss>http://xprogramming.com/articles/can-doing-something-anti-agile-be-more-effective/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
	</channel>
</rss>
