<?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>Paul Butcher &#187; Software Engineering</title>
	<atom:link href="http://www.paulbutcher.com/category/softwareengineering/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.paulbutcher.com</link>
	<description></description>
	<lastBuildDate>Mon, 06 Sep 2010 14:12:29 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Android library project with tests, step by step</title>
		<link>http://www.paulbutcher.com/2010/09/android-library-project-with-tests-step-by-step/</link>
		<comments>http://www.paulbutcher.com/2010/09/android-library-project-with-tests-step-by-step/#comments</comments>
		<pubDate>Sun, 05 Sep 2010 22:47:04 +0000</pubDate>
		<dc:creator>paul</dc:creator>
				<category><![CDATA[Software Engineering]]></category>

		<guid isPermaLink="false">http://www.paulbutcher.com/?p=839</guid>
		<description><![CDATA[In Testing a library project the Android documentation says:

There are two recommended ways of setting up testing on code and resources in a library project:

You can set up a test project that instruments an application project that depends on the library project. You can then add tests to the project for library-specific features.
You can set [...]]]></description>
			<content:encoded><![CDATA[<p>In <a href="http://developer.android.com/guide/developing/other-ide.html#considerations">Testing a library project</a> the Android documentation says:</p>
<blockquote><p>
There are two recommended ways of setting up testing on code and resources in a library project:</p>
<ul>
<li>You can set up a test project that instruments an application project that depends on the library project. You can then add tests to the project for library-specific features.</li>
<li>You can set up a set up a standard application project that depends on the library and put the instrumentation in that project. This lets you create a self-contained project that contains both the tests/instrumentations and the code to test.</li>
</ul>
</blockquote>
<p>How to achieve the first of these is pretty obvious, but the second (to me, at least) rather less so. I wasn&#8217;t able to find an example, so I thought that I&#8217;d post how I managed to get it working.</p>
<p>Although it does work, I&#8217;m not 100% happy with it, and there may well be a nicer way to achieve this (see the end of this post for a discussion about my concerns). I would be very grateful for any suggestions for improvements.</p>
<p>Note, we don&#8217;t build with Eclipse (partly because we&#8217;ve found its reliability leaves a lot to be desired, but mainly because we need a command line build in order to be able to integrate with the rest of our build system and continuous integration server). So all of the following uses the Android command line tools.</p>
<h3>The steps</h3>
<ol>
<li>Create a new library project as follows:

<div class="wp_syntax"><div class="code"><pre class="none" style="font-family:monospace;">android create lib-project -n ExampleLib -t android-8 \
-p examplelib -k com.example.lib</pre></div></div>

</li>
<li>In that project, create <code>src/com/example/lib/Widget.java</code> containing:

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">com.example.lib</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Widget <span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">String</span> getColour<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #0000ff;">&quot;blue&quot;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">String</span> getDisposition<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #0000ff;">&quot;awesome&quot;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

</li>
<li>In the <code>examplelib</code> directory, create a test project with:

<div class="wp_syntax"><div class="code"><pre class="none" style="font-family:monospace;">android create test-project -m .. -p test -n ExampleTest</pre></div></div>

</li>
<li>Edit the <code>AndroidManifest.xml</code> in the test project and change the line:

<div class="wp_syntax"><div class="code"><pre class="none" style="font-family:monospace;">android:targetPackage=&quot;com.example.lib&quot;</pre></div></div>

<p>to:</p>

<div class="wp_syntax"><div class="code"><pre class="none" style="font-family:monospace;">android:targetPackage=&quot;com.example.lib.tests&quot;</pre></div></div>

</li>
<li>Delete the following line from the <code>build.properties</code> in the test project:

<div class="wp_syntax"><div class="code"><pre class="none" style="font-family:monospace;">tested.project.dir=..</pre></div></div>

<p>and add the following:</p>

<div class="wp_syntax"><div class="code"><pre class="none" style="font-family:monospace;">android.library.reference.1=..</pre></div></div>

</li>
<li>Delete the <code>src/com/example/lib/ACTIVITY_ENTRY_NAMETest.java</code> file.</li>
<li>Create <code>src/com/example/lib/WidgetTest.java</code> containing:

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">com.example.lib</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">junit.framework.TestCase</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> WidgetTest <span style="color: #000000; font-weight: bold;">extends</span> TestCase <span style="color: #009900;">&#123;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">private</span> Widget widget<span style="color: #339933;">;</span>
&nbsp;
    @Override
    <span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000066; font-weight: bold;">void</span> setUp<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        widget <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Widget<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> testColour<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        assertEquals<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;blue&quot;</span>, widget.<span style="color: #006633;">getColour</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> testDisposition<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        assertEquals<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;awesome&quot;</span>, widget.<span style="color: #006633;">getDisposition</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

</li>
<li>Start an emulator and install with <code>ant install</code>.</li>
<li>Run the tests with:

<div class="wp_syntax"><div class="code"><pre class="none" style="font-family:monospace;">adb shell am instrument \
-w com.example.lib.tests/android.test.InstrumentationTestRunner</pre></div></div>

</li>
</ol>
<h3>Reservations</h3>
<p>It&#8217;s clear from the above that the Android tools (the command line tools, at least&mdash;perhaps the Eclipse plugin is better?) don&#8217;t really fully support this way of working. Not least the fact that they assume that we&#8217;re always testing an activity in another application (hence the strangely named <code>ACTIVITY_ENTRY_NAMETest.java</code> file).</p>
<ol>
<li>In step 4, we changed the <code>targetPackage</code>. This is necessary because if we leave it as <code>com.example.lib</code>, Android will try to launch an application with that package name, which doesn&#8217;t exist. However, it&#8217;s something of a lie to suggest that the targetPackage is <code>com.example.lib.tests</code></li>
<li>In a normal Android test project, we can run the tests by typing:

<div class="wp_syntax"><div class="code"><pre class="none" style="font-family:monospace;">ant run-tests</pre></div></div>

<p>We have to run the tests explicitly with <code>adb</code>, however, because in step 5, we deleted the <code>tested.project.dir</code> line. If we don&#8217;t, the ant build system will try to rebuild the library project (and library projects can&#8217;t be build independently).</p>
<p>An alternative to the solution presented above is to set <code>tested.project.dir</code> to the current directory (<code>.</code>). This enables <code>ant run-tests</code>, but at the expense of building the project twice.</li>
</ol>
<p>So, it all works, but it&#8217;s a bit messy. Suggestions for improvements very welcome!</p>
<h3>Update</h3>
<p>Updated to simplify <code>WidgetTest</code> to use JUnit directly instead of <code>InstrumentationTestCase</code>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.paulbutcher.com/2010/09/android-library-project-with-tests-step-by-step/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Debug It! reviewed on ElegantCode</title>
		<link>http://www.paulbutcher.com/2010/08/debug-it-reviewed-on-elegantcode/</link>
		<comments>http://www.paulbutcher.com/2010/08/debug-it-reviewed-on-elegantcode/#comments</comments>
		<pubDate>Thu, 19 Aug 2010 10:25:09 +0000</pubDate>
		<dc:creator>paul</dc:creator>
				<category><![CDATA[Software Engineering]]></category>

		<guid isPermaLink="false">http://www.paulbutcher.com/?p=836</guid>
		<description><![CDATA[
This book is highly recommended as it contains a whole lot of wisdom and experience from the field of software engineering. It’s only 190 pages, so you should be able to get through very quickly. So, you can’t lose on this one.


&#8212; ElegantCode

For more reviews, see Debug It! Review Roundup.
]]></description>
			<content:encoded><![CDATA[<blockquote><p>
This book is highly recommended as it contains a whole lot of wisdom and experience from the field of software engineering. It’s only 190 pages, so you should be able to get through very quickly. So, you can’t lose on this one.
</p></blockquote>
<p style="text-align: right">
&mdash; <a href="http://elegantcode.com/2010/08/18/book-review-debug-it/">ElegantCode</a>
</p>
<p>For more reviews, see <a href="/2010/02/debug-it-review-roundup/">Debug It! Review Roundup</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.paulbutcher.com/2010/08/debug-it-reviewed-on-elegantcode/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Great Expectations</title>
		<link>http://www.paulbutcher.com/2010/07/great-expectations/</link>
		<comments>http://www.paulbutcher.com/2010/07/great-expectations/#comments</comments>
		<pubDate>Fri, 30 Jul 2010 10:12:07 +0000</pubDate>
		<dc:creator>paul</dc:creator>
				<category><![CDATA[Software Engineering]]></category>

		<guid isPermaLink="false">http://www.paulbutcher.com/?p=817</guid>
		<description><![CDATA[Here is the example source code to my PragPub article Great Expectations.
]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.paulbutcher.com/wp-content/uploads/2010/07/great_expectations.zip">Here</a> is the example source code to my PragPub article <a href="http://pragprog.com/magazines/2010-08/great-expectations">Great Expectations</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.paulbutcher.com/2010/07/great-expectations/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Debug It! reviewed on LosTechies</title>
		<link>http://www.paulbutcher.com/2010/05/debug-it-reviewed-on-lostechies/</link>
		<comments>http://www.paulbutcher.com/2010/05/debug-it-reviewed-on-lostechies/#comments</comments>
		<pubDate>Thu, 13 May 2010 12:50:18 +0000</pubDate>
		<dc:creator>paul</dc:creator>
				<category><![CDATA[Software Engineering]]></category>

		<guid isPermaLink="false">http://www.paulbutcher.com/?p=811</guid>
		<description><![CDATA[
I think that this book should be read by all new software developers as well as all junior or mid-level developers. There’s plenty to be learned by the senior developer types too. Even if you’ve been doing these things for a long time, this is a good read to make sure you’re keeping your feet [...]]]></description>
			<content:encoded><![CDATA[<blockquote><p>
I think that this book should be read by all new software developers as well as all junior or mid-level developers. There’s plenty to be learned by the senior developer types too. Even if you’ve been doing these things for a long time, this is a good read to make sure you’re keeping your feet planted firmly on the ground.
</p></blockquote>
<p style="text-align: right">
&mdash; <a href="http://www.lostechies.com/blogs/chrismissal/archive/2010/05/12/debug-it.aspx">lostechies.com</a>
</p>
<p>For more reviews, see <a href="/2010/02/debug-it-review-roundup/">Debug It! Review Roundup</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.paulbutcher.com/2010/05/debug-it-reviewed-on-lostechies/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Scala compiler advanced options</title>
		<link>http://www.paulbutcher.com/2010/04/scala-compiler-advanced-options/</link>
		<comments>http://www.paulbutcher.com/2010/04/scala-compiler-advanced-options/#comments</comments>
		<pubDate>Mon, 26 Apr 2010 10:05:19 +0000</pubDate>
		<dc:creator>paul</dc:creator>
				<category><![CDATA[Software Engineering]]></category>

		<guid isPermaLink="false">http://www.paulbutcher.com/?p=801</guid>
		<description><![CDATA[Recently I found myself trying to find a definitive list of the options supported by scalac, the Scala compiler. It turns out that I could have just asked the compiler itself (the -X option lists all &#8220;advanced&#8221; options and the -Y option lists all &#8220;private&#8221; options). But this is very difficult to find via Google.
So [...]]]></description>
			<content:encoded><![CDATA[<p>Recently I found myself trying to find a definitive list of the options supported by <code>scalac</code>, the Scala compiler. It turns out that I could have just asked the compiler itself (the <code>-X</code> option lists all &#8220;advanced&#8221; options and the <code>-Y</code> option lists all &#8220;private&#8221; options). But this is very difficult to find via Google.</p>
<p>So I thought that I&#8217;d create this page and hopefully save anyone else looking for the same information some time.</p>

<div class="wp_syntax"><div class="code"><pre class="none" style="font-family:monospace;">$ scalac -version
Scala compiler version 2.8.0.RC1 -- Copyright 2002-2010, LAMP/EPFL</pre></div></div>

<h3>Advanced Options</h3>

<div class="wp_syntax"><div class="code"><pre class="none" style="font-family:monospace;">$ scalac -X
Usage: scalac &lt;options&gt; &lt;source files&gt;
Possible advanced options include:
  -Xassem-extdirs &lt;dirs&gt;         List of directories containing assemblies, defaults to `lib'
  -Xassem-name &lt;file&gt;            Name of the output assembly (only relevant with -target:msil)
  -Xassem-path &lt;path&gt;            List of assemblies referenced by the program (only relevant with -target:msil)
  -Xcheck-null                   Emit warning on selection of nullable reference
  -Xcheckinit                    Add runtime checks on field accessors. Uninitialized accesses result in an exception being thrown.
  -Xdisable-assertions           Generate no assertions and assumptions
  -Xelide-below                  Generate calls to @elidable-marked methods only if method priority is greater than argument.
  -Xexperimental                 Enable experimental extensions
  -Xfuture                       Turn on future language features
  -Xgenerate-phase-graph &lt;file&gt;  Generate the phase graphs (outputs .dot files) to fileX.dot
  -Xlog-implicits                Show more info on why some implicits are not applicable
  -Xmigration                    Warn about constructs whose behavior may have changed between 2.7 and 2.8
  -Xno-forwarders                Do not generate static forwarders in mirror classes
  -Xno-uescape                   Disables handling of \u unicode escapes
  -Xnojline                      Do not use JLine for editing
  -Xplugin-disable:&lt;plugin&gt;      Disable a plugin
  -Xplugin-list                  Print a synopsis of loaded plugins
  -Xplugin-require:&lt;plugin&gt;      Abort unless a plugin is available
  -Xplugin:&lt;file&gt;                Load a plugin from a file
  -Xpluginsdir &lt;path&gt;            Path to search compiler plugins
  -Xprint-icode                  Log internal icode to *.icode files
  -Xprint-pos                    Print tree positions (as offsets)
  -Xprint-types                  Print tree types (debugging option)
  -Xprint:&lt;phase&gt;                Print out program after &lt;phase&gt; or &quot;all&quot;
  -Xprompt                       Display a prompt after each error (debugging option)
  -Xresident                     Compiler stays resident, files to compile are read from standard input
  -Xscript &lt;object&gt;              Compile as a script, wrapping the code into object.main()
  -Xshow-class &lt;class&gt;           Show class info
  -Xshow-object &lt;object&gt;         Show object info
  -Xshow-phases                  Print a synopsis of compiler phases
  -Xsource-reader &lt;classname&gt;    Specify a custom method for reading source files
  -Xsourcedir &lt;directory&gt;        When -target:msil, the source folder structure is mirrored in output directory.
  -Xstrict-warnings              Emit warnings about lots of things.
  -Xwarninit                     Warn about possible changes in initialization semantics
  -Y                             Print a synopsis of private options</pre></div></div>

<h3>Private Options</h3>

<div class="wp_syntax"><div class="code"><pre class="none" style="font-family:monospace;">$ scalac -Y
Usage: scalac &lt;options&gt; &lt;source files&gt;
Possible private options include:
  -Ybrowse:&lt;phase&gt;               Browse the abstract syntax tree after &lt;phase&gt; or &quot;all&quot;
  -Ybuild-manager-debug          Generate debug information for the Refined Build Manager compiler.
  -Ybuilder-debug:&lt;method&gt;       Compile using the specified build manager (none,refined,simple)
  -Ycheck:&lt;phase&gt;                Check the tree at the end of &lt;phase&gt; or &quot;all&quot;
  -Yclosure-elim                 Perform closure elimination
  -Ycompact-trees                Use compact tree printer when displaying trees
  -Ydead-code                    Perform dead code elimination
  -Ydebug                        Output debugging messages
  -Ydetach                       Perform detaching of remote closures
  -Yfatal-warnings               Fail the compilation if there are any warnings.
  -Yide-debug                    Generate, validate and output trees using the interactive compiler.
  -Yinline                       Perform inlining when possible
  -Yjenkins-hashCodes            Use jenkins hash algorithm for case class generated hashCodes.
  -Ylinearizer:&lt;which&gt;           Linearizer to use (normal,dfs,rpo,dump)
  -Ylog-classpath                Output information about what classpath is being applied.
  -Ylog:&lt;phase&gt;                  Log operations in &lt;phase&gt; or &quot;all&quot;
  -Yno-completion                Disable tab-completion in the REPL
  -Yno-generic-signatures        Suppress generation of generic signatures for Java
  -Yno-imports                   Compile without any implicit imports
  -Yno-predefs                   Compile without any implicit predefined values
  -Ypmat-debug                   Trace all pattern matcher activity.
  -Ypmat-naive                   Desugar matches as naively as possible..
  -Yrangepos                     Use range positions for syntax trees.
  -Yrecursion                    Recursion depth used when locking symbols
  -Yrepl-debug                   Trace all repl activity.
  -Yself-in-annots               Include a &quot;self&quot; identifier inside of annotations
  -Yshow-trees                   Show detailed trees when used in connection with -print:phase
  -Yskip:&lt;phase&gt;                 Skip &lt;phase&gt; or &quot;all&quot;
  -Ysqueeze:&lt;enabled&gt;            if on, creates compact code in matching (on,off)
  -Ystatistics                   Print compiler statistics
  -Ystop:&lt;phase&gt;                 Stop after phase &lt;phase&gt; or &quot;all&quot;
  -Ystruct-dispatch:&lt;method&gt;     Selects dispatch method for structural refinement method calls (no-cache,mono-cache,poly-cache,invoke-dynamic)
  -Ysuppress-vt-typer-warnings   Suppress warnings from the typer when testing the virtual class encoding, NOT FOR FINAL!
  -Ytailrecommend                Alert methods which would be tail-recursive if private or final.
  -Ytyper-debug                  Trace all type assignements
  -Ywarn-catches                 Emit warnings about catch blocks which catch everything.
  -Ywarn-dead-code               Emit warnings for dead code
  -Ywarn-shadowing               Emit warnings about possible variable shadowing.</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.paulbutcher.com/2010/04/scala-compiler-advanced-options/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Scala 2.8.0.RC1, sbt and ScalaTest step-by-step</title>
		<link>http://www.paulbutcher.com/2010/04/scala-2-8-0-rc1-sbt-and-scalatest-step-by-step/</link>
		<comments>http://www.paulbutcher.com/2010/04/scala-2-8-0-rc1-sbt-and-scalatest-step-by-step/#comments</comments>
		<pubDate>Sat, 24 Apr 2010 10:12:04 +0000</pubDate>
		<dc:creator>paul</dc:creator>
				<category><![CDATA[Software Engineering]]></category>

		<guid isPermaLink="false">http://www.paulbutcher.com/?p=777</guid>
		<description><![CDATA[I spent quite a bit of time beating my head against the details of getting Scala 2.8.0.RC1, sbt and ScalaTest to play nicely with each other. So here&#8217;s a step-by-step guide which will hopefully save others time.

Install sbt
Create a new project as follows:

$ mkdir aproject
$ cd aproject/
$ sbt
Project does not exist, create new project? &#40;y/N/s&#41; [...]]]></description>
			<content:encoded><![CDATA[<p>I spent quite a bit of time beating my head against the details of getting <a href="http://www.scala-lang.org/">Scala 2.8.0.RC1</a>, <a href="http://code.google.com/p/simple-build-tool/">sbt</a> and <a href="http://www.scalatest.org/">ScalaTest</a> to play nicely with each other. So here&#8217;s a step-by-step guide which will hopefully save others time.</p>
<ol>
<li><a href="http://code.google.com/p/simple-build-tool/wiki/Setup">Install sbt</a></li>
<li>Create a new project as follows:

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">mkdir</span> aproject
$ <span style="color: #7a0874; font-weight: bold;">cd</span> aproject<span style="color: #000000; font-weight: bold;">/</span>
$ sbt
Project does not exist, create new project? <span style="color: #7a0874; font-weight: bold;">&#40;</span>y<span style="color: #000000; font-weight: bold;">/</span>N<span style="color: #000000; font-weight: bold;">/</span>s<span style="color: #7a0874; font-weight: bold;">&#41;</span> y
Name: aproject
Organization: com.example
Version <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">1.0</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>: 
Scala version <span style="color: #7a0874; font-weight: bold;">&#91;</span>2.7.7<span style="color: #7a0874; font-weight: bold;">&#93;</span>: 2.8.0.RC1
sbt version <span style="color: #7a0874; font-weight: bold;">&#91;</span>0.7.3<span style="color: #7a0874; font-weight: bold;">&#93;</span>:</pre></div></div>

</li>
<li>Create a build configuration file in <code>project/build/AProject.scala</code> containing:

<div class="wp_syntax"><div class="code"><pre class="scala" style="font-family:monospace;"><span style="color: #0000ff; font-weight: bold;">import</span> sbt.<span style="color: #000080;">_</span> 
&nbsp;
<span style="color: #0000ff; font-weight: bold;">class</span> AProject<span style="color: #F78811;">&#40;</span>info<span style="color: #000080;">:</span> ProjectInfo<span style="color: #F78811;">&#41;</span> <span style="color: #0000ff; font-weight: bold;">extends</span> DefaultProject<span style="color: #F78811;">&#40;</span>info<span style="color: #F78811;">&#41;</span> <span style="color: #F78811;">&#123;</span> 
  <span style="color: #0000ff; font-weight: bold;">val</span> scalaToolsSnapshots <span style="color: #000080;">=</span> ScalaToolsSnapshots
  <span style="color: #0000ff; font-weight: bold;">val</span> scalatest <span style="color: #000080;">=</span> <span style="color: #6666FF;">&quot;org.scalatest&quot;</span> <span style="color: #000080;">%</span> <span style="color: #6666FF;">&quot;scalatest&quot;</span> <span style="color: #000080;">%</span>
    <span style="color: #6666FF;">&quot;1.0.1-for-scala-2.8.0.RC1-SNAPSHOT&quot;</span>
<span style="color: #F78811;">&#125;</span></pre></div></div>

<p>This tells sbt that you will be using the pre-release snapshot version of ScalaTest for Scala 2.8.0.RC1.
</li>
<li>Download the ScalaTest library with <code>sbt update</code>. After running this, you should see that you have a <code>lib_managed</code> directory containing the ScalaTest jar.</li>
<li>Create <code>src/main/scala/Widget.scala</code> containing:

<div class="wp_syntax"><div class="code"><pre class="scala" style="font-family:monospace;"><span style="color: #0000ff; font-weight: bold;">package</span> com.<span style="color: #000000;">example</span>
&nbsp;
<span style="color: #0000ff; font-weight: bold;">class</span> Widget <span style="color: #F78811;">&#123;</span>
  <span style="color: #0000ff; font-weight: bold;">def</span> colour <span style="color: #000080;">=</span> <span style="color: #6666FF;">&quot;Blue&quot;</span>
  <span style="color: #0000ff; font-weight: bold;">def</span> disposition <span style="color: #000080;">=</span> <span style="color: #6666FF;">&quot;Awesome&quot;</span>
<span style="color: #F78811;">&#125;</span></pre></div></div>

</li>
<li>Create <code>src/test/scala/WidgetSpec.scala</code> containing:

<div class="wp_syntax"><div class="code"><pre class="scala" style="font-family:monospace;"><span style="color: #0000ff; font-weight: bold;">package</span> com.<span style="color: #000000;">example</span>.<span style="color: #000000;">test</span>
&nbsp;
<span style="color: #0000ff; font-weight: bold;">import</span> org.<span style="color: #000000;">scalatest</span>.<span style="color: #000000;">Spec</span>
<span style="color: #0000ff; font-weight: bold;">import</span> com.<span style="color: #000000;">example</span>.<span style="color: #000000;">Widget</span>
&nbsp;
<span style="color: #0000ff; font-weight: bold;">class</span> WidgetSpec <span style="color: #0000ff; font-weight: bold;">extends</span> Spec <span style="color: #F78811;">&#123;</span>
&nbsp;
  describe<span style="color: #F78811;">&#40;</span><span style="color: #6666FF;">&quot;A Widget&quot;</span><span style="color: #F78811;">&#41;</span> <span style="color: #F78811;">&#123;</span>
&nbsp;
    it<span style="color: #F78811;">&#40;</span><span style="color: #6666FF;">&quot;should be blue&quot;</span><span style="color: #F78811;">&#41;</span> <span style="color: #F78811;">&#123;</span>
      expect<span style="color: #F78811;">&#40;</span><span style="color: #6666FF;">&quot;Blue&quot;</span><span style="color: #F78811;">&#41;</span> <span style="color: #F78811;">&#123;</span> <span style="color: #0000ff; font-weight: bold;">new</span> Widget<span style="color: #F78811;">&#40;</span><span style="color: #F78811;">&#41;</span>.<span style="color: #000000;">colour</span> <span style="color: #F78811;">&#125;</span>
    <span style="color: #F78811;">&#125;</span>
&nbsp;
    it<span style="color: #F78811;">&#40;</span><span style="color: #6666FF;">&quot;should be awesome&quot;</span><span style="color: #F78811;">&#41;</span> <span style="color: #F78811;">&#123;</span>
      expect<span style="color: #F78811;">&#40;</span><span style="color: #6666FF;">&quot;Awesome&quot;</span><span style="color: #F78811;">&#41;</span> <span style="color: #F78811;">&#123;</span> <span style="color: #0000ff; font-weight: bold;">new</span> Widget<span style="color: #F78811;">&#40;</span><span style="color: #F78811;">&#41;</span>.<span style="color: #000000;">disposition</span> <span style="color: #F78811;">&#125;</span>
    <span style="color: #F78811;">&#125;</span>
  <span style="color: #F78811;">&#125;</span>
<span style="color: #F78811;">&#125;</span></pre></div></div>

</li>
<li>Run your tests with <code>sbt test</code>. You should see:

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">&#91;</span>info<span style="color: #7a0874; font-weight: bold;">&#93;</span> == com.example.test.WidgetSpec ==
<span style="color: #7a0874; font-weight: bold;">&#91;</span>info<span style="color: #7a0874; font-weight: bold;">&#93;</span> A Widget
<span style="color: #7a0874; font-weight: bold;">&#91;</span>info<span style="color: #7a0874; font-weight: bold;">&#93;</span> Test Starting: A Widget should be blue
<span style="color: #7a0874; font-weight: bold;">&#91;</span>info<span style="color: #7a0874; font-weight: bold;">&#93;</span> Test Passed: A Widget should be blue
<span style="color: #7a0874; font-weight: bold;">&#91;</span>info<span style="color: #7a0874; font-weight: bold;">&#93;</span> Test Starting: A Widget should be awesome
<span style="color: #7a0874; font-weight: bold;">&#91;</span>info<span style="color: #7a0874; font-weight: bold;">&#93;</span> Test Passed: A Widget should be awesome
<span style="color: #7a0874; font-weight: bold;">&#91;</span>info<span style="color: #7a0874; font-weight: bold;">&#93;</span> == com.example.test.WidgetSpec ==</pre></div></div>

</li>
<li>Create <code>src/main/scala/Main.scala</code> containing:

<div class="wp_syntax"><div class="code"><pre class="scala" style="font-family:monospace;"><span style="color: #0000ff; font-weight: bold;">package</span> com.<span style="color: #000000;">example</span>
&nbsp;
<span style="color: #0000ff; font-weight: bold;">object</span> Main <span style="color: #F78811;">&#123;</span>
  <span style="color: #0000ff; font-weight: bold;">def</span> main<span style="color: #F78811;">&#40;</span>args<span style="color: #000080;">:</span> Array<span style="color: #F78811;">&#91;</span>String<span style="color: #F78811;">&#93;</span><span style="color: #F78811;">&#41;</span> <span style="color: #F78811;">&#123;</span>
    <span style="color: #0000ff; font-weight: bold;">val</span> w <span style="color: #000080;">=</span> <span style="color: #0000ff; font-weight: bold;">new</span> Widget<span style="color: #F78811;">&#40;</span><span style="color: #F78811;">&#41;</span>
    println<span style="color: #F78811;">&#40;</span><span style="color: #6666FF;">&quot;My new widget is &quot;</span>+ w.<span style="color: #000000;">colour</span><span style="color: #F78811;">&#41;</span>
  <span style="color: #F78811;">&#125;</span>
<span style="color: #F78811;">&#125;</span></pre></div></div>

</li>
<li>Run your program with <code>sbt run</code>. You should see:

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">&#91;</span>info<span style="color: #7a0874; font-weight: bold;">&#93;</span> Running com.example.Main 
My new widget is Blue</pre></div></div>

</li>
</ol>
<p><b>Update:</b> Use the pre-defined ScalaToolsSnapshots repo (thanks to Erick Fleming).</p>
<p><b>Update:</b> Fixed a typo in step 8 (thanks to Jason).</p>
]]></content:encoded>
			<wfw:commentRss>http://www.paulbutcher.com/2010/04/scala-2-8-0-rc1-sbt-and-scalatest-step-by-step/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Fuzzy about Scala</title>
		<link>http://www.paulbutcher.com/2010/04/fuzzy-about-scala/</link>
		<comments>http://www.paulbutcher.com/2010/04/fuzzy-about-scala/#comments</comments>
		<pubDate>Thu, 01 Apr 2010 22:17:57 +0000</pubDate>
		<dc:creator>paul</dc:creator>
				<category><![CDATA[Software Engineering]]></category>

		<guid isPermaLink="false">http://www.paulbutcher.com/?p=749</guid>
		<description><![CDATA[I&#8217;ve recently started working on a new project (SwiftKey), and my immediate priority is to get our testing sorted out. To that end, I&#8217;m constructing a fuzz test suite. Partly because I think that it&#8217;s the right tool for the job, and partly because it&#8217;s a good opportunity for me to learn more about the [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve recently started working on a new project (<a href="http://www.swiftkey.net/">SwiftKey</a>), and my immediate priority is to get our testing sorted out. To that end, I&#8217;m constructing a fuzz test suite. Partly because I think that it&#8217;s the right tool for the job, and partly because it&#8217;s a good opportunity for me to learn more about the language, I&#8217;m writing it in Scala.</p>
<p>A fuzz test interacts with the System Under Test in a random, yet structured manner. The object of the exercise is to construct sequences of API calls (or network traffic, or whatever) that flush out the kind of bugs that are less likely to be discovered by unit tests tests and the like. Fuzz tests are particularly good at finding things like security problems, buffer overruns, memory leaks etc.</p>
<p>Clearly randomness is a large part of a fuzz test, so I&#8217;m creating some utilities that make it easier to randomly choose between several different actions. I thought that I&#8217;d publish them just in case anyone else finds them useful, and also to solicit feedback to help me improve my use of Scala (bear in mind that I&#8217;m still finding my feet, so be gentle!).</p>
<p>So, here&#8217;s my first attempt:</p>

<div class="wp_syntax"><div class="code"><pre class="scala" style="font-family:monospace;"><span style="color: #0000ff; font-weight: bold;">val</span> random <span style="color: #000080;">=</span> <span style="color: #0000ff; font-weight: bold;">new</span> Random
&nbsp;
<span style="color: #0000ff; font-weight: bold;">def</span> oneAtRandom<span style="color: #F78811;">&#40;</span>actions<span style="color: #000080;">:</span> <span style="color: #F78811;">&#40;</span><span style="color: #F78811;">&#41;</span> <span style="color: #000080;">=&gt;</span> Unit<span style="color: #000080;">*</span><span style="color: #F78811;">&#41;</span><span style="color: #F78811;">&#40;</span><span style="color: #F78811;">&#41;</span> <span style="color: #000080;">=</span>
  <span style="color: #F78811;">&#40;</span><span style="color: #F78811;">&#41;</span> <span style="color: #000080;">=&gt;</span> actions<span style="color: #F78811;">&#40;</span>random.<span style="color: #000000;">nextInt</span><span style="color: #F78811;">&#40;</span>actions.<span style="color: #000000;">length</span><span style="color: #F78811;">&#41;</span><span style="color: #F78811;">&#41;</span><span style="color: #F78811;">&#40;</span><span style="color: #F78811;">&#41;</span></pre></div></div>

<p><code>oneAtRandom</code> takes a set of functions and returns another function which, each time it&#8217;s called, executes one of them at random. For example:</p>

<div class="wp_syntax"><div class="code"><pre class="scala" style="font-family:monospace;"><span style="color: #0000ff; font-weight: bold;">val</span> randomAction <span style="color: #000080;">=</span> oneAtRandom<span style="color: #F78811;">&#40;</span>
  <span style="color: #F78811;">&#40;</span><span style="color: #F78811;">&#41;</span> <span style="color: #000080;">=&gt;</span> print<span style="color: #F78811;">&#40;</span><span style="color: #6666FF;">'a'</span><span style="color: #F78811;">&#41;</span>, <span style="color: #F78811;">&#40;</span><span style="color: #F78811;">&#41;</span> <span style="color: #000080;">=&gt;</span> print<span style="color: #F78811;">&#40;</span><span style="color: #6666FF;">'b'</span><span style="color: #F78811;">&#41;</span>, <span style="color: #F78811;">&#40;</span><span style="color: #F78811;">&#41;</span> <span style="color: #000080;">=&gt;</span> print<span style="color: #F78811;">&#40;</span><span style="color: #6666FF;">'c'</span><span style="color: #F78811;">&#41;</span><span style="color: #F78811;">&#41;</span>
&nbsp;
<span style="color: #0000ff; font-weight: bold;">for</span><span style="color: #F78811;">&#40;</span><span style="color: #000080;">_</span> <span style="color: #000080;">&lt;</span>- <span style="color: #F78811;">1</span> to <span style="color: #F78811;">10</span><span style="color: #F78811;">&#41;</span>
  randomAction<span style="color: #F78811;">&#40;</span><span style="color: #F78811;">&#41;</span></pre></div></div>

<p>Which gives the following output:</p>

<div class="wp_syntax"><div class="code"><pre class="scala" style="font-family:monospace;">aabaacbbcc</pre></div></div>

<p>So far, so good. But what if we want different functions to be executed with different frequencies? We might have some actions that we want to only happen occasionally? Here&#8217;s another version of <code>oneAtRandom</code> that takes a weighted set of functions and calls them in proportion to their relative weights:</p>

<div class="wp_syntax"><div class="code"><pre class="scala" style="font-family:monospace;"><span style="color: #0000ff; font-weight: bold;">def</span> oneAtRandom<span style="color: #F78811;">&#40;</span>actions<span style="color: #000080;">:</span> <span style="color: #F78811;">&#40;</span>Int, <span style="color: #F78811;">&#40;</span><span style="color: #F78811;">&#41;</span> <span style="color: #000080;">=&gt;</span> Unit<span style="color: #F78811;">&#41;</span><span style="color: #000080;">*</span><span style="color: #F78811;">&#41;</span><span style="color: #F78811;">&#40;</span><span style="color: #F78811;">&#41;</span> <span style="color: #000080;">=</span> <span style="color: #F78811;">&#123;</span>
  <span style="color: #0000ff; font-weight: bold;">val</span> totalWeight <span style="color: #000080;">=</span> actions.<span style="color: #000000;">foldLeft</span><span style="color: #F78811;">&#40;</span><span style="color: #F78811;">0</span><span style="color: #F78811;">&#41;</span> <span style="color: #F78811;">&#123;</span><span style="color: #000080;">_</span> + <span style="color: #000080;">_</span>.<span style="color: #000080;">_</span>1<span style="color: #F78811;">&#125;</span>
  <span style="color: #F78811;">&#40;</span><span style="color: #F78811;">&#41;</span> <span style="color: #000080;">=&gt;</span> <span style="color: #F78811;">&#123;</span>
    <span style="color: #0000ff; font-weight: bold;">val</span> r <span style="color: #000080;">=</span> random.<span style="color: #000000;">nextInt</span><span style="color: #F78811;">&#40;</span>totalWeight<span style="color: #F78811;">&#41;</span>
    <span style="color: #0000ff; font-weight: bold;">var</span> w <span style="color: #000080;">=</span> <span style="color: #F78811;">0</span>
    <span style="color: #0000ff; font-weight: bold;">val</span> <span style="color: #F78811;">&#40;</span><span style="color: #000080;">_</span>, action<span style="color: #F78811;">&#41;</span> <span style="color: #000080;">=</span> actions.<span style="color: #000000;">find</span> <span style="color: #F78811;">&#123;</span>
        <span style="color: #0000ff; font-weight: bold;">case</span><span style="color: #F78811;">&#40;</span>weight, <span style="color: #000080;">_</span><span style="color: #F78811;">&#41;</span> <span style="color: #000080;">=&gt;</span> w +<span style="color: #000080;">=</span> weight<span style="color: #000080;">;</span> w <span style="color: #000080;">&gt;</span> r
      <span style="color: #F78811;">&#125;</span>.<span style="color: #000000;">get</span>
    action<span style="color: #F78811;">&#40;</span><span style="color: #F78811;">&#41;</span>
  <span style="color: #F78811;">&#125;</span>
<span style="color: #F78811;">&#125;</span></pre></div></div>

<p>Here&#8217;s how it&#8217;s used:</p>

<div class="wp_syntax"><div class="code"><pre class="scala" style="font-family:monospace;"><span style="color: #0000ff; font-weight: bold;">val</span> randomAction <span style="color: #000080;">=</span> oneAtRandom<span style="color: #F78811;">&#40;</span>
    <span style="color: #F78811;">&#40;</span><span style="color: #F78811;">1</span>, <span style="color: #F78811;">&#40;</span><span style="color: #F78811;">&#41;</span> <span style="color: #000080;">=&gt;</span> println<span style="color: #F78811;">&#40;</span><span style="color: #6666FF;">&quot;rare&quot;</span><span style="color: #F78811;">&#41;</span><span style="color: #F78811;">&#41;</span>,
    <span style="color: #F78811;">&#40;</span><span style="color: #F78811;">10</span>, <span style="color: #F78811;">&#40;</span><span style="color: #F78811;">&#41;</span> <span style="color: #000080;">=&gt;</span> println<span style="color: #F78811;">&#40;</span><span style="color: #6666FF;">&quot;occasional&quot;</span><span style="color: #F78811;">&#41;</span><span style="color: #F78811;">&#41;</span>,
    <span style="color: #F78811;">&#40;</span><span style="color: #F78811;">50</span>, <span style="color: #F78811;">&#40;</span><span style="color: #F78811;">&#41;</span> <span style="color: #000080;">=&gt;</span> println<span style="color: #F78811;">&#40;</span><span style="color: #6666FF;">&quot;frequent&quot;</span><span style="color: #F78811;">&#41;</span><span style="color: #F78811;">&#41;</span>
  <span style="color: #F78811;">&#41;</span>
&nbsp;
<span style="color: #0000ff; font-weight: bold;">for</span><span style="color: #F78811;">&#40;</span><span style="color: #000080;">_</span> <span style="color: #000080;">&lt;</span>- <span style="color: #F78811;">1</span> to <span style="color: #F78811;">100</span><span style="color: #F78811;">&#41;</span>
  randomAction<span style="color: #F78811;">&#40;</span><span style="color: #F78811;">&#41;</span></pre></div></div>

<p>And to prove that it&#8217;s doing what it claims:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ scala random2.scala <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">sort</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">uniq</span> <span style="color: #660033;">-c</span>
  <span style="color: #000000;">88</span> frequent
  <span style="color: #000000;">11</span> occasional
   <span style="color: #000000;">1</span> rare
&nbsp;
$ scala random2.scala <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">sort</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">uniq</span> <span style="color: #660033;">-c</span>
  <span style="color: #000000;">82</span> frequent
  <span style="color: #000000;">12</span> occasional
   <span style="color: #000000;">6</span> rare</pre></div></div>

<p>So I&#8217;ve got it working, which I&#8217;m happy about. But I&#8217;m sure that it could be improved. I&#8217;m sure, for example, that there must be a &#8220;nice&#8221; functional way to implement the loop inside the weighted version (instead of using <code>var w</code> as an accumulator), but each of my attempts to do so have ended up being considerably more complex than the current version.</p>
<p>I&#8217;d also love to use the <code>-></code> notation to pass the arguments, for example:</p>

<div class="wp_syntax"><div class="code"><pre class="scala" style="font-family:monospace;"><span style="color: #0000ff; font-weight: bold;">val</span> randomAction <span style="color: #000080;">=</span> oneAtRandom<span style="color: #F78811;">&#40;</span>
    <span style="color: #F78811;">1</span> -<span style="color: #000080;">&gt;</span> <span style="color: #F78811;">&#40;</span><span style="color: #F78811;">&#41;</span> <span style="color: #000080;">=&gt;</span> println<span style="color: #F78811;">&#40;</span><span style="color: #6666FF;">&quot;rare&quot;</span><span style="color: #F78811;">&#41;</span>,
    <span style="color: #F78811;">10</span> -<span style="color: #000080;">&gt;</span> <span style="color: #F78811;">&#40;</span><span style="color: #F78811;">&#41;</span> <span style="color: #000080;">=&gt;</span> println<span style="color: #F78811;">&#40;</span><span style="color: #6666FF;">&quot;occasional&quot;</span><span style="color: #F78811;">&#41;</span>,
    <span style="color: #F78811;">50</span> -<span style="color: #000080;">&gt;</span> <span style="color: #F78811;">&#40;</span><span style="color: #F78811;">&#41;</span> <span style="color: #000080;">=&gt;</span> println<span style="color: #F78811;">&#40;</span><span style="color: #6666FF;">&quot;frequent&quot;</span><span style="color: #F78811;">&#41;</span>
  <span style="color: #F78811;">&#41;</span></pre></div></div>

<p>But doing so results in a parse error&mdash;the only way I&#8217;ve found to avoid it is to add additional parentheses:</p>

<div class="wp_syntax"><div class="code"><pre class="scala" style="font-family:monospace;"><span style="color: #0000ff; font-weight: bold;">val</span> randomAction <span style="color: #000080;">=</span> oneAtRandom<span style="color: #F78811;">&#40;</span>
    <span style="color: #F78811;">1</span> -<span style="color: #000080;">&gt;</span> <span style="color: #F78811;">&#40;</span><span style="color: #F78811;">&#40;</span><span style="color: #F78811;">&#41;</span> <span style="color: #000080;">=&gt;</span> println<span style="color: #F78811;">&#40;</span><span style="color: #6666FF;">&quot;rare&quot;</span><span style="color: #F78811;">&#41;</span><span style="color: #F78811;">&#41;</span>,
    <span style="color: #F78811;">10</span> -<span style="color: #000080;">&gt;</span> <span style="color: #F78811;">&#40;</span><span style="color: #F78811;">&#40;</span><span style="color: #F78811;">&#41;</span> <span style="color: #000080;">=&gt;</span> println<span style="color: #F78811;">&#40;</span><span style="color: #6666FF;">&quot;occasional&quot;</span><span style="color: #F78811;">&#41;</span><span style="color: #F78811;">&#41;</span>,
    <span style="color: #F78811;">50</span> -<span style="color: #000080;">&gt;</span> <span style="color: #F78811;">&#40;</span><span style="color: #F78811;">&#40;</span><span style="color: #F78811;">&#41;</span> <span style="color: #000080;">=&gt;</span> println<span style="color: #F78811;">&#40;</span><span style="color: #6666FF;">&quot;frequent&quot;</span><span style="color: #F78811;">&#41;</span><span style="color: #F78811;">&#41;</span>
  <span style="color: #F78811;">&#41;</span></pre></div></div>

<p>which is starting to feel a bit too much like Lisp for my taste <img src='http://www.paulbutcher.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>Finally, I&#8217;m really missing some of the handy little utilities provided by Ruby. In Ruby, for example, I could write the loops that call <code>randomAction</code> like this:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">10.<span style="color:#9900CC;">times</span> <span style="color:#006600; font-weight:bold;">&#123;</span> randomAction <span style="color:#006600; font-weight:bold;">&#125;</span></pre></div></div>

<p>I know that it&#8217;s trivial to create this kind of utility, but one of the nice things about Ruby is that they all come as standard out of the box.</p>
<p>In any case, I&#8217;d be very grateful for any and all feedback on the above. Thanks in advance!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.paulbutcher.com/2010/04/fuzzy-about-scala/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Debug It! Review Roundup</title>
		<link>http://www.paulbutcher.com/2010/02/debug-it-review-roundup/</link>
		<comments>http://www.paulbutcher.com/2010/02/debug-it-review-roundup/#comments</comments>
		<pubDate>Wed, 17 Feb 2010 09:00:11 +0000</pubDate>
		<dc:creator>paul</dc:creator>
				<category><![CDATA[Software Engineering]]></category>

		<guid isPermaLink="false">http://www.paulbutcher.com/?p=713</guid>
		<description><![CDATA[
It&#8217;s clear that the author&#8217;s years of debugging experience were superbly distilled into this collection of high impact advice.


&#8212; www.drdobbs.com


A must have book for anyone writing programs.


&#8212; www.felgall.com


Perhaps it’s the fact that it’s Paul Butcher’s first book that gives Debug It! its remarkable charm and conviction. The fact that very few other books cover the [...]]]></description>
			<content:encoded><![CDATA[<blockquote><p>
It&#8217;s clear that the author&#8217;s years of debugging experience were superbly distilled into this collection of high impact advice.
</p></blockquote>
<p style="text-align: right">
&mdash; <a href="http://www.drdobbs.com/blog/archives/2010/01/debug_it_book_r.html">www.drdobbs.com</a>
</p>
<blockquote><p>
A must have book for anyone writing programs.
</p></blockquote>
<p style="text-align: right">
&mdash; <a href="http://www.felgall.com/debug.htm">www.felgall.com</a>
</p>
<blockquote><p>
Perhaps it’s the fact that it’s Paul Butcher’s first book that gives Debug It! its remarkable charm and conviction. The fact that very few other books cover the theme on such an intellectual and psychological level undoubtedly helps set it apart from the few books currently out there too. Either way you look at it, Paul’s take on debugging is certainly essential reading for those looking to clean up their act and, more importantly, their code.
</p></blockquote>
<p style="text-align: right">
&mdash; <a href="http://www.linuxuser.co.uk/reviews/debug-it-book-review/">www.linuxuser.co.uk</a>
</p>
<blockquote><p>
Overall, this book is going to be a huge win, and I think it’s a worthy successor to the Release It! reputation. Development managers and team leads should get a copy for the junior developers on their team as a Christmas gift, but only after the senior developers have read through it as well.
</p></blockquote>
<p style="text-align: right">
&mdash; <a href="http://blogs.tedneward.com/2009/11/23/Book+Review+Debug+It+Paul+Butcher+Pragmatic+Bookshelf.aspx">blogs.tedneward.com</a>
</p>
<blockquote><p>
Excellent discussion of the strategy of debugging. Buy, it read it and kill bugs.
</p></blockquote>
<p style="text-align: right">
&mdash; <a href="http://www.i-programmer.info/bookreviews/20/567-debug-it.html">i-programmer.info</a>
</p>
<blockquote><p>
Frankly, I wish this book would be read by a lot of developers
</p></blockquote>
<p style="text-align: right">
&mdash; <a href="http://www.jasonbock.net/JB/Default.aspx?blog=entry.297be5e667cb41dfa318b0ab00d7cfa2">www.jasonbock.net</a>
</p>
<blockquote><p>
This book is highly recommended as it contains a whole lot of wisdom and experience from the field of software engineering. It’s only 190 pages, so you should be able to get through very quickly. So, you can’t lose on this one.
</p></blockquote>
<p style="text-align: right">
&mdash; <a href="http://elegantcode.com/2010/08/18/book-review-debug-it/">ElegantCode</a>
</p>
<blockquote><p>
I think that this book should be read by all new software developers as well as all junior or mid-level developers. There’s plenty to be learned by the senior developer types too. Even if you’ve been doing these things for a long time, this is a good read to make sure you’re keeping your feet planted firmly on the ground.
</p></blockquote>
<p style="text-align: right">
&mdash; <a href="http://www.lostechies.com/blogs/chrismissal/archive/2010/05/12/debug-it.aspx">lostechies.com</a>
</p>
<blockquote><p>
With my many years of experience in supporting and debugging large existing enterprise systems, I have to say that Paul Butcher summarize and structure all the knowledge (and more) that I have, sometimes painfully, accumulated during this activity. This is therefore an excellent book that I will recommend to everybody that is involved in software development in general and maintenance activities specifically.
</p></blockquote>
<p style="text-align: right">
&mdash; <a href="http://blog.martinig.ch/books/debug-it/">blog.martinig.ch</a>
</p>
<blockquote><p>
I know that this book influenced the way I work now, and there aren’t many books I could say something like this about.
</p></blockquote>
<p style="text-align: right">
&mdash; <a href="http://devlicio.us/blogs/krzysztof_kozmic/archive/2009/08/30/book-review-debug-it-find-repair-and-prevent-bugs-in-your-code.aspx">devlicio.us</a>
</p>
<blockquote><p>
All in all, there is just a lot of tremendously valuable information in this book.  And it’s only about 190 pages so it definitely won’t take you a long time to read it.  I’ve frequently been amazed at the inability of developers to efficiently debug issues when they occur.  And i’m not just talking about bad developers.  I’ve seen plenty of good or even great developers having trouble with debugging efficiently.  This book would definitely get them on the right track, with just a little bit effort.
</p></blockquote>
<p style="text-align: right">
&mdash; <a href="http://davybrion.com/blog/2010/01/highly-recommended-book-debug-it/">davybrion.com/blog</a>
</p>
<blockquote><p>
Understanding is everything: that is at the heart of Paul Butcher’s comprehensive study of the science and psychology of debugging.
</p></blockquote>
<p style="text-align: right">
&mdash; <a href="http://softtalkblog.wordpress.com/2009/12/22/book-review-debug-it/">softtalkblog.wordpress.com</a>
</p>
<blockquote><p>
The book does a great (and truly pragmatic) job of covering all these aspects and addressing a wide range of topics related to debugging software.
</p></blockquote>
<p style="text-align: right">
&mdash; <a href="http://hamagudi.com/2010/03/05/debug-it/">hamagudi.com</a>
</p>
<blockquote><p>
If you are too busy to read this delightful book in its entirety, then at least read the final chapter whilst mandating that your entire development team read “Debug It!” from cover to cover.
</p></blockquote>
<p style="text-align: right">
&mdash; <a href="http://javablog.co.uk/2009/12/13/book-review-debug-it/">javablog.co.uk</a>
</p>
<blockquote><p>
As usual, the publisher has an excellent book on a practical subject that answers oractical qustions on debugging.
</p></blockquote>
<p style="text-align: right">
&mdash; <a href="http://matt.eifelle.com/2010/03/23/book-review-debug-it-find-repair-and-prevent-bugs-in-your-code/">matt.eifelle.com</a>
</p>
<blockquote><p>
I would highly recommend Debug It! to any junior-level programmer who’s interested in developing a more disciplined approach to debugging. If you’re not a junior-level programmer but still feel like you waste a lot of time debugging, you will probably find this book helpful as well. It’s like having a mentor sitting there with you, teaching you how to take your debugging game to the next level.
</p></blockquote>
<p style="text-align: right">
&mdash; <a href="http://lylejohnson.name/blog/2009/12/23/book-review-debug-it/">lylejohnson.name</a>
</p>
<blockquote><p>
It&#8217;s really good seeing these ideas in words because it&#8217;s quite easy to forget about the best way to approach problems in the heat of the moment and the approaches suggested by Paul certainly aren&#8217;t done everywhere in my experience.
</p></blockquote>
<p style="text-align: right">
&mdash; <a href="http://www.markhneedham.com/blog/2009/12/24/debug-it-book-review/">www.markhneedham.com</a>
</p>
<blockquote><p>
While I was familiar with many of the practices discussed in the book … I learned quite a few new things.
</p></blockquote>
<p style="text-align: right">
&mdash; <a href="http://starglider.blogspot.com/2009/12/debug-it.html">starglider.blogspot.com</a>
</p>
<blockquote><p>
 It does a great job of setting the scene for debugging and getting you into the right mind set, while also talking about the complications that can arise once the bug is found and squashed. It&#8217;s almost worth looking at for the anecdotes alone, to understand the lengths that you sometimes have to go to when trying to understand some truly bizarre defects.
</p></blockquote>
<p style="text-align: right">
&mdash; <a href="http://blog.jonmdickinson.com/2009/07/book-review-debug-it.html">blog.jonmdickinson.com</a>
</p>
<blockquote><p>
This is a recommended read for anyone who works closely in the software industry, be it a developer, a tester or even a product manager.
</p></blockquote>
<p style="text-align: right">
&mdash; <a href="http://vidhujoshua.blogspot.com/2009/07/debug-it-book-on-software-debugging.html">vidhujoshua.blogspot.com</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.paulbutcher.com/2010/02/debug-it-review-roundup/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Debug It! in Brazil</title>
		<link>http://www.paulbutcher.com/2009/12/debug-it-in-brazil/</link>
		<comments>http://www.paulbutcher.com/2009/12/debug-it-in-brazil/#comments</comments>
		<pubDate>Thu, 03 Dec 2009 14:26:08 +0000</pubDate>
		<dc:creator>paul</dc:creator>
				<category><![CDATA[Software Engineering]]></category>

		<guid isPermaLink="false">http://www.paulbutcher.com/?p=707</guid>
		<description><![CDATA[
Debug It! is making its way around the world, as this review by Luiz Marques in Brazil demonstrates.
Luiz is kind enough to say:

While I was familiar with many of the practices discussed in the book &#8230; I learned quite a few new things.

He goes on to say:

Well worth the time, specially as it is not [...]]]></description>
			<content:encoded><![CDATA[<div style="padding-left: 1em; margin: 0px; float: right"><a href="http://pragprog.com/titles/pbdp/debug-it"><img src="http://paulbutcher.com/wp-content/uploads/2009/06/debugit.jpg" alt="Debug It!" style="border: 1px black solid; height: 80px" /></a></div>
<p>Debug It! is making its way around the world, as this <a href="http://starglider.blogspot.com/2009/12/debug-it.html">review</a> by Luiz Marques in Brazil demonstrates.</p>
<p>Luiz is kind enough to say:</p>
<blockquote><p>
While I was familiar with many of the practices discussed in the book &#8230; I learned quite a few new things.
</p></blockquote>
<p>He goes on to say:</p>
<blockquote><p>
Well worth the time, specially as it is not very long.
</p></blockquote>
<p>Many thanks, Luiz.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.paulbutcher.com/2009/12/debug-it-in-brazil/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Forgive and Remember</title>
		<link>http://www.paulbutcher.com/2009/12/forgive-and-remember/</link>
		<comments>http://www.paulbutcher.com/2009/12/forgive-and-remember/#comments</comments>
		<pubDate>Wed, 02 Dec 2009 17:30:03 +0000</pubDate>
		<dc:creator>paul</dc:creator>
				<category><![CDATA[Software Engineering]]></category>

		<guid isPermaLink="false">http://www.paulbutcher.com/?p=704</guid>
		<description><![CDATA[You&#8217;re recovering from a major operation—which nursing unit do you choose? One that reports an error once every 500 patient days, or one that reports an error once every 50 days?
What if I were to tell you that in the first unit, which on the face of things makes 10 times fewer mistakes, nurses don’t [...]]]></description>
			<content:encoded><![CDATA[<p>You&#8217;re recovering from a major operation—which nursing unit do you choose? One that reports an error once every 500 patient days, or one that reports an error once every 50 days?</p>
<p>What if I were to tell you that in the first unit, which on the face of things makes 10 times fewer mistakes, nurses don’t report errors because they’re concerned that &#8220;heads will roll.&#8221; Would that change how you feel? How many errors are being swept under the carpet? Do you think that they’re likely to be learning from their mistakes or repeating them over and over again? (This example comes from Hard Facts, Dangerous Half-Truths &#038; Total Nonsense by Jeffrey Pfeffer and Robert I. Sutton, Harvard Business School Press, ISBN: 1-59139-862-2.)</p>
<p>In software, we have our own name for mistakes—we call them bugs. And every bug is an opportunity to learn.</p>
<p>To read the rest of this article, take a look at Issue 6 of <a href="http://www.pragprog.com/magazines">PragPub magazine</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.paulbutcher.com/2009/12/forgive-and-remember/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
