<?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>Mirko Stocker&#039;s Blog &#187; Scala</title>
	<atom:link href="http://misto.ch/tag/scala/feed/" rel="self" type="application/rss+xml" />
	<link>http://misto.ch</link>
	<description></description>
	<lastBuildDate>Mon, 19 Sep 2011 14:11:25 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Organizing Imports in Scala</title>
		<link>http://misto.ch/organizing-imports-in-scala/</link>
		<comments>http://misto.ch/organizing-imports-in-scala/#comments</comments>
		<pubDate>Wed, 29 Jun 2011 09:27:55 +0000</pubDate>
		<dc:creator>Mirko Stocker</dc:creator>
				<category><![CDATA[InfoQ]]></category>
		<category><![CDATA[Scala]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Refactoring]]></category>

		<guid isPermaLink="false">http://misto.ch/?p=273</guid>
		<description><![CDATA[Organize Imports was a very often requested feature for the Scala IDE for Eclipse, so I wrote the first very limited version as part of my thesis. It couldn&#8217;t do much more than sorting the imports and collapsing them from multiple import statements to a single one. At the beginning of this year, Daniel Ratiu [...]]]></description>
			<content:encoded><![CDATA[<p>Organize Imports was a very often requested feature for the Scala IDE for Eclipse, so I wrote the first very limited version as part of my thesis. It couldn&#8217;t do much more than sorting the imports and collapsing them from multiple import statements to a single one. At the beginning of this year, Daniel Ratiu provided a patch that made Organize Imports recognize some of the unused imports.</p>
<p>One limitation we still had was that we didn&#8217;t really know the complete set of required imports, but this is required to, for example, replace all wildcard imports with the actually used ones. Another request was that it should be possible to push import statements down to the scope where they are used. For this, we also need to know which parts of the code require which imports.</p>
<p>Yet another motivation to write some code to analyze dependencies was that I want to provide a move refactoring, and for this too we need to know some of the dependencies in the code. But that&#8217;s for a future post, back to what we have now:</p>
<p><a href="http://misto.ch/wp-content/organize-imports-configuration.png"><img class="alignnone size-full wp-image-276" title="organize-imports-configuration" src="http://misto.ch/wp-content/organize-imports-configuration.png" alt="" width="552" height="421" /></a></p>
<p>As you can see, just like the JDT, we can now configure grouping for imports (groups are separated by a blank line), and it&#8217;s possible to expand or collapse imports from the same package. The Scalaz or Lift users will likely want to always use wildcard imports on some packages and types, so this is also possible. The JDT has some additional options, but I think I implemented the important ones.</p>
<p>And there&#8217;s more! No, <a href="http://www.youtube.com/watch?v=tGvHNNOLnCk">not Reversi</a>, but if there are missing imports in the file, Organize Imports will add them for you:</p>
<p><a href="http://misto.ch/wp-content/organize-imports-missing.png"><img class="alignnone size-full wp-image-277" title="organize-imports-missing" src="http://misto.ch/wp-content/organize-imports-missing.png" alt="" width="468" height="321" /></a></p>
<p>This all is part of the<a href="http://www.scala-ide.org/2011/06/scala-ide-beta-6-available/"> latest beta release of the Scala IDE</a>, so please give it a try and <a href="http://scala-ide.assembla.com/">open a ticket</a> if you find a problem.</p>
<div class="plus-one-wrap"><g:plusone href="http://misto.ch/organizing-imports-in-scala/"></g:plusone></div>]]></content:encoded>
			<wfw:commentRss>http://misto.ch/organizing-imports-in-scala/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Eliminating Pattern Matching</title>
		<link>http://misto.ch/eliminating-pattern-matching/</link>
		<comments>http://misto.ch/eliminating-pattern-matching/#comments</comments>
		<pubDate>Sun, 06 Mar 2011 16:19:39 +0000</pubDate>
		<dc:creator>Mirko Stocker</dc:creator>
				<category><![CDATA[InfoQ]]></category>
		<category><![CDATA[Scala]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Refactoring]]></category>

		<guid isPermaLink="false">http://misto.ch/?p=248</guid>
		<description><![CDATA[In the last few years, I worked on several Java projects where we transformed and analyzed abstract syntax trees, so when I started learning Scala, pattern-matching quickly became one of my favorite language features. I could never warm up to the visitor pattern, so I was thankful that Scala offered a much more powerful alternative. [...]]]></description>
			<content:encoded><![CDATA[<p>In the last few years, I worked on several Java projects where we transformed and analyzed abstract syntax trees, so when I started learning Scala, pattern-matching quickly became one of my favorite language features. I could never warm up to the visitor pattern, so I was thankful that Scala offered a much more powerful alternative.</p>
<p>What I also liked very much was Scala&#8217;s consistent use of the <tt>Option</tt> type in its standard library. Now, instead of having to read the documentation to find out whether some call could return <tt>null</tt>, the type checker forced me to handle this where necessary. So a lot of my early Scala code looked as follows:</p>
<pre class="brush: scala; title: ; notranslate">
doSomething() match {
  case Some(value) =&gt; Some(doSomethingElse(value))
  case None =&gt; None
}
</pre>
<p>While it&#8217;s still possible to get a NPE in Scala, it just doesn&#8217;t happen with well-written libraries, simply because there&#8217;s no need to ever use <tt>null</tt>.</p>
<p>(By the way, isn&#8217;t it funny that Java forces you to check exceptions but doesn&#8217;t help you with the much more common and annoying <tt>null</tt> problem?)</p>
<p>So yes, in practice, <tt>Options</tt> do save you from NPEs. Does your code also get smaller (because usually, in Scala it will)? Not if you pattern match on <tt>Some</tt>/<tt>None</tt>, all the un-wrapping and lifting is quite verbose.</p>
<p>Nowadays, certainly influenced by all the discussions on monads, I realize that pattern-matching on <tt>Option</tt> is a very primitive  form of abstraction, and instead of the code above I now write:</p>
<pre class="brush: scala; title: ; notranslate">
doSomething() map (value =&gt; doSomethingElse(value))
</pre>
<p>(For those unfamiliar with functional programming, <tt>map</tt> applies the function to the value inside a <tt>Some</tt>, and does nothing when called on a <tt>None</tt>.)</p>
<p>Even better, we can fully automate this refactoring! I&#8217;m currently working on a first version in the scala-refactoring library. So far, I&#8217;ve implemented the refactoring for map, but there are many more we can do, for example:</p>
<ul>
<li>If the <tt>Some</tt> case does not construct a <tt>Some</tt> but calls a function that returns an <tt>Option</tt>, we use <tt>flatMap</tt> instead of <tt>map</tt>.</li>
<li>If the <tt>Some</tt> case evaluates to <tt>Boolean</tt> and the <tt>None</tt> case returns <tt>false</tt>, we can replace it with <tt>exists</tt>. If <tt>Some</tt> returns <tt>true</tt> and <tt>None</tt> returns <tt>false</tt>, we can just replace the whole pattern match with <tt>isDefined</tt>.</li>
<li>When the <tt>None</tt> case is <tt>()</tt>, we can transform to <tt>foreach</tt>.</li>
</ul>
<p>So far we have only looked at <tt>Option</tt>, but there is more: for example, we could also replace pattern-matching on lists and recursion with folds. I&#8217;m sure somebody has already written a paper about such refactorings, but I haven&#8217;t found anything yet.</p>
<p>What do you think about eliminating pattern matching? Do you also prefer mapping to explicit pattern-matching?</p>
<div class="plus-one-wrap"><g:plusone href="http://misto.ch/eliminating-pattern-matching/"></g:plusone></div>]]></content:encoded>
			<wfw:commentRss>http://misto.ch/eliminating-pattern-matching/feed/</wfw:commentRss>
		<slash:comments>18</slash:comments>
		</item>
		<item>
		<title>Plans for 2011</title>
		<link>http://misto.ch/plans-for-2011/</link>
		<comments>http://misto.ch/plans-for-2011/#comments</comments>
		<pubDate>Sat, 01 Jan 2011 18:00:02 +0000</pubDate>
		<dc:creator>Mirko Stocker</dc:creator>
				<category><![CDATA[InfoQ]]></category>
		<category><![CDATA[Scala]]></category>
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://misto.ch/?p=236</guid>
		<description><![CDATA[I originally wanted to write a review of 2010 here, but by now I definitely missed the deadline for year-end-retrospectives, so I&#8217;m going to make this about my plans for 2011. I&#8217;ve spent a large portion of last year on the Scala Refactoring project, and I&#8217;m quite happy with the results: four editors/IDEs are using [...]]]></description>
			<content:encoded><![CDATA[<p>I originally wanted to write a review of 2010 here, but by now I definitely missed the deadline for year-end-retrospectives, so I&#8217;m going to make this about my plans for 2011.</p>
<p>I&#8217;ve spent a large portion of last year on the <a href="http://scala-refactoring.org">Scala Refactoring</a> project, and I&#8217;m quite happy with the results: four editors/IDEs are using the library to do refactoring, plus others use parts of it to manipulate or generate Scala source code.</p>
<p>It&#8217;s clear that I cannot continue investing as much time into it as during my master thesis (except of course, if someone would be willing to sponsor me <img src='http://misto.ch/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' />  ). My plan for this year is to find at least half a day per week to continue writing new refactorings and improving the existing code. One idea I originally had with the refactoring library hasn&#8217;t played out yet: getting others to create new refactorings. It&#8217;s really <a href="https://www.assembla.com/code/scala-refactoring/git/nodes/org.scala-refactoring.library/src/main/scala/scala/tools/refactoring/implementations?rev=57a6bbb87e8680d64e554611837ab8bbc35fd07c">not that hard</a>! So give it a try if you have an idea for a refactoring you want to automate.</p>
<p>Besides working on the refactoring library, I also really want to get back to writing for InfoQ. Speaking of InfoQ, I&#8217;m looking forward to <a href="http://qconlondon.com/">QCon London in March</a>!</p>
<p>Now, enough with the blogging &ndash; there are some bugs in Organize Imports I need to fix <img src='http://misto.ch/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />  A happy new year to all of you!</p>
<div class="plus-one-wrap"><g:plusone href="http://misto.ch/plans-for-2011/"></g:plusone></div>]]></content:encoded>
			<wfw:commentRss>http://misto.ch/plans-for-2011/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Scala IDE at Eclipse Summit Europe 2010</title>
		<link>http://misto.ch/eclipse-summit-europe-2010/</link>
		<comments>http://misto.ch/eclipse-summit-europe-2010/#comments</comments>
		<pubDate>Fri, 29 Oct 2010 16:28:17 +0000</pubDate>
		<dc:creator>Mirko Stocker</dc:creator>
				<category><![CDATA[InfoQ]]></category>
		<category><![CDATA[Scala]]></category>
		<category><![CDATA[eclipse]]></category>
		<category><![CDATA[talk]]></category>

		<guid isPermaLink="false">http://misto.ch/?p=223</guid>
		<description><![CDATA[It seems to be customary to announce his Eclipse Summit talk in blogs, so here&#8217;s mine: My talk will of course be on the Scala IDE for Eclipse: This talk introduces the Scala IDE for Eclipse, the obvious choice for all Eclipse users who want to write Scala code. We are going to both take [...]]]></description>
			<content:encoded><![CDATA[<p>It seems to be customary to announce his Eclipse Summit talk in blogs, so here&#8217;s mine:</p>
<p><a href="http://www.eclipsecon.org/summiteurope2010/sessions/?page=sessions&#038;id=1777"><img src="http://misto.ch/wp-content/speaking-ese.gif"/></a></p>
<p>My talk will of course be on the <a href="http://www.eclipsecon.org/summiteurope2010/sessions/?page=sessions&#038;id=1777">Scala IDE for Eclipse</a>:</p>
<blockquote><p>This talk introduces the Scala IDE for Eclipse, the obvious choice for all Eclipse users who want to write Scala code. We are going to both take a look at the features the IDE currently provides as well as a glance under the hood.</p></blockquote>
<p>So if you&#8217;re at ESE and want to know more about the Scala IDE for Eclipse, <a href="http://www.eclipsecon.org/summiteurope2010/table/?page=table&#038;date=2010-11-04">visit me on Thursday</a>, just before lunch.</p>
<div class="plus-one-wrap"><g:plusone href="http://misto.ch/eclipse-summit-europe-2010/"></g:plusone></div>]]></content:encoded>
			<wfw:commentRss>http://misto.ch/eclipse-summit-europe-2010/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Scala Refactoring Thesis Finished</title>
		<link>http://misto.ch/scala-refactoring-thesis-finished/</link>
		<comments>http://misto.ch/scala-refactoring-thesis-finished/#comments</comments>
		<pubDate>Fri, 16 Jul 2010 15:01:45 +0000</pubDate>
		<dc:creator>Mirko Stocker</dc:creator>
				<category><![CDATA[InfoQ]]></category>
		<category><![CDATA[Scala]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Refactoring]]></category>

		<guid isPermaLink="false">http://misto.ch/?p=181</guid>
		<description><![CDATA[I&#8217;m done! A few minutes ago, I handed in my thesis on Scala Refactoring. The project also has a new home at scala-refactoring.org, where you can find more about the refactorings I implemented, how they can be used, etc. I also recommend reading my report, but if you just want an overview, take a look [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m done! A few minutes ago, I handed in my thesis on Scala Refactoring.</p>
<p>The project also has a new home at <a href="http://scala-refactoring.org">scala-refactoring.org</a>, where you can find more about the refactorings I implemented, how they can be used, etc. I also recommend reading <a href="http://scala-refactoring.org/wp-content/uploads/scala-refactoring.pdf">my report</a>, but if you just want an overview, take a look at the poster:</p>
<p><a href="http://misto.ch/wp-content/poster.png"><img class="alignnone size-medium wp-image-182" title="poster" src="http://misto.ch/wp-content/poster-300x212.png" alt="" width="300" height="212" /></a></p>
<p>The next steps for me now are to go on holidays, so please excuse if I don&#8217;t respond for a week.</p>
<div class="plus-one-wrap"><g:plusone href="http://misto.ch/scala-refactoring-thesis-finished/"></g:plusone></div>]]></content:encoded>
			<wfw:commentRss>http://misto.ch/scala-refactoring-thesis-finished/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Scala Refactoring Talk at Scala Days 2010</title>
		<link>http://misto.ch/scala-refactoring-talk-at-scala-days-2010/</link>
		<comments>http://misto.ch/scala-refactoring-talk-at-scala-days-2010/#comments</comments>
		<pubDate>Mon, 03 May 2010 15:30:04 +0000</pubDate>
		<dc:creator>Mirko Stocker</dc:creator>
				<category><![CDATA[InfoQ]]></category>
		<category><![CDATA[Scala]]></category>

		<guid isPermaLink="false">http://misto.ch/?p=156</guid>
		<description><![CDATA[My talk at Scala Days 2010 is now available online: And don&#8217;t forget to take a look at the other talks.]]></description>
			<content:encoded><![CDATA[<p>My talk at Scala Days 2010 is now available online:</p>
<p><a href="http://days2010.scala-lang.org/node/138/141" target="_new"><img src="http://misto.ch/wp-content/scala_refactoring_talk_screenshot.png" alt="" title="scala_refactoring_talk_screenshot" width="580"  class="alignnone size-full wp-image-157" /></a></p>
<p>And don&#8217;t forget to take a look at <a href="http://days2010.scala-lang.org/node/136">the other talks</a>.</p>
<div class="plus-one-wrap"><g:plusone href="http://misto.ch/scala-refactoring-talk-at-scala-days-2010/"></g:plusone></div>]]></content:encoded>
			<wfw:commentRss>http://misto.ch/scala-refactoring-talk-at-scala-days-2010/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Building Eclipse Plug-ins Written in Scala with Maven/Tycho</title>
		<link>http://misto.ch/eclipse-plugins-scala-maventycho/</link>
		<comments>http://misto.ch/eclipse-plugins-scala-maventycho/#comments</comments>
		<pubDate>Sat, 10 Apr 2010 15:40:04 +0000</pubDate>
		<dc:creator>Mirko Stocker</dc:creator>
				<category><![CDATA[InfoQ]]></category>
		<category><![CDATA[Scala]]></category>
		<category><![CDATA[eclipse]]></category>
		<category><![CDATA[maven]]></category>

		<guid isPermaLink="false">http://misto.ch/?p=140</guid>
		<description><![CDATA[The Scala Refactoring project currently uses a rather crude hand-written ant build file; it compiles and runs tests. What it doesn&#8217;t do is creating a proper OSGi bundle, which I need if I want to do proper releases and integrate it into the Scala Eclipse IDE. Most of my colleagues are using PDE build, but [...]]]></description>
			<content:encoded><![CDATA[<p>The Scala Refactoring project currently uses a rather crude hand-written ant build file; it compiles and runs tests. What it doesn&#8217;t do is creating a proper OSGi bundle, which I need if I want to do proper releases and integrate it into the Scala Eclipse IDE. Most of my colleagues are using PDE build, but from what I&#8217;ve heard, <a href="http://www.eclipse.org/buckminster/">Buckminster</a> or <a href="http://tycho.sonatype.org/">Maven/Tycho</a> are the way to go.</p>
<p>Buchminster looks rather complex to me, so I went with Maven, even though I had no prior experience with it. Now, a few hours later, I have a <em>Hello World</em> plug-in written in Scala and a bunch of poms that build everything I want, even an update site! </p>
<p>Tycho needs Maven 3, which hasn&#8217;t been released yet, so I downloaded the latest <a href="http://maven.apache.org/download.html">alpha build</a> and created an alias that pointed to the mvn binary.</p>
<p>I started with <a href="http://mattiasholmqvist.se/2010/02/building-with-tycho-part-1-osgi-bundles/">Mattias Holmqvist&#8217;s Blog</a> where he explains how to create the initial Maven configuration and an OSGi bundle in Eclipse (I created a Hello World Plug-in Project). Now, we don&#8217;t want to have a Java plug-in but one written in Scala, so I added the Scala Nature to the project and re-wrote the two generated files in Scala.</p>
<p>To add Scala functionality to my pom, I followed the <a href="http://code.google.com/p/esmi/wiki/CreatingScalaMavenProjectsInEclipse">Eclipse Scala Maven Integration wiki</a>. I also had to add the Scala Eclipse Plug-in nightly build update site to my list of repositories so Maven could resolve the <em>scala.library</em> dependency the project has. </p>
<pre class="brush: xml; title: ; notranslate">    &lt;repository&gt;
       &lt;id&gt;scala eclipse nightly&lt;/id&gt;
       &lt;layout&gt;p2&lt;/layout&gt;
       &lt;url&gt;http://www.scala-lang.org/scala-eclipse-plugin-nightly&lt;/url&gt;
    &lt;/repository&gt;
</pre>
<p>Because I apparently didn&#8217;t follow Maven&#8217;s source layout, I had to explicitly specify the source directory via:
<pre class="brush: xml; title: ; notranslate">&lt;sourceDirectory&gt;${basedir}/src&lt;/sourceDirectory&gt;</pre>
<p>Adding the update site and feature projects was a peace of cake when following <a href="http://tycho.sonatype.org/how-to-create-a-new-osgi-bundle.html">this tutorial</a> (scroll to <em>Creating an Update Site / P2 repository</em>) from the Tycho project.</p>
<p>I&#8217;ve put the whole project on <a href="http://github.com/misto/Scala-Hello-World-Plug-in">GitHub</a> so you can try it yourself. And remember, this is my first day with Maven, so if I could make the poms even smaller or more idiomatic, please tell me. Or even better, just fork my code!</p>
<p>Next I&#8217;m going to find out how to run unit tests and how the integration in Hudson works, and then I can migrate the Scala Refactoring project and delete a build.xml file.</p>
<div class="plus-one-wrap"><g:plusone href="http://misto.ch/eclipse-plugins-scala-maventycho/"></g:plusone></div>]]></content:encoded>
			<wfw:commentRss>http://misto.ch/eclipse-plugins-scala-maventycho/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>DIY Refactoring for Scala</title>
		<link>http://misto.ch/diy-refactoring-for-scala/</link>
		<comments>http://misto.ch/diy-refactoring-for-scala/#comments</comments>
		<pubDate>Fri, 02 Apr 2010 15:52:16 +0000</pubDate>
		<dc:creator>Mirko Stocker</dc:creator>
				<category><![CDATA[InfoQ]]></category>
		<category><![CDATA[Scala]]></category>
		<category><![CDATA[Refactoring]]></category>

		<guid isPermaLink="false">http://misto.ch/?p=133</guid>
		<description><![CDATA[Excuse my long absence from blogging, but I have a good excuse: I&#8217;ve been hard at work on my Scala Refactoring project. Today, I&#8217;m going to show you how you can implement your very own automated refactoring for Scala. &#8220;Implement a refactoring you say? But I don&#8217;t use IDE xy!&#8221;. Don&#8217;t worry, you won&#8217;t have [...]]]></description>
			<content:encoded><![CDATA[<p>Excuse my long absence from blogging, but I have a good excuse: I&#8217;ve been hard at work on my Scala Refactoring project.</p>
<p>Today, I&#8217;m going to show you how you can implement your very own automated refactoring for Scala. &#8220;Implement a refactoring you say? But I don&#8217;t use IDE xy!&#8221;. Don&#8217;t worry, you won&#8217;t have to use a specific IDE, in fact, you don&#8217;t need to use an IDE at all.</p>
<p>Why should you want to write a refactoring? IDEs usually provide a bunch of general refactorings and code generators, but maybe you need a framework or project specific one that no IDE will implement for you. And don&#8217;t worry, it is not as complicated as it might sound. (And I should add that when I write refactoring, this includes all program transformations that affect the source code, so you could also create a transformation that just creates new code.)</p>
<p>A refactoring is essentially a transformation of the program in its tree form. Unfortunately, our programs are stored in plain text files, so the transformed tree has to be converted back to text, and this without losing all our pretty formatting. One of the design goals of the Scala Refactoring library was to separate these two concerns as good as possible, so that the implementor (you!) of a refactoring can concentrate on transforming trees and let the library do all the ugly code generation for him. To make it easier for those who already know the Scala compiler&#8217;s abstract syntax tree, the refactorings are completely based on this AST instead of introducing a new program representation. I can&#8217;t introduce Scala&#8217;s AST in detail here, but there&#8217;s an <a href="http://scala.ifs.hsr.ch/doc/scalarefactoring-term.pdf">introduction in my term project&#8217;s technical report</a> which I also plan to expand in my master&#8217;s thesis (please give me feedback if you notice any errors).</p>
<p><strong>Please continue reading</strong> the rest <a href="http://scala.ifs.hsr.ch/wiki/DoItYourselfRefactoring#TheExample">of the post on my project wiki</a> (where the layout is much more suited for source code).</p>
<div class="plus-one-wrap"><g:plusone href="http://misto.ch/diy-refactoring-for-scala/"></g:plusone></div>]]></content:encoded>
			<wfw:commentRss>http://misto.ch/diy-refactoring-for-scala/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Scala Refactoring Term Project Finished</title>
		<link>http://misto.ch/scala-refactoring-term-project-finished/</link>
		<comments>http://misto.ch/scala-refactoring-term-project-finished/#comments</comments>
		<pubDate>Fri, 22 Jan 2010 14:58:49 +0000</pubDate>
		<dc:creator>Mirko Stocker</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Refactoring]]></category>
		<category><![CDATA[Scala]]></category>

		<guid isPermaLink="false">http://misto.ch/?p=112</guid>
		<description><![CDATA[Today, after 15 weeks of hard work, I was finally able to hand in my Refactoring for Scala term project (its website is scala.ifs.hsr.ch, where you can also find the technical report). After a short break of four weeks, I will continue the project as my master&#8217;s thesis. What has been achieved so far? After [...]]]></description>
			<content:encoded><![CDATA[<p>Today, after 15 weeks of hard work, I was finally able to hand in my <a href="/scala-refactoring-term-project/">Refactoring for Scala</a> term project (its website is <a href="http://scala.ifs.hsr.ch/">scala.ifs.hsr.ch</a>, where you can also find the <a href="http://scala.ifs.hsr.ch/doc/scalarefactoring-term.pdf">technical report</a>). After a short break of four weeks, I will continue the project as my master&#8217;s thesis. </p>
<p>What has been achieved so far? After investigating the Scala compiler (nothing is more fun than learning a new language by reading it compiler&#8217;s source code, trust me), I started to create with a foundation to build the refactorings on. Refactorings basically just transform an AST, which has to be converted back to plain text afterwards (which is far more complicated than it sounds, trust me). This occupied me for the larger part of the project, and it still isn&#8217;t finished, but I was able to come up with a scheme that allowed me to leave it in an unfinished state and still being able to perform refactorings, at least good enough for a proof-of-concept. </p>
<p>The implemented refactoring is Extract Method; a perfect candidate because it is not too simple (with regards to the code transformatioms) and it looks much more impressive than e.g. Rename. Is it already usable? I&#8217;m not sure, it has not been tested with a lot of real world code (and usually when I did, it didn&#8217;t take me long to find new bugs, or rather things that were not yet implemented), but that will certainly be done in the near future. Another hurdle to using it is that you would need to install my modified Eclipse Scala plug-in (and I haven&#8217;t yet been able to create a working nightly-build including the Eclipse plug-in and all my stuff that would be needed).</p>
<p>For the near future, i.e. before the thesis, the plan is to implement <em>organize imports</em>, so I can bribe Miles Sabin into including the refactoring library in the Eclipse Scala IDE. After that, I&#8217;ll continue the project with a 20 week full-time thesis (~800 hours of work), where I hope to stabilize the existing Extract Method, advance the library so it can be used by other developers without knowing the inner workings of it, and to provide many new refactorings!</p>
<p>In the mean time, I highly appreciate any feedback. And keep an eye on this blog or <a href="http://twitter.com/m_st">follow me on twitter</a> to hear the latest about the project. </p>
<div class="plus-one-wrap"><g:plusone href="http://misto.ch/scala-refactoring-term-project-finished/"></g:plusone></div>]]></content:encoded>
			<wfw:commentRss>http://misto.ch/scala-refactoring-term-project-finished/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>Extract Method for Scala</title>
		<link>http://misto.ch/extract-method-for-scala/</link>
		<comments>http://misto.ch/extract-method-for-scala/#comments</comments>
		<pubDate>Sun, 20 Dec 2009 12:55:32 +0000</pubDate>
		<dc:creator>Mirko Stocker</dc:creator>
				<category><![CDATA[InfoQ]]></category>
		<category><![CDATA[Scala]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Refactoring]]></category>

		<guid isPermaLink="false">http://misto.ch/?p=100</guid>
		<description><![CDATA[I haven&#8217;t blogged in quite a while now. Actually, the last entry was to announce my term project on Scala Refactoring. My excuse is, I was hard at work! So without further ado: Select the line with the assignment to b, murmur the incantation press some keys, et voilà: It also works with multiple return [...]]]></description>
			<content:encoded><![CDATA[<p>I haven&#8217;t blogged in quite a while now. Actually, the last entry was to announce my <a href="http://misto.ch/scala-refactoring-term-project/">term project</a> on Scala Refactoring. My excuse is, I was hard at work! So without further ado:</p>
<pre class="brush: scala; title: ; notranslate">class Demo1 {
  def demo1(i: Int): Int = {
    val a = i
    val b = a + i
    b
  }
}</pre>
<p>Select the line with the assignment to b, <del datetime="2009-12-20T12:55:39+00:00">murmur the incantation</del> press some keys, et voilà:</p>
<pre class="brush: scala; title: ; notranslate">class Demo1 {
  def newMethod(i: Int, a: Int): Int = {
    val b = a + i
    b
  }
  def demo1(i: Int): Int = {
    val a = i
    val b = newMethod(i, a)
    b
  }
}</pre>
<p>It also works with multiple return values and when passing functions. Now, the code isn&#8217;t ready yet, and I have to concentrate on writing my report right now, so it might take a couple more weeks until I can ship something.</p>
<div class="plus-one-wrap"><g:plusone href="http://misto.ch/extract-method-for-scala/"></g:plusone></div>]]></content:encoded>
			<wfw:commentRss>http://misto.ch/extract-method-for-scala/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
	</channel>
</rss>

