<?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>wuetender-junger-mann.de &#187; Uncategorized</title>
	<atom:link href="http://wuetender-junger-mann.de/wordpress/category/uncategorized/feed/" rel="self" type="application/rss+xml" />
	<link>http://wuetender-junger-mann.de/wordpress</link>
	<description>Der Freiheit eine Gasse</description>
	<lastBuildDate>Tue, 08 May 2012 11:59:17 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Scala Compiler Quirks</title>
		<link>http://wuetender-junger-mann.de/wordpress/2011/09/scala-compiler-quirks/</link>
		<comments>http://wuetender-junger-mann.de/wordpress/2011/09/scala-compiler-quirks/#comments</comments>
		<pubDate>Sun, 04 Sep 2011 12:41:37 +0000</pubDate>
		<dc:creator>felix</dc:creator>
				<category><![CDATA[Scala]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://wuetender-junger-mann.de/wordpress/?p=1184</guid>
		<description><![CDATA[Recently I have been dabbling with scala a bit. As it happens I found a few quirks in the compiler. So does the following bit of code compiler and, if so, what does it print? object Example &#123; val x = y val y = true &#160; def main&#40;args: Array&#91;String&#93;&#41; &#123; print&#40;x&#41;; &#125; &#125; Yes [...]]]></description>
			<content:encoded><![CDATA[<p>
Recently I have been dabbling with scala a bit. As it happens I found a few quirks in the compiler.
</p>
<p>
So does the following bit of code compiler and, if so, what does it print?
</p>

<div class="wp_syntax"><div class="code"><pre class="scala" style="font-family:monospace;"><span style="color: #0000ff; font-weight: bold;">object</span> Example <span style="color: #F78811;">&#123;</span>
    <span style="color: #0000ff; font-weight: bold;">val</span> x <span style="color: #000080;">=</span> y
    <span style="color: #0000ff; font-weight: bold;">val</span> y <span style="color: #000080;">=</span> <span style="color: #0000ff; font-weight: bold;">true</span>
&nbsp;
    <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>
        print<span style="color: #F78811;">&#40;</span>x<span style="color: #F78811;">&#41;</span><span style="color: #000080;">;</span>
    <span style="color: #F78811;">&#125;</span>
<span style="color: #F78811;">&#125;</span></pre></div></div>

<p>Yes you&#8217;ll get <code>false</code> and that is plain wrong. In my opinion a compiler error would have been fine and ideally, as there are no cycles it would have just printed <code>true</code>.</p>
<p>Another major selling point of scala is it&#8217;s pattern matching mechanism. A very convenient feature is the compiler&#8217;s ability to print a warning, if the cases provided are not exhaustive. A very simple case of such a non-exhaustive match is this:</p>

<div class="wp_syntax"><div class="code"><pre class="scala" style="font-family:monospace;"><span style="color: #0000ff; font-weight: bold;">object</span> CaseExample <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> b <span style="color: #000080;">=</span> args.<span style="color: #000000;">length</span> <span style="color: #000080;">==</span> <span style="color: #F78811;">1</span>
          b <span style="color: #0000ff; font-weight: bold;">match</span> <span style="color: #F78811;">&#123;</span>
              <span style="color: #0000ff; font-weight: bold;">case</span> <span style="color: #0000ff; font-weight: bold;">true</span> <span style="color: #000080;">=&gt;</span> print<span style="color: #F78811;">&#40;</span><span style="color: #6666FF;">&quot;True&quot;</span><span style="color: #F78811;">&#41;</span>
          <span style="color: #F78811;">&#125;</span>
&nbsp;
      <span style="color: #F78811;">&#125;</span>
  <span style="color: #F78811;">&#125;</span></pre></div></div>

<p>
Unfortunately the compiler doesn&#8217;t complain at all. After some googling I came across <a href="https://issues.scala-lang.org/browse/SI-3111">SI-3111</a>. My own problem was slighty, but only slightly more complicated. I matched tupels of <code>Options</code> against <code>Some</code> and <code>None</code>.
</p>
<p>
We have been bitten by both problems, that lead to really subtle bugs. This is really unfortunate, because the compiler can do a lot more in a language like scala. The first problem gets even caught by javac.
</p>
<p>A third shortcoming of scala can be easily fixed. Set the tab size to <strong>four</strong> spaces and your code will<br />
look a lot more structured.</p>
<p>
To me it seems like the scala compiler unnessarily discredits the idea of strong static checks by a somehwat quirky implementation.</p>
]]></content:encoded>
			<wfw:commentRss>http://wuetender-junger-mann.de/wordpress/2011/09/scala-compiler-quirks/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Jour Fixe Zubehör</title>
		<link>http://wuetender-junger-mann.de/wordpress/2010/04/jour-fixe-zubehor/</link>
		<comments>http://wuetender-junger-mann.de/wordpress/2010/04/jour-fixe-zubehor/#comments</comments>
		<pubDate>Sat, 10 Apr 2010 20:41:07 +0000</pubDate>
		<dc:creator>felix</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://wuetender-junger-mann.de/wordpress/?p=968</guid>
		<description><![CDATA[Bin schon vor längerem über dieses Design gestolpert. Leider scheint es nicht produziert zu werden.]]></description>
			<content:encoded><![CDATA[<p>Bin schon vor längerem über dieses <a href="http://www.iglanddesign.com/pub/iglanddesign/main/?aid=33#iglanddesign">Design</a> gestolpert. Leider scheint es nicht produziert zu werden.</p>
]]></content:encoded>
			<wfw:commentRss>http://wuetender-junger-mann.de/wordpress/2010/04/jour-fixe-zubehor/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Working Effectively with Legacy Code</title>
		<link>http://wuetender-junger-mann.de/wordpress/2010/01/working-effectively-with-legacy-code/</link>
		<comments>http://wuetender-junger-mann.de/wordpress/2010/01/working-effectively-with-legacy-code/#comments</comments>
		<pubDate>Sat, 16 Jan 2010 22:44:24 +0000</pubDate>
		<dc:creator>felix</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://wuetender-junger-mann.de/wordpress/?p=940</guid>
		<description><![CDATA[I have just finished reading Michael Feathers&#8217; Working Effectively with Legacy Code. The book gives a lot of very concrete examples of how to improve code and make it testable. To my tastes he is exaggerating the whole code without test is legacy code thing, which in the naïve reader might lead to the impression [...]]]></description>
			<content:encoded><![CDATA[<p>I have just finished reading Michael Feathers&#8217; <em>Working Effectively with Legacy Code</em>. The book gives a lot of very concrete examples of how to improve code and make it testable. To my tastes he is exaggerating the whole code without test is legacy code thing, which in the naïve reader might lead to the impression that a test is all it needs for code to be good.
</p>
<p>
As I am going to sell my copy at favourable rate to one of my colleagues, I&#8217;ll just list a few things I found intersting:
</p>
<ul>
<li>Chapter 15 &#8211; My application is all API calls. He uses a very good example of a mailing list server to illustrate how to get around problems with external API dependencies. He distinguishes to approaches &#8220;Skin and wrap the API&#8221; and &#8220;Responsibility-based extraction&#8221;. I am strongly favouring the second approach as I find it leads to more relevant abstractions and not wrapping for the sake of wrapping&#8230;
</li>
<li>Another theme in the book is <em>understanding code</em>. He mentions a few nice techniques:
<ul>
<li>Effect analysis (dataflow analysis) using pen and paper</li>
<li>Mapping out your way through the code base while reading on a piece of paper</li>
<li>Printing the code and doing listing markup using marker pens.</li>
<li>Scratch refactorings while reading code, that are thrown away and whose sole purpose is helping to understand the codebase and on a similar note delete unused code you find while reading</li>
<li>Telling the story of the system. This is done at several levels starting with a high level description that has a lot of generalisations. This practice helps people to develop a shared vision and also highlights discrepancies between the system and the story.</li>
<li>Naked CRC-Cards &#8211; somewhat poorly named as actually it&#8217;s naked object cards. Use white index cards on a table to represent objects. Tell story as you place and rearrange them.
</ul>
</li>
</ul>
<p>
There is a nice example for separation of concerns (he uses the term SRP, which I don&#8217;t like) on page 247 describing an expression evaluator.
</p>
<p>
Adapt parameter refactoring. If the parameter type is too complicated for stubbing etc, look at the use of the parameter and introduce a wrapper around the original object that just exposes what the current method needs. Example HttpServletRequest gets wrapped in ServlatParameterSource which implements a new ParameterSource interface.
</p>
<p>
On a similar note primitivise parameter. Instead of passing in our wrapping an expensive abstraction just pass in the required &#8220;values&#8221;. This of course very dangerous as it breaks encapsulation. On the other hand it could lead to the extraction of roll based primitive interfaces (a bit like the adapt parameter pattern)</p>
]]></content:encoded>
			<wfw:commentRss>http://wuetender-junger-mann.de/wordpress/2010/01/working-effectively-with-legacy-code/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

