<?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>Jayway Team Blog</title>
	<atom:link href="http://blog.jayway.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.jayway.com</link>
	<description>Sharing Experience</description>
	<lastBuildDate>Wed, 16 May 2012 12:23:10 +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>Lightweight agile test documentation</title>
		<link>http://blog.jayway.com/2012/05/15/lightweight-agile-test-documentation/</link>
		<comments>http://blog.jayway.com/2012/05/15/lightweight-agile-test-documentation/#comments</comments>
		<pubDate>Tue, 15 May 2012 07:38:10 +0000</pubDate>
		<dc:creator>Fjodor Ekström</dc:creator>
				<category><![CDATA[Testing]]></category>
		<category><![CDATA[agile testing]]></category>
		<category><![CDATA[test documentation]]></category>
		<category><![CDATA[testing]]></category>

		<guid isPermaLink="false">http://blog.jayway.com/?p=13660</guid>
		<description><![CDATA[Test documentation has evolved from discussions about test results to rigid documents following strict processes and now we’re going back again. Let’s find out why documentation has become so time consuming, seldom read and what we can do about it. It all started with collaboration Honestly, I am not sure what’s the main reason for [...]]]></description>
			<content:encoded><![CDATA[<p><em>Test documentation has evolved from discussions about test results to rigid documents following strict processes and now we’re going back again. Let’s find out why documentation has become so time consuming, seldom read and what we can do about it.</em></p>
<h2>It all started with collaboration</h2>
<p>Honestly, I am not sure what’s the main reason for writing excessive documentation but I can imagine it has something to do with collaboration. As soon as you start collaborating with people lacking domain knowledge (stakeholders on distance, new team members, third parties etc.) you will find yourself explaining a lot of things, a lot of times.</p>
<h2>The quality receipt</h2>
<p>There has always been projects where the stakeholder wants a quality receipt. So testers started to specify everything. When a project was finished, the stakeholder had evidence in the form of documentation that this project is something and this something works according to the documents. As you see, this proves very little about the actual quality of the project. Nonetheless it was (and still is) regarded as a kind of quality receipt.</p>
<p>The problem with saying test documentation is a receipt is that it isn’t. The only thing test documentation is, is documentation about testing.</p>
<h2>Testing</h2>
<p>Testers will not prove quality because there are no really good metrics for quality in its whole. If you start to think about what quality is and how you measure it you will find that it is subjective and emotionally valued and therefore not measurable by anyone else than yourself and by doing that you will only measure your definition of quality.</p>
<p>This is a problem in other environments than software development as well. So, what can we do as testers? We talk to our stakeholder and use our experience to find out which quality characteristics are more important (this to assure that we spend time testing the right things). Then we decide restrictions in which the system must be kept.</p>
<p>With restrictions defined we can perform and analyze test activities for how well the system meets these restrictions. This way we can get some results and communicate our analysis to the stakeholder.</p>
<h2>A word on releases</h2>
<p>In some companies, the testers are the ones with power to say "go" / "no-go" for a project release. Doing this, the stakeholder will definitely expect a receipt of quality. If any bug shows up it will be the testers responsibility and the stakeholder will be less involved in the project. A loose-loose situation, one could say.</p>
<p>Ideally the product owner should be the one that makes release decisions, based on a recommendation from the development team. There are many business decisions that needs to be taken into account when releasing a system. It’s not all about quality you know!</p>
<p>The testers responsibility is testing things, this involves all surrounding activities (planning, analyzing, reporting/communication etc.). The core responsibility for a tester should be to provide enough data from the tests of the system for the stakeholder to feel confident enough deciding on releasing the system.</p>
<h2>Communication</h2>
<p>Sometimes there is a demand from the stakeholder for extensive documentation. Listen to your stakeholder and see if you can provide the documentation he needs but at the same time pay attention and try to find out the root cause for the need of more documentation.</p>
<p>If you find out the root cause it might be cheaper to fix it than spend unnecessary time writing test documentation. A good start could be to communicate more with your stakeholder. When communicating you will start a relationship and with this relationship the stakeholder starts to feel more relaxed about your questions. This communication also opens a feedback gate which, once opened, will provide you with immense knowledge about what quality criteria is more important to the stakeholder.</p>
<h2>Easier documentation</h2>
<p>So here is my solution to test documentation in Agile projects. I will show you an easy way of documenting what has been tested, when and how.</p>
<p>Enter the matrix:<br />
<a href="https://docs.google.com/spreadsheet/ccc?key=0Av18LcPLkYMvdERKM0JGaXpHdXlZMkRHcjc5TDJaLWc">Testplan</a><br />
<em>This spreadsheet is quite simple. It communicates which test-activities has been performed on which date.</em></p>
<p>Now let’s take a look at another one:<br />
<a href="https://docs.google.com/spreadsheet/ccc?key=0Av18LcPLkYMvdDJMdzB1ek9ubGxVSmZZZVBvNURpRkE">Testmatrix</a><br />
<em>This spreadsheet communicates information on another level. Here we can see which requirements have been tested on which dates and which focus area the tests had.</em></p>
<p>To utilize the full potential of the documents, they have to have the dates synchronized. This way you can always go back and see what happened when. In combination these two documents covers most necessary documentation needs. You can see what has been tested when and how and the level of detail is of course something you can adjust.</p>
<p>The most efficient way according to me, is to let it be dynamic documents, updated after each activity has been performed. This way the information in the documents always matches what actually happened in the sprint and you will be able to analyze the documentation to improve your test planning.</p>
<h2>Summary</h2>
<p>Using these spreadsheets and complementing them with log results, bugs and other required information, you have a basic test report. Finish off the report with some descriptive text regarding the test activities and test results in order to make the report more readable for the stakeholder and there you go. Lightweight agile test documentation with high readability and minimal production time, a way of making test documentation easy in Agile projects.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.jayway.com/2012/05/15/lightweight-agile-test-documentation/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>App Harbor and RavenDB</title>
		<link>http://blog.jayway.com/2012/05/14/app-harbor-and-ravendb/</link>
		<comments>http://blog.jayway.com/2012/05/14/app-harbor-and-ravendb/#comments</comments>
		<pubDate>Mon, 14 May 2012 11:29:29 +0000</pubDate>
		<dc:creator>Gustaf Nilsson Kotte</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[appharbor]]></category>
		<category><![CDATA[ravendb]]></category>

		<guid isPermaLink="false">http://blog.jayway.com/?p=13627</guid>
		<description><![CDATA[Some days ago I had the opportunity to do a spike on making a small application and deploy it in App Harbor. I had never used App Harbor before, but I had used Heroku, which is another "Platform as a Service" (PaaS). Heroku is very easy to get started with and it's easy to deploy [...]]]></description>
			<content:encoded><![CDATA[<p>Some days ago I had the opportunity to do a spike on making a small application and deploy it in App Harbor. I had never used App Harbor before, but I had used Heroku, which is another "Platform as a Service" (PaaS). Heroku is very easy to get started with and it's easy to deploy to (it's using git), so I had some expectations before I started.</p>
<h2>Surprise #1, Add-ins</h2>
<p>I had quite low expectations on what storage alternative that would be available - "a SQL Server service, a key/value store and perhaps a queue" was what I thought. The first thing that surprised me was that App Harbor has as many add-ins as Heroku (I didn't count though) and I could choose between SQL Server, Couch, Mongo, Redis and RavenDB - all free in the most basic setting (i.e. small storage, no backup, etc). I turns out that RavenDB was <a href="http://blog.appharbor.com/2012/02/17/hosted-ravendb-on-appharbor">added to the add-in stack</a> quite recently. Cool.</p>
<p style="text-align: center;"><a href="http://blog.jayway.com/wordpress/wp-content/uploads/2012/05/5778938232_4eeb0f692c_z.jpg" rel="lightbox"><img class="size-medium wp-image-13647 aligncenter" title="Image source: http://www.flickr.com/photos/data_cold/5778938232/" src="http://blog.jayway.com/wordpress/wp-content/uploads/2012/05/5778938232_4eeb0f692c_z-300x200.jpg" alt="" width="300" height="200" /></a></p>
<h2>Surprise #2, Learning RavenDB is easy</h2>
<p>I added the RavenDB add-in to my app with a click and on its configuration page I saw both a link to the Silverlight administration tool and a url to the database. For about a year ago, I wanted to play with RavenDB at home, so I installed it on my personal machine but I couldn't make it work. That is my personal experience with RavenDB, even if many colleuages and people in the community have praised it.</p>
<p>I wanted to drive my learning with small tests and thus created an empty project in Visual Studio. First I had to add RavenDB (client) and NUnit to the project, using NuGet. Then I went back to AppHarbor and clicked the RavenDB admin link, installed Silverlight, and RavenDB then asked me if I wanted it to add some sample data to my database, since it was empty, which I did.</p>
<p>After that I could easily find a "getting started" page with how to insert data into RavenDB, copy/paste that code into a test, replace the URL and run the test. It didn't work...</p>
<p>It turns out that the URL and API key was separated with a semi-colon, which took me 2-3 minutes to figure out. DocumentStore has a property APIKey, so I set the API key there instead of having it in the URL and ran the test again. The test did not crash and a document appeared in the RavenDB admin application - success.</p>
<h2>Move code to controller</h2>
<p>I now had some test code that worked on my local machine that talked to a RavenDB database instance on App Harbor. The next step was to create a new ASP.NET MVC 4 project, move my test code to a controller action (nothing fancy, adding a redirect at the end of the code I already had) and run the proect. I clicked on a link to my controller action and again saw in the RavenDB admin app that a new document had been created, which was what I had expected. Nice.<br />
<a href="http://blog.jayway.com/wordpress/wp-content/uploads/2012/05/raven_saved.png" rel="lightbox"><img class="alignright size-full wp-image-13634" title="raven_saved" src="http://blog.jayway.com/wordpress/wp-content/uploads/2012/05/raven_saved.png" alt="" width="148" height="230" /></a></p>
<h2>Deploy</h2>
<p>Now, I wanted to deploy my working code to App Harbor. Following the <a href="http://support.appharbor.com/kb/getting-started/deploying-your-first-application-using-git">instructions</a>, all I had to do was to add a <a href="https://gist.github.com/825373">.gitignore file</a> to the application's root folder, and run the following commands</p>
<pre class="code">git init
git add .
git commit -m "Initial commit"
git remote add appharbor [my repo url ]
git push appharbor master</pre>
<p>I then opened up my app's admin page in App Harbor, followed the link to my app and it worked just as on my local machine, as I expected.</p>
<p>Finally, I wanted to add some form of query from the database. The simplest kind of query is a Count(), so on the index page I added some code to show that. Now, each time I clicked the link, the counter was incremented with one - I did no longer need to go to the RavenDB admin app to see if a new document had been created.</p>
<p><a href="http://blog.jayway.com/wordpress/wp-content/uploads/2012/05/postcounter1.png" rel="lightbox"><img class="alignright size-medium wp-image-13642" title="postcounter" src="http://blog.jayway.com/wordpress/wp-content/uploads/2012/05/postcounter1-300x118.png" alt="" width="300" height="118" /></a></p>
<h2>Summary</h2>
<p>App Harbor was very easy to get started with. It has many add-ins, including RavenDB. I thought it was easy to start using the RavenDB add-in: I could test the API from my local machine and then move the working code to a web project. Deploying to App Harbor with git is also very easy.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.jayway.com/2012/05/14/app-harbor-and-ravendb/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>HTML5 Server-Sent Events</title>
		<link>http://blog.jayway.com/2012/05/11/html5-server-sent-events/</link>
		<comments>http://blog.jayway.com/2012/05/11/html5-server-sent-events/#comments</comments>
		<pubDate>Fri, 11 May 2012 06:25:49 +0000</pubDate>
		<dc:creator>Gustaf Nilsson Kotte</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[event sourcing]]></category>
		<category><![CDATA[html5]]></category>

		<guid isPermaLink="false">http://blog.jayway.com/?p=13542</guid>
		<description><![CDATA[There's been a lot of talk lately about realtime web and WebSockets, but did you know that there exists an alternative HTML5 technology called EventSource that could handle some of the scenarios as well? EventSource is also called Server-Sent Events (SSE), a name that I prefer to use in order to avoid confusion with the [...]]]></description>
			<content:encoded><![CDATA[<p>There's been a lot of talk lately about realtime web and WebSockets, but did you know that there exists an alternative HTML5 technology called EventSource that could handle some of the scenarios as well? EventSource is also called Server-Sent Events (SSE), a name that I prefer to use in order to avoid confusion with the larger architectural pattern called event sourcing.</p>
<p>The three things you should know about Server-Sent Events are: It's..</p>
<ul>
<li>uni-directional (only server push, initiated by client)</li>
<li>using pure HTTP</li>
<li>not using polling</li>
</ul>
<p>The uni-directional constraint is not a problem, since the client still can GET data from the server or POST messages to the server, using XMLHttpRequest. Instead, let's focus on the other two...</p>
<p><img class="size-medium wp-image-13617 aligncenter" title="lightning_night_texas_1306090_o" src="http://blog.jayway.com/wordpress/wp-content/uploads/2012/05/lightning_night_texas_1306090_o-300x214.jpg" alt="Image source: http://www.flickr.com/photos/davidw/171030064/" width="300" height="214" /></p>
<h2>Pure HTTP</h2>
<p>This feature is golden, because it has a lot of nice implications. First, even if SSE is <a href="http://caniuse.com/eventsource">not supported by all browsers</a>, the fallback is just to start to use polling (<a href="https://github.com/Modernizr/Modernizr/wiki/HTML5-Cross-browser-Polyfills">polyfills for SSE are found here</a>). Second, the integration story for <em>other types of clients than browsers</em> is better than websockets - no need for an websocket implementation on the client to be able to consume the events, just use HTTP. Third, it's not an "all-or-nothing" approach like websockets - you can start with a naive server implementation and gradually improve it. I will explain this last statement in more detail below.</p>
<h2>It's not polling</h2>
<p>Searching the web, it's not a problem to find out how the data format for SSE looks like. I recommend to read the last part of <a href="http://www.w3.org/TR/eventsource/#event-stream-interpretation">section 7 of the specification</a> for more details. However, it's not clear how the connection between the client and the server is working. At first, I thought I just had bad luck in searching the net, but now I realize why there was not a single answer on how to think about the client/server connection. The answer? There is not <em>one</em> right answer, but rather several right answers, depending on your requirements.</p>
<p>First, let's look at a sequence diagram using as much of SSE's promises as possible. (The image is a link to a larger version)</p>
<p><a href="http://blog.jayway.com/wordpress/wp-content/uploads/2012/05/title-SSE-long-lived-connection.png" rel="lightbox"><img class="aligncenter size-medium wp-image-13557" title="SSE, long-lived connection" src="http://blog.jayway.com/wordpress/wp-content/uploads/2012/05/title-SSE-long-lived-connection-257x300.png" alt="" width="257" height="300" /></a></p>
<p>In the diagram, we see that a connection is kept open as long as possible by the client/server pair and when the connection is closed (i.e. by a router, proxy, firewall, etc) the client reconnects to the server. As Damien Edward says on <a href="http://hanselminutes.com/291/damian-edwards-explains-the-realtime-web-for-aspnet-with-signalr">the excellent Hanselminutes episode about realtime web</a> (I'm paraphrasing): SSE is similar to the <a href="http://en.wikipedia.org/wiki/Comet_(programming)">long polling</a> strategy, except that the connection is kept open as long as possible.</p>
<h2>Begin simple</h2>
<p>Keeping a connection opened as long as possible? That doesn't scale! Yes and no. As Damien Edwards mentions in the Hanselminutes episode, in classical usage of ASP.NET this would be a problem, since every connection has a thread in the thread pool. If performance becomes a problem, one can refactor towards an asynchronous model, à la Node.js, which would reduce the memory footprint. But not every developer groks asynchronous design well, so there's cost involved here as well. Of course, it depends a lot on your specific scenario, <a href="http://en.wiktionary.org/wiki/your_mileage_may_vary">YMMV</a>.</p>
<p>But there exists a still simpler solution: instead of keeping the connection open you can close it when you consider yourself done.</p>
<p><a href="http://blog.jayway.com/wordpress/wp-content/uploads/2012/05/title-SSE-short-lived-connection.png" rel="lightbox"><img title="title SSE, short-lived connection" src="http://blog.jayway.com/wordpress/wp-content/uploads/2012/05/title-SSE-short-lived-connection-300x281.png" alt="" width="300" height="281" /></a></p>
<p>"Ahaha, that's polling!" Yep, it is, and it's very simple to implement and understand. And it has some potential problems, of course, but it all depends on what your scenario is. Perhaps it's a sufficient design to use polling, both for user experience and performance?</p>
<p>A cool thing with SSE is that you can perform these refactorings on the server-side without changing the client side. "Upgrading" websockets in a similar way is not possible - either you use a websocket connection or you don't. But then, if you <em>know</em> that [parts of] your web app is going to need "as much realtime as possible" and is expected to be used by many users at the same time, go for websockets.</p>
<p>There's also an interesting possibility to use a more heterogeneous architectural style and use SSE on some parts of the app and websockets on other parts, depending on the scenarios and requirements.</p>
<h2>Summary</h2>
<p>Server-Sent Events is an interesting light-weight and refactoring friendly alternative to websockets and is worth investigating. It has a good 3rd party integration compared to websockets since SSE is using plain HTTP. And SSE is uni-directional, so the client needs to use XMLHttpRequest to communicate client-to-server.</p>
<h2>Resources</h2>
<p>W3C EventSource/Server-Sent Events Specification<br />
<a href="http://www.w3.org/TR/eventsource/">http://www.w3.org/TR/eventsource/</a></p>
<p>When can I use Server-sent DOM events?<br />
<a href="http://caniuse.com/eventsource">http://caniuse.com/eventsource</a></p>
<p>Damian Edwards explains The Realtime Web for ASP.NET with SignalR (audio podcast, recommended)<br />
<a href="http://hanselminutes.com/291/damian-edwards-explains-the-realtime-web-for-aspnet-with-signalr">http://hanselminutes.com/291/damian-edwards-explains-the-realtime-web-for-aspnet-with-signalr</a></p>
<p>Real Time Rack (video presentation, recommended, start from 22:50 for non-Ruby content)<a href="http://confreaks.com/videos/727-rockymtnruby2011-real-time-rack"></p>
<p>http://confreaks.com/videos/727-rockymtnruby2011-real-time-rack</a></p>
<p>HTML5 Rocks: Stream Updates with Server-Sent Events<br />
<a href="http://www.html5rocks.com/en/tutorials/eventsource/basics/">http://www.html5rocks.com/en/tutorials/eventsource/basics/</a></p>
<p>Aslak Hellesøy compares WebSockets and Server-Sent Events and concludes that SSE have a better application-to-application integration story<br />
<a href="https://github.com/aslakhellesoy/webbit-rest/wiki/Chat-Room-Example">https://github.com/aslakhellesoy/webbit-rest/wiki/Chat-Room-Example</a></p>
<p>StackOverflow: WebSockets vs. Server-Sent events/EventSource<br />
<a href="http://stackoverflow.com/questions/5195452/websockets-vs-server-sent-events-eventsource">http://stackoverflow.com/questions/5195452/websockets-vs-server-sent-events-eventsource</a></p>
<p>StackOverflow: What so different about Node.js's event-driven? Can't we do that in ASP.NET's HttpAsyncHandler?<br />
<a href="http://stackoverflow.com/questions/5599024/what-so-different-about-node-jss-event-driven-cant-we-do-that-in-asp-nets-ht">http://stackoverflow.com/questions/5599024/what-so-different-about-node-jss-event-driven-cant-we-do-that-in-asp-nets-ht</a></p>
<p>Jim Webber's opinion about websockets<br />
<a href="https://twitter.com/#!/jimwebber/status/172748058336034816">https://twitter.com/#!/jimwebber/status/172748058336034816</a></p>
<p>InfoQ: WebSockets versus REST<br />
<a href="http://www.infoq.com/news/2012/02/websockets-rest">http://www.infoq.com/news/2012/02/websockets-rest</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.jayway.com/2012/05/11/html5-server-sent-events/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Point-free programming style in F#</title>
		<link>http://blog.jayway.com/2012/05/08/point-free-programming-style-in-f/</link>
		<comments>http://blog.jayway.com/2012/05/08/point-free-programming-style-in-f/#comments</comments>
		<pubDate>Tue, 08 May 2012 07:45:19 +0000</pubDate>
		<dc:creator>Christian Jacobsen</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[f#]]></category>
		<category><![CDATA[functional programming]]></category>
		<category><![CDATA[point-free style]]></category>

		<guid isPermaLink="false">http://blog.jayway.com/?p=13605</guid>
		<description><![CDATA[I gave a short presentation at Functional programming Stockholm user group about point-free programming style in F# which I will write a summary of here. I was reading Tomas Petricek's and Jon Skeet's book Real-World Functional Programming which contains a short section about point-free style. The conclusion was that the code could end up being hard [...]]]></description>
			<content:encoded><![CDATA[<p>I gave a short presentation at <a href="http://groups.google.com/group/functional-programming-sthlm" title="Functional programming Stockholm">Functional programming Stockholm</a> user group about point-free programming style in F# which I will write a summary of here.</p>
<p>I was reading Tomas Petricek's and Jon Skeet's book <a href="http://www.google.se/url?sa=t&amp;rct=j&amp;q=&amp;esrc=s&amp;source=web&amp;cd=1&amp;ved=0CDAQFjAA&amp;url=http%3A%2F%2Fwww.manning.com%2Fpetricek%2F&amp;ei=At6iT9C5HsbEtAbxyNjrDQ&amp;usg=AFQjCNElLA7hoGRQypoNhFOSZfHx1hx_uQ" title="Real-World Functional Programming">Real-World Functional Programming</a> which contains a short section about point-free style. The conclusion was that the code could end up being hard to read. However, I found the examples in the book quite elegant and was intrigued to learn more.</p>
<p>Point-free style originates from a mathematical branch called topology which deals with spaces composed by points (values) and functions between those spaces. A function is said to be point-free if it doesn't mention the points of the space which it operates on. In functional programming this translates to a function that doesn't mention the arguments of its transform. The point (no pun...) is to make the code less verbose and to focus more on behavior of the function than on its data.</p>
<p>In order to accomplish point-free style, functional programming features such as higher-order functions, function composition and partial function application are used. Let's look at some examples:</p>
<pre>
let rec sum list =
   match list with
   | [] -&gt; 0;
   | h::t -&gt; h + sum t
</pre>
<p>This function sums the elements of a list recursively. Since the arguments are bound in a pattern matching expression they can't be taken out so we need to rewrite it using a higher order function like so:</p>
<pre>
let sum list = List.fold (+) 0 list
</pre>
<p>The fold function takes an aggregating function, a seed value and a list as arguments (note that the +-operator is surrounded by parentheses which turns it into a function). The function's type signature is:</p>
<pre>
val sum : int list -&gt; int
</pre>
<p>That is, it's a function taking a list of integers and returning an integer value.<br />
Now, if we remove the list argument we get:</p>
<pre>
let sum = List.fold (+) 0
</pre>
<p>and the type signature:</p>
<pre>
val sum : (int list -&gt; int)
</pre>
<p>The signature is the same but surrounded by parentheses which means that the sum function returns a function instead of a value, i.e. it's a partial function application. Since the signature is the same as previously the usage is the same e.g.</p>
<pre>
let addingNumbersOneToTen = sum [1..10]
</pre>
<p>Here's another example:</p>
<pre>
let add10To list = List.map(fun x -&gt; x + 10) list
</pre>
<p>The map function applies the given function to each element of the passed list. In this case, a lambda function is used for adding 10 to each element. Using a partial function application instead of the lambda we get:</p>
<pre>
let add10To list = List.map((+) 10) list
</pre>
<p>and without the list argument:</p>
<pre>
let add10To = List.map((+) 10)
</pre>
<p>which is completely point-free.</p>
<p>Finally an example of using function composition to obtain point-freedom:</p>
<pre>
let doubleAndIncr = fun x -&gt; x * 2 + 1
</pre>
<p>This function, as the name implies, doubles the given value and increments it with one.<br />
Composing the multiply function and the add function will get rid of the lambda function:</p>
<pre>
let doubleAndIncr x = ((*) 2 &gt;&gt; (+) 1) x
</pre>
<p>and making it a partial function application will loose the x argument:</p>
<pre>
let doubleAndIncr = (*) 2 &gt;&gt; (+) 1
</pre>
<p>I think point-free style can make the code more readable when used wisely. As in the last example above the expression to the right reads almost like natural language "times 2 and then plus 1". Of course, it could get really gory but so can anything else in the world of programming.</p>
<p>Refs.<br />
<a href="http://www.google.se/url?sa=t&amp;rct=j&amp;q=&amp;esrc=s&amp;source=web&amp;cd=1&amp;ved=0CCcQFjAA&amp;url=http%3A%2F%2Fen.wikipedia.org%2Fwiki%2FTacit_programming&amp;ei=kd6iT8CVI4jmtQa30NnTBw&amp;usg=AFQjCNETr1Cj86yPFAsiaxuec_PAkD5tow" title="Tacit programming">Tacit programming</a><br />
<a href="http://www.google.se/url?sa=t&amp;rct=j&amp;q=&amp;esrc=s&amp;source=web&amp;cd=2&amp;ved=0CDYQFjAB&amp;url=http%3A%2F%2Fwww.haskell.org%2Fhaskellwiki%2FPointfree&amp;ei=kd6iT8CVI4jmtQa30NnTBw&amp;usg=AFQjCNGKHTTQRMSgvcvka7ebnaKlaIdTDg" title="HaskellWiki">HaskellWiki</a><br />
<a href="http://www.google.se/url?sa=t&amp;rct=j&amp;q=&amp;esrc=s&amp;source=web&amp;cd=3&amp;ved=0CEMQFjAC&amp;url=http%3A%2F%2Fbuffered.io%2Fposts%2Fpoint-free-style-what-is-it-good-for&amp;ei=kd6iT8CVI4jmtQa30NnTBw&amp;usg=AFQjCNH1c9-fAIT72lxJ1a1TV3H7HvFSFg" title="Point-free style: What is it good for?">Point-free style: What is it good for?</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.jayway.com/2012/05/08/point-free-programming-style-in-f/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Converting to Windows 8 from Windows Phone &#124; Looking back&#8211;what would we do differently (12 of 12)</title>
		<link>http://blog.jayway.com/2012/05/08/porting-to-windows-8-from-windows-phone-looking-backwhat-would-we-do-differently-12-of-12/</link>
		<comments>http://blog.jayway.com/2012/05/08/porting-to-windows-8-from-windows-phone-looking-backwhat-would-we-do-differently-12-of-12/#comments</comments>
		<pubDate>Tue, 08 May 2012 06:30:00 +0000</pubDate>
		<dc:creator>Andreas Hammar</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[windows 8]]></category>
		<category><![CDATA[windows phone]]></category>
		<category><![CDATA[windows phone 7]]></category>
		<category><![CDATA[winrt]]></category>

		<guid isPermaLink="false">http://blog.jayway.com/?p=13497</guid>
		<description><![CDATA[We started with a Windows Phone application and converted it to a Windows 8 equivalent. The end result was far from a clone, neither visually nor in function, but that was never the goal. The goal was to take a real application through the trembling steps of converting into a fully functional prototype on Windows [...]]]></description>
			<content:encoded><![CDATA[<p>We started with a Windows Phone application and converted it to a Windows 8 equivalent. The end result was far from a clone, neither visually nor in function, but that was never the goal. The goal was to take a <em>real </em>application through the trembling steps of converting into a fully functional prototype on Windows 8.</p>
<p>The idea of this last post in the series is to look back and discuss what we had done differently building the Windows Phone app, knowing what we know now.</p>
<p>This post is a part in a series - you can find the full index <a href="http://blog.jayway.com/2012/04/04/converting-to-windows-8-from-windows-phone-introduction-1-of-12/">here</a>.</p>
<h2>Isolate 3rd party libraries</h2>
<p>Yes, we know – there are lots of great frameworks out there. Yes, we know – the wheel should not be reinvented over and over. So, to be clear, we are not against 3rd party libraries on Windows Phone. But before adding that library reference through <a href="http://nuget.org/">nuget</a>, there are a few things to consider.</p>
<ul>
<li>Does it solve a problem in a smarter way than something I would be able to create in matter of hours?</li>
<li>Do I have full control over the impact on performance?</li>
<li>Can I jump to Windows 8 and find the same component or rewrite my code easily?</li>
<li>Can I isolate the component or will it scatter across my code base?</li>
</ul>
<p>We had a couple of 3rd party components in the Reseguiden Windows Phone application. We removed them all when converting to Windows 8. Silverlight Toolkit was easy since it was only used by the views, and they were removed in the conversion as well. We only used a fraction of Caliburn.Micro so that was easily removed and rewritten. The big hit came when all JSON parsing had to be rewritten to replace ServiceStack.Text.</p>
<p>So, the big lesson learned here is, if you are to use 3rd party libraries, make sure they are isolated. It will help when converting to Windows 8, and will surely help in other situations as well.</p>
<h2>Isolate navigation</h2>
<p>Yepp, navigation has changed. From working with Uri’s and query strings to navigate and pass data, Windows 8 instead uses types and objects. </p>
<p>The advantage of the new way of navigating is that you don’t have to deal with a bunch of strings. The drawback is that you have completely rewrite your navigation handling. In other words, if you have spread out the navigation code throughout your code base you have quite a task at hand. Luckily for us, we had all navigation logic in one class. Replacing that class with a Windows 8 version was done in minutes.</p>
<h2>Isolate storage </h2>
<p>(no pun intended <img style="border-bottom-style: none; border-left-style: none; border-top-style: none; border-right-style: none" class="wlEmoticon wlEmoticon-smile" alt="Smile" src="http://blog.jayway.com/wordpress/wp-content/uploads/2012/05/wlEmoticon-smile.png" /> )</p>
<p>Of course there are way to store data locally both on Windows Phone and Windows 8. One difference though is that Windows 8 also has both temporary and roaming storage. Another difference is that also storage has moved from .NET to WinRT.</p>
<p>What we’re leaning towards here is that you win a lot by isolating your storage behind and interface, or at least keep everything in one class. The storage code has to be rewritten anyway when converting to Windows 8, so if it’s tucked away in one single place it won’t interfere with your other code.</p>
<p>We also mentioned the temporary storage in Windows 8 – a cache. Windows Phone does not separate temporary storage from storage. But doing this separation yourself logically in your Windows Phone app, even though it eventually is stored in the same storage, will help you when going to Windows 8.</p>
<h2>MVVM</h2>
<p>To be hones, we cannot say what this conversion would have been like without view models, we haven’t tried it. We haven’t tried converting an app with a lot of code and logic in the xaml.cs code behind files. We also haven’t tried converting where text formatting is done in the view instead of the view model.</p>
<p>We are glad we haven’t.</p>
<p>Will you be able to use your view models right off the bat? Well, since the views in Windows 8 probably will look a bit different that on Windows Phone the view models will not fit perfectly. But as a starting point they are really nice to have. It was quick for us to make the small modifications needed for the view models to fit our Windows 8 views.</p>
<p>To try to share view models completely between Windows Phone and Windows 8 will probably be counterproductive. A view model is there to serve a specific view and serve data in the exact way that view wants it in. Since the views will be different (they should be different) the view models will be different. Hence forcing the use of the same view models will make them unnecessarily complex.</p>
<h2>Localization</h2>
<p>The use of resource files differ between Windows Phone and Windows 8. To make the transition as smooth as possible, we recommend naming your resource keys according to the Windows 8 convention (Uid.Property, e.g. LoginButton.Content) also in your Windows Phone application. If you in addition to this bind to your resources directly in your views, all you have to do in your Windows 8 application is to copy the strings to a new resource file.</p>
<p>So, even if it’s not reusable as-is, also the localization can be transferred pretty smoothly.</p>
<h2>Data bind ApplicationBar</h2>
<p>In Windows Phone there is, as we all know, an application bar. What we also know, to everyone’s frustration, is that you cannot data bind directly to it. You have been limited to three options:</p>
<ol>
<li>Create it in XAML</li>
<li>Create it in code</li>
<li>Write a wrapper and data bind to that</li>
</ol>
<p>Our advice is – write a wrapper. Why?</p>
<p>The application bar in Windows 8 can be data bound against. So if you’ve chosen option number 1 or 2, you all of a sudden have some code to rewrite. (yes, XAML is code too). But if you’ve gone for option 3, you can simply bind your view model to your application bar in Windows 8 instead of Windows Phone and your done.</p>
<h2>Conclusion</h2>
<p>Altogether this conversion took 3 days and honestly speaking, the biggest hurdle was Visual Studio 11 Beta and Resharper Beta. The conversion itself actually was pretty frictionless. Worth mentioning is;</p>
<ul>
<li>We did not do a full conversion – we only chose a subset of the functionality and got that to work</li>
<li>The application we started with is small – only six views in total</li>
</ul>
<p>If we instead had chosen to convert one of the larger apps we’re working on (40+ views) this article series would probably have been a tad bit longer…</p>
<p>The goal has from the beginning been to take a real world application and see what kind of problems we run into. We have run into problems, but nothing that we haven’t been able to solve. We would like to end this series with some thoughts on the future.’</p>
<p>One might speculate… that there is a new version of Windows Phone in the future</p>
<p>One might speculate… that it will build on the same kernel as Windows 8</p>
<p>One might also ponder whether the right way to go is to separate the code bases today and migrate back from Windows 8 to Windows Phone 8 in the future. We think so.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.jayway.com/2012/05/08/porting-to-windows-8-from-windows-phone-looking-backwhat-would-we-do-differently-12-of-12/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Neo4j.rb 2.0 &#8211; An Overview</title>
		<link>http://blog.jayway.com/2012/05/07/neo4j-rb-2-0-an-overview/</link>
		<comments>http://blog.jayway.com/2012/05/07/neo4j-rb-2-0-an-overview/#comments</comments>
		<pubDate>Mon, 07 May 2012 19:59:03 +0000</pubDate>
		<dc:creator>Andreas Ronge</dc:creator>
				<category><![CDATA[Dynamic languages]]></category>

		<guid isPermaLink="false">http://blog.jayway.com/?p=13476</guid>
		<description><![CDATA[On the 14th of May 2008 the first commit was made. Now, four years, 2045 RSpecs and 1480 commits by 31 contributors later Neo4j.rb has reached version 2.0. Here are some of the news: The neo4j gem has been split up into three gems, neo4j-core, neo4j-wrapper and neo4j Lots of refactoring (which probably also means [...]]]></description>
			<content:encoded><![CDATA[<p>On the 14th of May 2008 the first commit was made. Now, four years, 2045 RSpecs and 1480 commits by 31 contributors later Neo4j.rb has reached version 2.0. Here are some of the news: 	</p>
<li>The neo4j gem has been split up into three gems, <a href="https://github.com/andreasronge/neo4j-core" title="neo4j-core" target="_blank">neo4j-core</a>, <a href="https://github.com/andreasronge/neo4j-wrapper" title="neo4j-wrapper" target="_blank">neo4j-wrapper</a> and <a href="https://github.com/andreasronge/neo4j" title="neo4j " target="_blank">neo4j</a></li>
<li>Lots of refactoring (which probably also means better performance)</li>
<li>More consistent API</li>
<li><a href="https://github.com/andreasronge/neo4j/wiki/Neo4j%3A%3ACore-Cypher" title="Cypher DSL" target="_blank">Cypher DSL</a> with  <a href="https://github.com/andreasronge/neo4j/wiki/Neo4j%3A%3AWrapper-Rules-and-Functions" title="Cypher DSL and Rule Intergration" target="_blank">Rule integration</a>. </li>
<p>In this blog I will give you an overview of Neo4j.rb.</p>
<h3>Neo4j.rb - a New Type of Object Database ?</h3>
<p>Graph and object databases (ODBMS) have many similar advantages. They are both good choices for data containing many relationships and composite objects. It's natural to map objects in an object oriented programming language to nodes,properties and relationships in a graph. That means you can use a graph database like it was an object database. For example, instead of using a database schema you can specify the structure of the graph database by using Ruby classes. You can also visualize the graph database in order to understand how your objects are related by simply following relationships between nodes.</p>
<p>Another reason for choosing a graph database is for solving graph related problems like finding critical paths in projects, implementing spatial algorithms or route planning. Some of these problems are impossible to solve using a different type of database. In this blog I will show how the graph database Neo4j can be used to implement a recommendation algorithm as well as using it like an object database for creating complex domain models.</p>
<p>The first question to ask before using Neo4j is which flavour of Neo4j you want - the embedded or the standalone server version ?</p>
<h3>Embedded or Server Neo4j  ?</h3>
<p>There are two different ways of using Neo4j - as a standalone database with a REST protocol or using it as an embedded database with a programmatic API.</p>
<p>Some of the advantages of using it as a standalone database is that it’s possible to use it from any language and multiple clients that can talk REST (for example see the <a href="https://github.com/maxdemarzi/neography" title="neography" target="_blank">neography gem</a>). It is also available on Heroku as an addon. In this blog we are going to use the “unplugged” embedded Neo4j version which only can be used from JRuby.</p>
<p>The advantage of the embedded Neo4j is better performance due to the direct use of the Java API. This means you can write queries in plain Ruby! Another advantage of the embedded Neo4j is that since it’s an embedded database there is one less piece of infrastructure (the database server) to install.  The embedded database is running in the same process as your (Rails) application. Since JRuby has real threads there is no need to start up several instances of the database or of the Ruby runtime since JRuby can utilize all available cores on the CPU. There is actually even no need to start the database at all as it will be started automatically when needed. Notice it’s still possible to use the REST protocol or the web admin interface from an embedded Neo4j, see the <a href="https://github.com/andreasronge/neo4j-admin" title="neo4j-admin" target="_blank">neo4j-admin</a> gem.</p>
<p>So which should I choose ? Well, if you can’t use JRuby or you don’t need an Active Model compliant Neo4j binding then the Neo4j Server is a good choice, otherwise I would suggest using the embedded Neo4j.rb gem (but I’m a bit biased <img src='http://blog.jayway.com/wordpress/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />  )</p>
<h3>Installation of Neo4j.rb</h3>
<p>Before installing Neo4j make sure you have installed JRuby. The easiest way to install JRuby is using <a href="https://rvm.io/interpreters/jruby/" title="RVM" target="_blank">RVM</a>. Neo4j.rb has bin split up into three gems: <a href="https://github.com/andreasronge/neo4j-core" title="neo4j-core" target="_blank">neo4j-core</a>, <a href="https://github.com/andreasronge/neo4j-wrapper" title="neo4j-wrapper" target="_blank">neo4j-wrapper</a> and <a href="https://github.com/andreasronge/neo4j" title="neo4j" target="_blank">neo4j</a>. In this example we are only going to use node, relationships and properties which mean that it's enought to install the neo4j-core gem.<br />
<code><br />
	gem install neo4j-core<br />
</code></p>
<p>You have now installed both the JRuby binding to the Java API and the embedded Neo4j database.</p>
<h3>Node, Properties and Relationships</h3>
<p>The basic building blocks of a graph database are node, properties relationships instead of tables and columns. </p>
<p>Now, open an IRB session and lets create two nodes:</p>
<p> <script src="https://gist.github.com/1565312.js?file=nodes.rb"></script></p>
<p>All modification to the database must be wrapped in transactions. Neo4j supports <a href="http://docs.neo4j.org/chunked/1.7/transactions.html" title="Neo4j Transactions" target="_blank">ACID transactions</a>. Both nodes and relationship can have properties. Neo4j is schema free. That means that you do not predefine types and relationships. You can at any time change a property from one type to a different type. Example of setting properties on a node:</p>
<p> <script src="https://gist.github.com/1565312.js?file=properties.rb"></script></p>
<p>In a graph database, relationships are first class citizens. (By the way, I like this tweet:<br />
<a href="https://twitter.com/#!/andypiper/status/198070561438564353" title="With Neo4j it is the relationships, not the data, that counts" target="_blank">"With neo4j it is the relationships, not the data, that count"</a>). Relationships in Neo4j have a type and a direction. Lets create an outgoing relationship from node alice to node bob of type friends with one property.</p>
<p> <script src="https://gist.github.com/1565312.js?file=relationships.rb"></script></p>
<p>We have now created the following graph:<br />
<a href="http://blog.jayway.com/wordpress/wp-content/uploads/2012/05/two_nodes.png" rel="lightbox"><img src="http://blog.jayway.com/wordpress/wp-content/uploads/2012/05/two_nodes.png" alt="Relationship between two nodes" title="two_nodes" width="355" height="158" class="alignnone size-full wp-image-13503" /></a></p>
<p>To retrieve all outgoing nodes of type friends from node alice of depth one:<br />
<code>alice.outgoing(:friends)</code></p>
<p>To navigate the same relationship type but in the opposite direction:<br />
<code>bob.incoming(:friends)</code></p>
<p>There are many more methods for doing <a href="https://github.com/andreasronge/neo4j/wiki/Neo4j::Core-Traverse" title="Advanced Traversals" target="_blank">advanced traversals</a> of relationships of any depth.</p>
<h3>An Example of a  Recommendation Algorithm</h3>
<p>By using the traversal methods it is easy to solve problems like finding recommendations. Here is a very simple implementation of finding recommendations for twitter users. It compares similarities in tags used in tweets. Let say we have the following users which have tweeted using the tags #neo4j, #jruby and #rails.</p>
<div id="attachment_13508" class="wp-caption alignnone" style="width: 310px"><a href="http://blog.jayway.com/wordpress/wp-content/uploads/2012/05/recommend.png" rel="lightbox"><img src="http://blog.jayway.com/wordpress/wp-content/uploads/2012/05/recommend-300x206.png" alt="Database Model for twitter users" title="recommend" width="300" height="206" class="size-medium wp-image-13508" /></a><p class="wp-caption-text">A Database Model for Twitter Users</p></div>
<p>We now want to recommend Alice a new user to follow, based on similarities in hash tags. Here is a rather naive algorithm. Lets first find all users who have used the same tag as Alice. We do that by traversing outgoing used_tags and incoming used_tags. We stop at depth two and find users Ted, Bob and Carol. Since Alice already follows Ted we exclude him. For all these users we find which tags they have used and compare that with Alice’s tags. Since Alice and Bob both have used tags #neo4j and #rails and Carol and Alice only have #rails in common we then recommend Alice to follow user Bob.</p>
<p> <script src="https://gist.github.com/1564598.js?file=recommend.rb"></script></p>
<p>A complete Rails example using this algorithm can be found <a href="https://github.com/andreasronge/kvitter" title="Kvitter Rails Neo4j Demo Example" target="_blank">here</a>. It’s often both easier and faster to use the declarative <a href="http://docs.neo4j.org/chunked/snapshot/cypher-query-lang.html" title="Cypher Docs" target="_blank">cypher query language</a> -  a SQL-like language for graph matching. </p>
<p>Here is an example of using the new Cypher DSL support in Neo4j.rb 2.0 using the same algorithm.</p>
<p> <script src="https://gist.github.com/1564598.js?file=cypher.rb"></script></p>
<p>You can play around with the generated cypher query <a href="http://tinyurl.com/7zzad7t" title="Neo4j Graph REPL" target="_blank">here</a> using the Neo4j REPL console. Another alternative is using the excellent <a href="https://github.com/pangloss/pacer" title="Pacer Gem" target="_blank">pacer gem</a>.</p>
<h3>Performance Benefits of Neo4j</h3>
<p>Neo4j is optimized for fast traversals of the graph by navigating in and outgoing relationships. The performance of Neo4j will remain the same independently of data size and the depth of traversals. This is a huge advantage over relational database (RDBMS) where the data size and the number of join operations have a strong negative impact on the performance. This is a benefit that both graph databases and object databases share.</p>
<h3>How Neo4j Maps to Ruby?</h3>
<p>In the example above we have shown how easy and efficient it is to use Neo4j to solve graph related problems. The next thing I want to show is how Neo4j.rb maps to the database. Neo4j.rb consists of a three layers API :</p>
<li>Layer 1 (<a href="https://github.com/andreasronge/neo4j-core" title="neo4j-core" target="_blank">neo4j-core</a>) is used for interacting with nodes and relationships using the native Java (!) <a href="http://rdoc.info/github/andreasronge/neo4j-core/Neo4j/Node" title="Neo4j::Node" target="_blank">Neo4j::Node</a> and <a href="http://rdoc.info/github/andreasronge/neo4j-core/Neo4j/Relationship" title="Neo4j::Relationship" target="_blank">Neo4j::Relationship</a> classes.</li>
<li>Layer 2 (<a href="https://github.com/andreasronge/neo4j-core" title="neo4j-wrapper" target="_blank">neo4j-wrapper</a>) enables wrapping the native layer 1 objects using the <a href="http://rdoc.info/github/andreasronge/neo4j-wrapper/Neo4j/NodeMixin" title="Neo4j::Node" target="_blank">Neo4j::NodeMixin</a> and <a href="http://rdoc.info/github/andreasronge/neo4j-wrapper/Neo4j/RelationshipMixin" title="Neo4j::RelationshipMixin" target="_blank">Neo4j::RelationshipMixin</a> modules.</li>
<li>Layer 3 (<a href="https://github.com/andreasronge/neo4j-core" title="neo4j" target="_blank">neo4j</a>) contains an implementation of Rails Active Model and a subset of the Active Record API using the <a href="http://rdoc.info/github/andreasronge/neo4j/Neo4j/Rails/Model" title="Neo4j::Rails::Model" target="_blank">Neo4j::Rails::Model</a> and <a href="http://rdoc.info/github/andreasronge/neo4j/Neo4j/Rails/Relationship" title="Neo4j::Rails::Relationship" target="_blank">Neo4j::Rails::Relationship</a> classes.</li>
<p>Layer 3 creates a transaction automatically. However, if you need better performance you can always access the unwrapped <tt>Neo4j::Node</tt> objects. Another reason to use layer 2 or 3 is to declare properties and relationships. This makes it more convenient as Neo4j.rb will generate accessor methods. Using layer 3 also means it works very well together with Rails 3 and many other Rails gems (see for example <a href="https://github.com/andreasronge/neo4j/wiki/Neo4j%3A%3ARails-Scaffolds-%26-Generators" title="Neo4j-Rails 3 Generators" target="_blank">Rails 3 Scaffolds and Generators</a> or old blog <a href="http://blog.jayway.com/2011/03/02/neo4j-rb-1-0-0-and-rails-3/" title="neo4j-rb-1-0-0-and-rails-3" target="_blank">Neo4j 1.0.0 and Rails 3</a>)</p>
<p>Example:<br />
 <script src="https://gist.github.com/1565312.js?file=mapping.rb"></script></p>
<p>The <tt>p.friends</tt> method is the same as <tt>p.outgoing(:friends)</tt>. Notice that it’s optional to declare types on properties and relationships.</p>
<h3>Example of Domain Modelling</h3>
<p>One of the advantages of an object database over RDBMS is the ability to persist composite objects and relationships. Using RDBMS for complex domains can cause an explosion of smaller tables which will degrade the performance because more tables have to be joined. The next example will show how to persist composite objects and data structures using Neo4j.rb. Lets say we want to create a model for the following domain:</p>
<blockquote><p>
A student can enroll in one or more seminars.<br />
A seminar has students and a waiting list for students.
</p></blockquote>
<p>There are many ways to implement this in Neo4j.rb. I’ve chosen to represent the enrollment as a relationship object. The Enrollment object connects the student node to the seminar node. The waiting list can be represented as a linked list of nodes. Here is an example of what the database would look like:</p>
<div id="attachment_13528" class="wp-caption alignnone" style="width: 610px"><a href="http://blog.jayway.com/wordpress/wp-content/uploads/2012/05/seminar2.png" rel="lightbox"><img src="http://blog.jayway.com/wordpress/wp-content/uploads/2012/05/seminar2.png" alt="Neo4j Database Model - Linked List" title="seminar" width="600" height="110" class="size-full wp-image-13528" /></a><p class="wp-caption-text">Neo4j Database Model</p></div>
<p>In the next code example we will create this database. Notice how easy it is to implement a data structure like a linked list in Neo4j. Implementing varying-sized structures for an RDBMS is often very hard.</p>
<p> <script src="https://gist.github.com/1565312.js?file=seminar.rb"></script></p>
<p>How about querying a data structure like the linked list above? One very interesting approach is to build a search tree of nodes connected to the nodes in the list. Let’s say you want to find nodes in the list based on a time interval. Instead of simply traversing each node in the list (Neo4j can traverse between 1-2 million hops between nodes per second) you do a search using the tree instead.</p>
<div id="attachment_13531" class="wp-caption alignnone" style="width: 546px"><a href="http://blog.jayway.com/wordpress/wp-content/uploads/2012/05/linked_list_tree.png" rel="lightbox"><img src="http://blog.jayway.com/wordpress/wp-content/uploads/2012/05/linked_list_tree.png" alt="Neo4j Database Model linked list and a tree" title="linked_list_tree" width="536" height="405" class="size-full wp-image-13531" /></a><p class="wp-caption-text">Neo4j Database Model - Linked List and a Tree</p></div>
<p>How about finding the seminar with number 6001? One way of doing that is by using the reference node which can always be found (<a href="http://rdoc.info/github/andreasronge/neo4j-core/Neo4j#ref_node-class_method" title="Neo4j.ref_node" target="_blank">Neo4j.ref_node</a>). If you create a relationship between the reference node and the seminar node then you can find it. In fact, Neo4j.rb automatically creates class nodes which are connected to the reference node. All instances of a class are automatically linked to the class node. The <tt>all</tt> method on the Seminar class returns all instances, which can be used like this:</p>
<p><code><br />
  Seminar.all.find{|seminar| seminar.number == 6001}<br />
</code></p>
<p>Another way of finding the seminar node is to use the Lucene search engine which is included in Neo4j. All that is needed is to declare an index, for example:</p>
<p> <script src="https://gist.github.com/1565312.js?file=seminar2.rb"></script></p>
<p>You can then use the the Lucene query syntax or a convenient finder method (similar to the Active Record API), for example:</p>
<p> <script src="https://gist.github.com/1565312.js?file=seminar_query.rb"></script></p>
<h3>Object Database vs. Graph Database</h3>
<p>Does a graph database have the same disadvantages which are often found in object databases?</p>
<li>Schema Changes? - There is a clear but simple separation between the code base and the database model. It is therefore possible to update a class without updating all nodes that represent that class.</li>
<li>Language Dependence? Since Neo4j is running on the JVM it can be accessed from any JVM language. There is also a REST protocol available.</li>
<li>Ad-Hoc Queries? Yes, the cypher query language.</li>
<li>Lack of standard? It’s hard to create a standard for object databases since the object oriented database language has to be part of that standard. The <a href="https://github.com/tinkerpop/blueprints/wiki/" title="TinkerPop BluePrints" target="_blank">Tinkerpop Blueprints</a> is a good example of a minimal common API. This API is also used in the pacer Ruby gem.</li>
<h3>Conclusions</h3>
<p>Are graph databases the right tool for you? In an awful lot of cases - yes. But a RDBMS might be a better choice if you don’t have complex data. A graph database becomes more attractive as the complexity of the data grows. Sometimes you don’t even have a choice if you need to implement things like a recommendation algorithm. I think graph database is a good fit for many different domains and believe it will become more popular as people discover that it’s not just for solving graph related problems or for social networks. There is still a lot more to explore on how best to use a graph database. You are all welcome not only as a user of Neo4j.rb but also as a contributor! Graph databases are the future and <a href="https://github.com/andreasronge/neo4j" title="neo4j.rb " target="_blank">Neo4j.rb</a> is one path to it. </p>
]]></content:encoded>
			<wfw:commentRss>http://blog.jayway.com/2012/05/07/neo4j-rb-2-0-an-overview/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>My time with Jayway</title>
		<link>http://blog.jayway.com/2012/05/07/my-time-with-jayway/</link>
		<comments>http://blog.jayway.com/2012/05/07/my-time-with-jayway/#comments</comments>
		<pubDate>Mon, 07 May 2012 17:47:10 +0000</pubDate>
		<dc:creator>Henrik Andersson</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.jayway.com/?p=13577</guid>
		<description><![CDATA[Finally my third conference as a speaker for Jayway is over. This time I’m sitting at the Pearson International Airport, Toronto, Canada and summarizing my time at Jayway. It all started in the summer of 2006. Back then I lived in Reykavik, Iceland and was going home to visit my mom and dad for a [...]]]></description>
			<content:encoded><![CDATA[<p>Finally my third conference as a speaker for Jayway is over. This time I’m sitting at the Pearson International Airport, Toronto, Canada and summarizing my time at Jayway.<br />
It all started in the summer of 2006. Back then I lived in Reykavik, Iceland and was going home to visit my mom and dad for a couple of weeks. On my way home I stopped for a short interview with Per S and Mats W. They asked me the classic question “where do you see yourself in 5 years?”</p>
<p>My short answer was “I will be at an international conference talking about software testing”. I had my goal all ready clear for me.</p>
<p>When I started at Jayway there were three things that I noticed differentiated Jayway from other companies</p>
<ol>
<li>The competence training</li>
<li>The breakfast seminars</li>
<li>Oredev</li>
</ol>
<p><strong>The Training</strong><br />
In many companies they have small number of training opportunities, you may buy a book or if you are lucky you may go a course or if you are best friend with the boss you may go to a conference abroad.</p>
<p>At Jayway we buy books without any hesitation because that is the least expensive training. During my time with Jayway I have been in serveral courses and conferences. Latest course was the “Certified Scrum Master course”. Jayway thought, who is the best in Scrum?</p>
<p>Jeff Sutherland of course. So we let him come to us for a 3 day course in Scrum so that we become certified scrum masters. That is taking competence training seriously.</p>
<p>In every quater we have C-weekend, C for competence. These weekends start on Friday and ends on Saturday lunch. During these weekends we are testing new frameworks and talking about software craftmannaship etc.</p>
<p>So competence training is equally important for Jayway as it is for me.</p>
<p><strong>Breakfast seminars</strong><br />
During each semester Jayway has several seminars. From testing to development, througout agile leading. Next up coming event are Dependency Injection with Andreas Eriksson</p>
<p><strong>Oredev</strong><br />
Oredev www.oredev.org is a conference founded by Jayway. During the past conferences there has been several gurus speaking there. Dan North, Gojko Adzic, Selena Delesie and James Bach are some of the speakers that has made their voice heard in Oredev conference. .NET, Java, Testing and UX is some of the tracks. This conference is all about software development.</p>
<p><strong>My journey</strong><br />
My five and a half years at Jayway has been great. I have been at serveral conference as a delegate and I have meet several notable persons within testing and programming, like James Bach, Micheal Bolton and I had Jeff Sutherland as my Scrum Master teacher. Eating pizza with Chris Patterson is also cool, as is drinking a couple of pints with Dan North</p>
<p>Competence training, has for me always been and will always be important. I like to learn new things and develop myself as a consultant. Jayway is one of its kind, when it comes to competence training. Next weekend we are going to the archipelagos for a code weekend. That weekend we have a theme, the dragon nest. It is simple, during 48 hours you and your team will come up with a product and you shall sell the idea to some investers. If you are lucky, you may end up coding on your project and someone is paying for it.</p>
<p>I started my carrier as a C++ developer and switch carrier to tester at Jayway. As a rookie within testing I got the best start as possible. I started with a small project for green peace, that had a web service that should be tested. During that project I learned my first exploratory testing and wrote my first Ruby script. I had never been coding Ruby before, but with help from both my boss (that gave me the book about Ruby) and developers from other teams within Jayway, I succeed to create a bank simulator.<br />
After that project that was three month long, I had my first breakfast seminar. The seminar were about Exploratory Testing. From there my carrier started as a speaker. I have been in different types of projects; large projects, waterfall projects and good and bad projects.</p>
<p>So in the fall of 2010 I got the opportunity to participate in an Agile project, I toke that oppertunity. This project were my stepping stone to my dreams; standing on the international stage, talking about the software testing.</p>
<p>In the spring of 2011 I applied for a call for paper to “Agile Development Practices” conference in Orlando, FL, USA, and got accepted. I have never been so happy as when I read the e-mail from the conference.</p>
<p>Later on I got accepted to Belgium Testing Days and now I have been at a test conference in Toronto, Canada.</p>
<p>Later on in May I’ll go to London and in June you can meet me in Krakow, Poland at the Agile &amp; Lean conference. Jayway has given me these opportunities that I never would have had in any other consultant firm.</p>
<p>Where do you see yourself in 5 years?</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.jayway.com/2012/05/07/my-time-with-jayway/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Converting to Windows 8 from Windows Phone &#124; Background agents (11 of 12)</title>
		<link>http://blog.jayway.com/2012/05/04/porting-to-windows-8-from-windows-phone-background-agents-11-of-12/</link>
		<comments>http://blog.jayway.com/2012/05/04/porting-to-windows-8-from-windows-phone-background-agents-11-of-12/#comments</comments>
		<pubDate>Fri, 04 May 2012 06:30:46 +0000</pubDate>
		<dc:creator>Andreas Hammar</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[windows 8]]></category>
		<category><![CDATA[windows phone]]></category>
		<category><![CDATA[windows phone 7]]></category>
		<category><![CDATA[winrt]]></category>

		<guid isPermaLink="false">http://blog.jayway.com/?p=13491</guid>
		<description><![CDATA[The Mango (7.1) update for Windows Phone brought us a lot of goodies including the Scheduled Task Agent. It allowed us to create a feeling of push notifications without actually doing any server push implementation. In the Reseguiden app we use the background agents to do new searches for trips and displaying the top result [...]]]></description>
			<content:encoded><![CDATA[<p>The Mango (7.1) update for Windows Phone brought us a lot of goodies including the Scheduled Task Agent. It allowed us to create a feeling of push notifications without actually doing any server push implementation. In the Reseguiden app we use the background agents to do new searches for trips and displaying the top result in the app tile. Sort of a budget-push.</p>
<p>So, the question is, does the same functionality exist in Windows 8? The answer is yes; same same but different.</p>
<p>This post is a part in a series - you can find the full index <a href="http://blog.jayway.com/2012/04/04/converting-to-windows-8-from-windows-phone-introduction-1-of-12/">here</a>.</p>
<h2>New times, new APIs</h2>
<p>You will recognize the same thinking when looking at background agents for Windows 8 as in Windows Phone. They are declared in the app manifest and kept in a separate project. The big difference is that the control of the background running has been moved from .NET to the Windows Runtime. And since the logic for it has moved the way to call it has changed as well.</p>
<p>So, the plan is to implement a background agent in Windows 8, explain how it works, what we’re doing and how it differs from Windows Phone. Let’s begin.</p>
<h2>Setting up the basics</h2>
<p>First and foremost we need to activate our background process. We chose to create a class BackgroundTask and on that the method Register.</p>
<pre class="brush: csharp;">

public class BackgroundTask
{
     public void Register()
     {
          var builder = new BackgroundTaskBuilder();
          builder.Name = &quot;UpdateLiveTile&quot;;
          builder.TaskEntryPoint = &quot;Peach.Background.UpdateTile&quot;;
          IBackgroundTrigger trigger = new SystemTrigger(SystemTriggerType.InternetAvailable, false);
          builder.SetTrigger(trigger);
          builder.Register();
     }
}
</pre>
<p>Worth noting here:</p>
<ul>
<li>TaskEntryPoint is the full name of the class to be executed. We have not created that class yet. Important is that the class implements IBackgroundTask.</li>
<li>We’re creating a Trigger, in this case a SystemTrigger. As you can see we’re triggering on InternetAvailable. Other available triggers are:</li>
<ul>
<li>TimeTrigger*</li>
<li>PushNotificationTrigger*</li>
<li>ControlChannelTrigger*</li>
<li>MaintenanceTrigger</li>
</ul>
<p>*) requires the app the be visible on the lock screen</p>
<li>You can (but we won’t) register an IBackgroundCondition that can e.g. require the user to be active.</li>
</ul>
<p>We’ll call Register in the OnLaunched method of App.cs.</p>
<p>Now, let’s move on to our app manifest where we have to declare that we are running a background process. We’ll place the following piece of XML inside the Application element.</p>
<pre class="brush: xml;">

&lt;Extensions&gt;
     &lt;Extension 

          Category=&quot;windows.backgroundTasks&quot; 

          Executable=&quot;backgroundTaskHost.exe&quot; 

          EntryPoint=&quot;Peach.Background.UpdateTile&quot;&gt;
          &lt;BackgroundTasks&gt;
               &lt;Task Type=&quot;systemEvent&quot; /&gt;
          &lt;/BackgroundTasks&gt;
     &lt;/Extension&gt;
&lt;/Extensions&gt;
</pre>
<p>Not so much to say about it, this is how it looks.</p>
<h2>Implementing the background process</h2>
<p>In this case we will update the live tile from the background process. Before we get to code, we have to create the project to hold the background process. You just add a new project to the solution, we chose the name Reseguiden.Background.</p>
<p><strong>Now to the important part. </strong>Go to the properties for the project and change Output Type from Class Library to WinMD file. The reason for this is that it’s the Windows Runtime that will execute the code in this project, and WinRT does not understand .NET. Let’s jump to our implementation of IBackgroundTask.</p>
<pre class="brush: csharp;">

public sealed class UpdateTile : IBackgroundTask
{
      void IBackgroundTask.Run(IBackgroundTaskInstance taskInstance)
      {
            XmlDocument tileXml = TileUpdateManager.GetTemplateContent(TileTemplateType.TileSquareText02);
            XmlNodeList tileTextAttributes = tileXml.GetElementsByTagName(&quot;text&quot;);
            foreach (var tileTextAttr in tileTextAttributes)
            {
                  tileTextAttr.InnerText = &quot;Någon text&quot;;
            }
            var tileNotification = new TileNotification(tileXml);
            TileUpdateManager.CreateTileUpdaterForApplication().Update(tileNotification);
      }
}

</pre>
<p>As you can see we create a tile update, nothing magic here. Just regular code that will be executed regardless of if the app is suspended or not. Well a little magic there is; the class must be sealed. </p>
<h2>Putting it all together</h2>
<p>Now to the step that we forgot when implementing this. If the app were to be run now, the WIFI turned off and on again, the tile would not update, and the app would crash without any error messages…</p>
<p><strong>Important part number 2. </strong>Add a reference to your WinMD-project (the one containing the implementation of IBackgroundTask) from your application project. That solves the crash problem.</p>
<p>So, as we brushed on earlier, to test your application you can.</p>
<ol>
<li>Start the app</li>
<li>Put the app in the background (e.g. go to the home screen)</li>
<li>Wait 10-15 seconds (so the app will be suspended)</li>
<li>Disconnect the internet</li>
<li>Reconnect the internet</li>
<li>Look at the tile and watch it update itself</li>
</ol>
<p>Das ist alles!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.jayway.com/2012/05/04/porting-to-windows-8-from-windows-phone-background-agents-11-of-12/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Custom events in WinJS</title>
		<link>http://blog.jayway.com/2012/05/03/custom-events-in-winjs/</link>
		<comments>http://blog.jayway.com/2012/05/03/custom-events-in-winjs/#comments</comments>
		<pubDate>Thu, 03 May 2012 08:33:02 +0000</pubDate>
		<dc:creator>Gustaf Nilsson Kotte</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[html5]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[metro]]></category>
		<category><![CDATA[windows 8]]></category>
		<category><![CDATA[WinJS]]></category>

		<guid isPermaLink="false">http://blog.jayway.com/?p=13402</guid>
		<description><![CDATA[In this post, we'll perform a refactoring that moves some code that controls the AppBar in a Metro application written in HTML5. The code is currently placed in each page in the application and each page searches the DOM for an element with an id 'appbar' and then hides or shows a button in the [...]]]></description>
			<content:encoded><![CDATA[<p>In this post, we'll perform a refactoring that moves some code that controls the AppBar in a Metro application written in HTML5. The code is currently placed in each page in the application and each page searches the DOM for an element with an id 'appbar' and then hides or shows a button in the AppBar, depending on if a "full view" button should be visible or not. But even if we have data in the DOM available as global state, it doesn't mean that we should use it - writing Metro applications in WinJS doesn't change the fact that encapsulation is still an important property of the design of your application!</p>
<p style="text-align: center;"><img class="size-medium wp-image-13450 aligncenter" title="paper-star-tinker-679566-o" src="http://blog.jayway.com/wordpress/wp-content/uploads/2012/05/paper-star-tinker-679566-o-300x203.jpg" alt="Image source: http://www.flickr.com/photos/124330160/2127121118/" width="300" height="203" /></p>
<p>First, the code to the finished example is found here: <a href="https://github.com/gustafnk/FeedReaderTechDays2012">https://github.com/gustafnk/FeedReaderTechDays2012</a>. Some of the old code is still commented out, in order for you to see what changes were made. (Next time I'll create the git repo much earlier, tracking the changes made.)</p>
<p>In our example, we have a page, default.html, which creates a div which is an AppBar control, so it should also be responsible for turning on and off a button in the bar. But this is not the current case, instead all the other JavaScript files controls the AppBar, in the following style:</p>
<pre class="brush: javascript; ruler: true; auto-links: false; smart-tabs: false; gutter: false;">// Display the app bar but hide the Full View button
var appbar = document.getElementById('appbar');
var appbarCtrl = appbar.winControl;
appbarCtrl.hideCommands(["view"], false);</pre>
<p>My goal with this example is to try to take as small steps as possible in the beginning of the refactoring and then, when I get confidence, try to take bigger steps.We first do a little research and see that itemsPage.js and detailsPage.js contains the code above that hides the app bar button named "Full view". The file splitPage.js is the only place which shows the button.</p>
<h2>Feedback through the console</h2>
<p>First, let's test if we can receive an event and act on it. An event is something that has happened, so we use "past tense" for the name. Also, the name of the event is chosen from the perspective of the source of the event. From this, we choose the name of the event to be "fullViewPossibleChanged" and expect it to contain a boolean as an event argument. To test the eventing support in WinJS, we run the application and type the following in the JavaScript console</p>
<pre class="brush: javascript; ruler: true; auto-links: false; smart-tabs: false; gutter: false;">WinJS.Application.addEventListener("fullViewPossibleChanged", function (e) { console.log("Hello Jayway"); });</pre>
<pre class="brush: javascript; ruler: true; auto-links: false; smart-tabs: false; gutter: false;">WinJS.Application.queueEvent({type: "fullViewPossibleChanged"})</pre>
<p>and the callback fires, which prints "Hello Jayway" in the console. First feedback cycle is complete.</p>
<h2>Refactoring, moving "hide"</h2>
<div id="attachment_13444" class="wp-caption aligncenter" style="width: 282px"><a href="http://blog.jayway.com/wordpress/wp-content/uploads/2012/05/InteractiveMode.png" rel="lightbox"><img class="size-full wp-image-13444 " title="InteractiveMode" src="http://blog.jayway.com/wordpress/wp-content/uploads/2012/05/InteractiveMode.png" alt="" width="272" height="145" /></a><p class="wp-caption-text">Blend&#39;s Interactive Mode is your friend</p></div>
<p>We would like to open Blend and run the app in "Interactive mode", which would give us rapid feedback on the code changes, but currently <a href="http://download.microsoft.com/download/3/8/E/38E95D6C-BF2C-4D4A-B4A9-87C1D6111704/Visual%20Studio%2011%20Beta%20Readme_enu.htm">Blend does not support the "right click brings up the app bar" feature out-of-the-box</a> (issue 1.3.3.31). I had some issues getting the proposed fix to work and it seems very unstable at the moment. At the moment, we need to hit F5 in VS everytime we want feedback, but hopefully the bug is changed in future versions of Blend so that we can get feedback "for free". So, in the rest of the post, when I write run/reload, imagine that you just can stay in the Interactive Mode in Blend and see your changes live.</p>
<p>In itemsPage.js, we comment out the following lines and run/reload the app again.</p>
<pre class="brush: javascript; ruler: true; auto-links: false; smart-tabs: false; gutter: false;">//var appbar = document.getElementById('appbar');
//var appbarCtrl = appbar.winControl;
//appbarCtrl.hideCommands(["view"], false);</pre>
<p>The app bar now shows the button, as expected.</p>
<p>We then copy the event registration to default.js and replace the log call with the code for hiding the button.</p>
<pre class="brush: javascript; ruler: true; auto-links: false; smart-tabs: false; gutter: false;">WinJS.Application.addEventListener("fullViewPossibleChanged", function (e) {
  var appbar = document.getElementById('appbar');
  var appbarCtrl = appbar.winControl;
  appbarCtrl.hideCommands(["view"], false);
});</pre>
<p>After that, we add the line for queueing the event in itemsPage.js</p>
<pre class="brush: javascript; ruler: true; auto-links: false; smart-tabs: false; gutter: false;">//var appbar = document.getElementById('appbar');
//var appbarCtrl = appbar.winControl;
//appbarCtrl.hideCommands(["view"], false);
WinJS.Application.queueEvent({ type: "fullViewPossibleChanged"})</pre>
<p>When we run/reload the app again, the button is no longer visible. Success!</p>
<p>One place left to refactor to move all the "hide" logic: detailsPage.js. We do exactly the same thing, comment out the code hiding the button, run/reload the app and see that button is there, add the code for queueing the event, run/reload the app again and see that the button is no longer there when navigating to detailsPage.html.</p>
<h2>Refactoring, moving "show"</h2>
<p>At this point, I'm getting more confidence that my mental model matches the reality, which means that I can start to make bigger steps. I add another temporary event handler in default.js,</p>
<pre class="brush: javascript; ruler: true; auto-links: false; smart-tabs: false; gutter: false;">WinJS.Application.addEventListener("fullViewPossibleChangedTmp", function (e) {
  var appbar = document.getElementById('appbar');
  var appbarCtrl = appbar.winControl;
  appbarCtrl.showCommands(["view"], false); // changed this from hideCommands to showCommands
});</pre>
<p>And I comment out the following code in splitPage.js and add the line that queues the event</p>
<pre class="brush: javascript; ruler: true; auto-links: false; smart-tabs: false; gutter: false;">//var appbar = document.getElementById('appbar');
//var appbarCtrl = appbar.winControl;
//appbarCtrl.showCommands(["view"], false);
WinJS.Application.queueEvent({ type: "fullViewPossibleChangedTmp"})</pre>
<p>Then I run/reload the app and sees that button is still being shown in splitPage.html.</p>
<h2>Refactoring, joining the event handlers</h2>
<p>We want to join the two event handlers to one event handler, which match the design decision we did in the beginning that we would send a boolean as event argument. Being very confident now, we remove the temporary event handler and change the original one to</p>
<pre class="brush: javascript; ruler: true; auto-links: false; smart-tabs: false; gutter: false;">WinJS.Application.addEventListener("fullViewPossibleChanged", function (e) {
  var appbar = document.getElementById('appbar');
  var appbarCtrl = appbar.winControl;

  if (e.isFullViewPossible)
    appbarCtrl.showCommands(["view"], false);
  else
    appbarCtrl.hideCommands(["view"], false);
});</pre>
<p>We then adds the argument "isFullViewPossible" to all three call sites - splitPage.js sends true and the other two sends false. We run/reload the app and see that it works as we expected.</p>
<h2>Refactoring, cleaning up</h2>
<p>Before we can consider our selves as done, we remove the out commented code. In default.js, we replace WinJS.Application with the variable name "app", which was already is scope. Then we run/reload the app again, no changes.</p>
<h2>Summary</h2>
<p>There are a couple of thing that we notice here. First, we did an early design decision that the event should have a boolean sent with it, but we didn't need to use the boolean until we joined the two event handlers. In retrospect, I'm not very happy with that strategy - I should have chosen either to use the boolean argument directly in the "hide" refactoring <em>or</em> I should have ignored my "boolean idea" and used two separate events with good names and then joined them in a later refactoring.</p>
<p>I could also have written the two event handlers directly in default.js and using the console to test that they worked, thus creating a "stepping stone" that I could use from the other JavaScript files. Right now, that seems to have been the shortest path to done.</p>
<p>Another thing to notice is that I need to build and deploy the app every time I need feedback of a code change, since I couldn't use Blend for this refactoring, for reasons stated early in this post. Using automatic tests (unit tests) is of course another option for getting feedback, but AFAIK <a href="http://social.msdn.microsoft.com/Forums/pl-PL/vstest/thread/c452f61d-ff69-43d3-ac05-a54cd8829f2c">it's still not known how to write and run tests against Metro apps written in HTML5</a>. Hopefully there will be a better unittest story for Metro apps written in HTML5 in the near future.</p>
<p>And there are still things to refactor regarding  the appbar logic, i.e. the event listener on the button itself is set by splitPage.js, which is also breaking the encapsulation. Thus, we should in some way move parts of the logic to default.js.</p>
<h2>Resources</h2>
<p>GitHub repo with the finished example: <a href="https://github.com/gustafnk/FeedReaderTechDays2012">https://github.com/gustafnk/FeedReaderTechDays2012</a><a href="http://pragprog.com/magazines/2009-09/responsive-design"><br />
</a>Lots of resources on how to develop Metro apps with HTML5:  <a href="http://blog.jayway.com/2012/04/27/windows-8-for-web-developers-techdays-2012-debriefing/">http://blog.jayway.com/2012/04/27/windows-8-for-web-developers-techdays-2012-debriefing/</a><a href="http://pragprog.com/magazines/2009-09/responsive-design"><br />
</a>API reference for WinJS.Application: <a href="http://msdn.microsoft.com/en-us/library/windows/apps/br229774.aspx">http://msdn.microsoft.com/en-us/library/windows/apps/br229774.aspx<br />
</a>Responsive Design: <a href="http://pragprog.com/magazines/2009-09/responsive-design">http://pragprog.com/magazines/2009-09/responsive-design</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.jayway.com/2012/05/03/custom-events-in-winjs/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Converting to Windows 8 from Windows Phone &#124; Live tiles (10 of 12)</title>
		<link>http://blog.jayway.com/2012/04/30/converting-to-windows-8-from-windows-phone-live-tiles-10-of-12/</link>
		<comments>http://blog.jayway.com/2012/04/30/converting-to-windows-8-from-windows-phone-live-tiles-10-of-12/#comments</comments>
		<pubDate>Mon, 30 Apr 2012 06:30:47 +0000</pubDate>
		<dc:creator>Peter von Lochow</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[metro]]></category>
		<category><![CDATA[windows 8]]></category>
		<category><![CDATA[windows phone]]></category>
		<category><![CDATA[windows phone 7]]></category>
		<category><![CDATA[xaml]]></category>

		<guid isPermaLink="false">http://blog.jayway.com/?p=13124</guid>
		<description><![CDATA[Live tiles was introduced with Windows Phone. Compared to an icon, which only used to start an application, a live tile is more like a window into your application. A window where you can present up to date information even if your application is not running. Live tiles in one of the strengths of Windows [...]]]></description>
			<content:encoded><![CDATA[<p>Live tiles was introduced with Windows Phone. Compared to an icon, which only used to start an application, a live tile is more like a window into your application. A window where you can present up to date information even if your application is not running. Live tiles in one of the strengths of Windows Phone and it has, of course, been transferred to Windows 8.</p>
<p>But there are differences between live tiles in Windows Phone and Windows 8. With a Windows Phone you had greater limitations in display size and performance. In this post we’ll start with a short overview how live tiles work and then continue with an introduction to live tiles in Windows 8.</p>
<p>This post is a part in a series - you can find the full index <a title="Converting to Windows 8 from Windows Phone | Introduction (1 of 12)" href="http://blog.jayway.com/2012/04/04/converting-to-windows-8-from-windows-phone-introduction-1-of-12/">here</a>.</p>
<h2>Live tiles –Windows Phone</h2>
<p>With Windows Phone you can create both primary and secondary tiles. </p>
<p><a href="http://blog.jayway.com/wordpress/wp-content/uploads/2012/04/tiles.png" rel="lightbox"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto; padding-top: 0px" title="tiles" border="0" alt="tiles" src="http://blog.jayway.com/wordpress/wp-content/uploads/2012/04/tiles_thumb.png" width="437" height="220" /></a></p>
<p>The code for creating these tiles looks (more or less) the same, this example shows how to update the primary tile.</p>
<pre class="brush: csharp; ruler: true; auto-links: false; smart-tabs: false;">var tile = new StandardTileData
{
     Title = &quot;Sista-minuten&quot;,
     BackgroundImage = new Uri(&quot;/Assets/tile.png&quot;, UriKind.Relative),
     Count = 2,
     BackTitle = &quot;Back Title&quot;,
     BackBackgroundImage = new Uri(&quot;/Assets/tile_back.png&quot;, UriKind.Relative),
     BackContent = &quot;Back Content&quot;
};</pre>
<p>You notice that:</p>
<ol>
<li>We send in a picture to the front and back </li>
<li>We send in a title to the front and back </li>
<li>We send in a text to the back </li>
<li>We can set a count to get a number in the top right corner of the front side </li>
</ol>
<p>But we can't do much else. Well – you can play around and generate images runtime in order to fit more data in. The code to accomplish this is usually messy and hard to change. </p>
<h2>Live Tiles – Windows 8</h2>
<p>It is a little different for Windows 8. To start with you got two different form factors for tiles – square and rectangular. Which version displayed is totally up to the user.</p>
<ul>
<li><strong>Square</strong><br />
These tiles (regarding form factor) reminds us a lot of the tiles that we are used to from Windows Phone. Just could speculate that you have the same limitations as well – this is not the case. More information coming up!</li>
<li><strong>Rectangular</strong><br />
Rectangular tiles are bigger and bigger tiles gives us more space for information. So you can look at a rectangular tile as a panoramic window to your application where you can show even more information. As earlier mentioned, it is the user that controls if the rectangular or square tile should be visible. Square is default, so you must always include a square tile as well.</li>
</ul>
<p><a href="http://blog.jayway.com/wordpress/wp-content/uploads/2012/04/tile-windows-8.png" rel="lightbox"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="tile windows 8" border="0" alt="tile windows 8" src="http://blog.jayway.com/wordpress/wp-content/uploads/2012/04/tile-windows-8_thumb.png" width="651" height="342" /></a></p>
<p>Besides the different sizes, Microsoft has also addressed the problem with developers having to hack together an image runtime in order to display information. When updating a Windows 8 tile you simply use one of the <a href="http://msdn.microsoft.com/en-us/library/windows/apps/xaml/windows.ui.notifications.tiletemplatetype.aspx">44 templates</a> that are available. So take for example the code below.</p>
<pre class="brush: csharp; ruler: true; auto-links: false; smart-tabs: false;">XmlDocument tileXml = TileUpdateManager.GetTemplateContent(TileTemplateType.TileSquareText02);
XmlNodeList tileTextAttributes = tileXml.GetElementsByTagName(&quot;text&quot;);

foreach (var tileText in tileTextAttributes)
{
    tileText.InnerText = &quot;Some text&quot;;
}

var tileNotification = new TileNotification(tileXml);
TileUpdateManager.CreateTileUpdaterForApplication().Update(tileNotification); </pre>
<p>It will generate a tile with a title and smaller text below. In our case it will say “Some text” in both of them. </p>
<p>Yes – no more hacking together images in order to get a richer tile with more information.<br />
  <br />No – the code you have for your Windows Phone tile today cannot be reused and needs to be rewritten.</p>
<h2>There’s more</h2>
<p>In addition to the new templates there is one more new thing worth mentioning – the notification queue. We can, quite simply, activate a cycling between the five last updates. So all that we do is basically to just keep on updating the live tile and then Windows 8 will take care of cycling the updates.</p>
<p>This means that we don't have to constantly update our tile in order to give an impression that the application is alive. We can just add new updates whenever we feel like it and the hand over the responsibility to Windows to make it look alive. The code to activate this functionality...</p>
<pre class="brush: csharp; ruler: true; auto-links: false; smart-tabs: false;">TileUpdateManager.CreateTileUpdaterForApplication().EnableNotificationQueue(true);</pre>
<p>...is not very complex.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.jayway.com/2012/04/30/converting-to-windows-8-from-windows-phone-live-tiles-10-of-12/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Windows 8 for Web Developers, TechDays 2012 Debriefing</title>
		<link>http://blog.jayway.com/2012/04/27/windows-8-for-web-developers-techdays-2012-debriefing/</link>
		<comments>http://blog.jayway.com/2012/04/27/windows-8-for-web-developers-techdays-2012-debriefing/#comments</comments>
		<pubDate>Fri, 27 Apr 2012 07:14:41 +0000</pubDate>
		<dc:creator>Gustaf Nilsson Kotte</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[html5]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[metro]]></category>
		<category><![CDATA[windows 8]]></category>
		<category><![CDATA[WinJS]]></category>

		<guid isPermaLink="false">http://blog.jayway.com/?p=13294</guid>
		<description><![CDATA[Yesterday we had the pleasure to present at TechDays 2012, with a session named "Windows 8 for Web Developers". The topic of the presentation was how to develop Win8 Metro applications using HTML5, JavaScript and CSS3. Thanks to all of you that attended the session - we hope you enjoyed it as much as we [...]]]></description>
			<content:encoded><![CDATA[<p>Yesterday we had the pleasure to present at TechDays 2012, with a session named "Windows 8 for Web Developers". The topic of the presentation was how to develop Win8 Metro applications using HTML5, JavaScript and CSS3. Thanks to all of you that attended the session - we hope you enjoyed it as much as we did! <img src='http://blog.jayway.com/wordpress/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Below, you find the slides and also the links to many of the resources that we used when working on the presentation material. You find the code for the final demo here:</p>
<p><a href="https://github.com/gustafnk/FeedReaderTechDays2012">https://github.com/gustafnk/FeedReaderTechDays2012</a></p>
<div id="__ss_12712177" style="width: 425px;"><strong style="display: block; margin: 12px 0 4px;"><a title="Windows 8 for Web Developers" href="http://www.slideshare.net/GustafKotte/windows-8-for-web-developers">Windows 8 for Web Developers</a></strong><object id="__sse12712177" width="425" height="355" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowFullScreen" value="true" /><param name="allowScriptAccess" value="always" /><param name="wmode" value="transparent" /><param name="src" value="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=metrohtml5bitsandpiecessafe-120427020341-phpapp02&amp;stripped_title=windows-8-for-web-developers&amp;userName=GustafKotte" /><param name="allowscriptaccess" value="always" /><param name="allowfullscreen" value="true" /><embed id="__sse12712177" width="425" height="355" type="application/x-shockwave-flash" src="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=metrohtml5bitsandpiecessafe-120427020341-phpapp02&amp;stripped_title=windows-8-for-web-developers&amp;userName=GustafKotte" allowFullScreen="true" allowScriptAccess="always" wmode="transparent" allowscriptaccess="always" allowfullscreen="true" /></object></p>
<div style="padding: 5px 0 12px;">View more <a href="http://www.slideshare.net/">presentations</a> from <a href="http://www.slideshare.net/GustafKotte">Gustaf Nilsson Kotte</a>.</div>
</div>
<h1>The links</h1>
<h2>Resource sites</h2>
<p>Microsoft Dev Center - Metro Style Apps<br />
<a href="http://msdn.microsoft.com/en-us/windows/apps/br229512.aspx">http://msdn.microsoft.com/en-us/windows/apps/br229512.aspx</a></p>
<p>Build 2011 on Channel 9 (Lots of great videos!)<br />
<a href="http://channel9.msdn.com/Events/Build/Build2011">http://channel9.msdn.com/Events/Build/Build2011</a></p>
<h2>Blog posts</h2>
<h3>Introduction to developing Metro applications in HTML5</h3>
<p>Stephen Walter has many nice intro posts on developing Metro applications with HTML5.<br />
<a href="http://stephenwalther.com/blog/archive/category/metro" target="_blank">http://stephenwalther.com/<wbr>blog/archive/category/metro</wbr></a></p>
<h3>"What's new in the Beta"</h3>
<p>What’s New in the Beta Metro/JS Templates for VS11<br />
<a href="http://www.sellsbrothers.com/Posts/Details/12716">http://www.sellsbrothers.com/Posts/Details/12716</a></p>
<p>Migrating your apps from Developer Preview to Consumer Preview<br />
<a href="http://blogs.msdn.com/b/windowsappdev/archive/2012/03/08/migrating-your-apps-from-developer-preview-to-consumer-preview.aspx">http://blogs.msdn.com/b/windowsappdev/archive/2012/03/08/migrating-your-apps-from-developer-preview-to-consumer-preview.aspx</a></p>
<p>What’s changed for app developers since //build/<br />
<a href="http://blogs.msdn.com/b/windowsappdev/archive/2012/03/01/what-s-changed-since-build-part-1.aspx">http://blogs.msdn.com/b/windowsappdev/archive/2012/03/01/what-s-changed-since-build-part-1.aspx</a><br />
<a href="http://blogs.msdn.com/b/windowsappdev/archive/2012/03/06/what-s-changed-for-app-developers-since-build-part-2.aspx">http://blogs.msdn.com/b/windowsappdev/archive/2012/03/06/what-s-changed-for-app-developers-since-build-part-2.aspx</a></p>
<h3>Tutorials</h3>
<p>Create your first Metro style app using JavaScript (<span style="text-decoration: underline;"><em>This is the tutorial that we based our final demo on!</em></span>)<a href="http://msdn.microsoft.com/en-us/library/windows/apps/br211385.aspx"></p>
<p>http://msdn.microsoft.com/en-us/library/windows/apps/br211385.aspx</a></p>
<p>How to cook a complete Windows 8 application with HTML5, CSS3 and JavaScript in a week<br />
<a href="http://blogs.msdn.com/b/eternalcoding/archive/tags/windows+8/">http://blogs.msdn.com/b/eternalcoding/archive/tags/windows+8/</a></p>
<p>Quickstart: adding a SemanticZoom<br />
<a href="http://msdn.microsoft.com/en-us/library/windows/apps/hh465492.aspx">http://msdn.microsoft.com/en-us/library/windows/apps/hh465492.aspx</a></p>
<h3>Technology specific posts</h3>
<p>HTML, CSS, and JavaScript features and differences<br />
<a href="http://msdn.microsoft.com/en-us/library/windows/apps/hh465380.aspx">http://msdn.microsoft.com/en-us/library/windows/apps/hh465380.aspx</a></p>
<p>Hands On: CSS3 Grid Layout (IE10 only)<br />
<a href="http://ie.microsoft.com/testdrive/Graphics/hands-on-css3/hands-on_grid.htm">http://ie.microsoft.com/testdrive/Graphics/hands-on-css3/hands-on_grid.htm</a></p>
<p>Quickstart: Using single-page navigation<br />
<a href="http://msdn.microsoft.com/en-us/library/windows/apps/hh452768.aspx">http://msdn.microsoft.com/en-us/library/windows/apps/hh452768.aspx</a></p>
<p>Security contexts<br />
<a href="http://msdn.microsoft.com/en-us/library/windows/apps/hh465373.aspx">http://msdn.microsoft.com/en-us/library/windows/apps/hh465373.aspx</a></p>
<p>Grouping and Semantic Zoom<br />
<a href="http://debugmode.net/2012/03/21/listview-binding-with-grouping-and-semantic-zoom-in-windows-8-javascript-metro-application/">http://debugmode.net/2012/03/21/listview-binding-with-grouping-and-semantic-zoom-in-windows-8-javascript-metro-application/</a></p>
<p>WinJS Promises: then and done<br />
<a href="http://www.sellsbrothers.com/Posts/Details/12717">http://www.sellsbrothers.com/Posts/Details/12717</a></p>
<p>Making HTML safer: details for toStaticHTML<br />
<a href="http://msdn.microsoft.com/en-us/library/windows/apps/hh465388.aspx">http://msdn.microsoft.com/en-us/library/windows/apps/hh465388.aspx<br />
</a></p>
<p>HTML AppBar control sample<br />
<a href="http://code.msdn.microsoft.com/windowsapps/App-bar-sample-a57eeae9">http://code.msdn.microsoft.com/windowsapps/App-bar-sample-a57eeae9</a></p>
<h2>Videos</h2>
<p>Debugging your Metro style apps using HTML<br />
<a href="http://channel9.msdn.com/Events/BUILD/BUILD2011/TOOL-514T">http://channel9.msdn.com/Events/BUILD/BUILD2011/TOOL-514T</a></p>
<p>Introducing the Windows libraries for JavaScript<br />
<a href="http://channel9.msdn.com/Events/BUILD/BUILD2011/TOOL-501T">http://channel9.msdn.com/Events/BUILD/BUILD2011/TOOL-501T</a></p>
<p>Building Metro style apps using JavaScript<br />
<a href="http://channel9.msdn.com/Events/BUILD/BUILD2011/TOOL-527C">http://channel9.msdn.com/Events/BUILD/BUILD2011/TOOL-527C</a></p>
<p>WinJS Promises #1<br />
<a href="http://mtaulty.com/CommunityServer/blogs/mike_taultys_blog/archive/2012/04/11/winjs-promises-1.aspx">http://mtaulty.com/CommunityServer/blogs/mike_taultys_blog/archive/2012/04/11/winjs-promises-1.aspx</a></p>
<h2>Some issues we had</h2>
<p>Blend For Visual Studio 11 get an error<br />
<a href="http://stackoverflow.com/questions/9760643/blend-for-visual-studio-11-get-an-error">http://stackoverflow.com/questions/9760643/blend-for-visual-studio-11-get-an-error</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.jayway.com/2012/04/27/windows-8-for-web-developers-techdays-2012-debriefing/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Converting to Windows 8 from Windows Phone &#124; Localization of your application (9 of 12)</title>
		<link>http://blog.jayway.com/2012/04/26/converting-to-windows-8-from-windows-phone-localization-of-your-application-9-of-12/</link>
		<comments>http://blog.jayway.com/2012/04/26/converting-to-windows-8-from-windows-phone-localization-of-your-application-9-of-12/#comments</comments>
		<pubDate>Thu, 26 Apr 2012 06:30:49 +0000</pubDate>
		<dc:creator>Peter von Lochow</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[metro]]></category>
		<category><![CDATA[windows 8]]></category>
		<category><![CDATA[windows phone]]></category>
		<category><![CDATA[windows phone 7]]></category>
		<category><![CDATA[xaml]]></category>

		<guid isPermaLink="false">http://blog.jayway.com/?p=13108</guid>
		<description><![CDATA[I don’t think I need to stress how important it is to place all of your texts (as in language specific texts visible to the end user) in the same place. To look around in your code and XAML after strings that may be duplicated through the application makes us sad developers. Even if you [...]]]></description>
			<content:encoded><![CDATA[<p>I don’t think I need to stress how important it is to place all of your texts (as in language specific texts visible to the end user) in the same place. To look around in your code and XAML after strings that may be duplicated through the application makes us sad developers. Even if you from start only support one language (and don’t plan to support any other) you can save a lot of time by adding all of your text in a resource file from start.</p>
<p>We, naturally, went with resource files when implementing <a href="http://www.windowsphone.com/sv-SE/apps/dd415e08-2de8-431a-9c0a-b431efaa115b">Reseguidens sista-minuten</a> application. We also chose to read from the resource file in our view models and then databind to the view. We did this because it is simpler to add dynamic data with <span style="font-family: consolas">string.Format(…)</span> in the view model.</p>
<p>In this post we’ll explain how we used resource files when implementing the Windows Phone application, and how we changed it for Windows 8.</p>
<p>This post is a part in a series - you can find the full index <a href="http://blog.jayway.com/2012/04/04/converting-to-windows-8-from-windows-phone-introduction-1-of-12/">here</a>.</p>
<h2>New file type</h2>
<p>First of all, before I say anything else, I would like to point out that the resx file type, that we are used to, has been switched to a resw file type in Windows 8. This means that you cannot directly reuse your old resource files.</p>
<p>This is really no problem. You simply select all in your old resx file and copy it into your new resw file.</p>
<h2>Databind texts from the view model</h2>
<p>Pro – as we mentioned earlier, is that you easily can format the text when mixing it up with data. Con – you need to write a lot of extra code. Below are some code that we just cut from a view model in the Windows Phone application. Our resource file is named <em>AppResources</em>.</p>
<pre class="brush: csharp; ruler: true; auto-links: false; smart-tabs: false;">public string DateToTitle { get {
  return AppResources.DetailPivot_DateToTitle; } }
public string TripLengthTitle { get {
  return AppResources.DetailPivot_TripLengthTitle; } }
public string InfoTitle { get {
  return AppResources.DetailPivot_InfoTitle; } }</pre>
<p>
  <br />So, this won’t compile in Windows 8. The handling of resource files has changed. If we want to bind the text resources in a similar manner in Windows 8 we first need to initiate a <a href="http://msdn.microsoft.com/en-us/library/windows/apps/br206014.aspx">ResourceLoader</a>.</p>
<p></p>
<pre class="brush: csharp; ruler: true; auto-links: false; smart-tabs: false;">var resourceLoader = new ResourceLoader(&quot;AppResources&quot;);</pre>
<p>
  <br />Then to get the values we write.</p>
<p></p>
<pre class="brush: csharp; ruler: true; auto-links: false; smart-tabs: false;">public string DateToTitle { get {
  return _resources.GetString(&quot;DetailPivot_DateToTitle&quot;); } }
public string TripLengthTitle { get {
  return _resources.GetString(&quot;DetailPivot_TripLengthTitle&quot;); } }
public string InfoTitle { get {
  return _resources.GetString(&quot;DetailPivot_InfoTitle&quot;); }</pre>
<p>So gone is the type safe static methods, instead we have strings (o_O). I don’t know why or how this decision was made, but in either case it doesn’t feel right to fetch the texts by string keys in the view model anymore. Not at all.</p>
<h2>Bind directly to resource files in the view</h2>
<p>This is the second option. This option is of course available in Windows Phone as well. But then you would preferably do it via a proxy and yes, it becomes quite messy for a functionality that really should be very simple.</p>
<p>How does it work in Windows 8 then? Well – better.</p>
<p>In Windows 8 you got a new convention based way to bind resource keys to a view. Let us look at an example.</p>
<pre class="brush: xml; ruler: true; auto-links: false; smart-tabs: false;">&lt;TextBlock x:Uid=”SearchPageTitle” /&gt;</pre>
<p>Note that the only thing specified is the <strong>Uid</strong>, it will bind to this.</p>
<p><a href="http://blog.jayway.com/wordpress/wp-content/uploads/2012/04/win-8-metro-resources1.png" rel="lightbox"><img title="win-8-metro-resources" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="win-8-metro-resources" src="http://blog.jayway.com/wordpress/wp-content/uploads/2012/04/win-8-metro-resources_thumb.png" width="461" height="116" /></a></p>
<p>No other code is necessary. The binding is handled by conventions that look at the resource name and the <strong>Uid</strong> and then match up the ones that fit. Very, very neat.</p>
<h2>However you did it on your Windows Phone</h2>
<p>You’ll probably end up rewriting some of the code for Windows 8. Luckily, it’s really simple to copy texts from an old resx file to a new resw file. On a personal note – we think that the convention based binding in Windows 8 feels much more modern and slick than the bulky old way.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.jayway.com/2012/04/26/converting-to-windows-8-from-windows-phone-localization-of-your-application-9-of-12/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Beginning Windows Phone development&#8211;slides and code from TechDays Sweden 2012</title>
		<link>http://blog.jayway.com/2012/04/25/beginning-windows-phone-developmentslides-and-code-from-techdays-sweden-2012/</link>
		<comments>http://blog.jayway.com/2012/04/25/beginning-windows-phone-developmentslides-and-code-from-techdays-sweden-2012/#comments</comments>
		<pubDate>Wed, 25 Apr 2012 21:22:24 +0000</pubDate>
		<dc:creator>Andreas Hammar</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[metro]]></category>
		<category><![CDATA[windows phone]]></category>
		<category><![CDATA[windows phone 7]]></category>

		<guid isPermaLink="false">http://blog.jayway.com/?p=13376</guid>
		<description><![CDATA[Today I’ve had the honor and privilege to present at TechDays Sweden and at TechDays@campus, Örebro University. The topic was Beginning Windows Phone development and at both venues I had a big crowd with interested developers – couldn’t be better! I here bring you the code samples and slides – thank you for coming! Code [...]]]></description>
			<content:encoded><![CDATA[<p>Today I’ve had the honor and privilege to present at TechDays Sweden and at <a href="mailto:TechDays@campus">TechDays@campus</a>, Örebro University. The topic was Beginning Windows Phone development and at both venues I had a big crowd with interested developers – couldn’t be better! I here bring you the code samples and slides – thank you for coming!</p>
<h2>Code</h2>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:fb3a1972-4489-4e52-abe7-25a00bb07fdf:b65a8f4a-751a-4cfd-93eb-2956c02afe16" class="wlWriterEditableSmartContent">
<p> <a href="http://blog.jayway.com/wordpress/wp-content/uploads/2012/04/techdays-2012-beginning-windows-phone-development-andreas-hammar2.zip">download code</a></p>
</div>
<h2>Slides</h2>
<div style="width: 425px" id="__ss_12687926"><strong style="margin: 12px 0px 4px; display: block"><a title="Techdays 2012 - Beginning Windows Phone development - Andreas Hammar" href="http://www.slideshare.net/AndreasHammar/techdays-2012-beginning-windows-phone-development-andreas-hammar">Techdays 2012 - Beginning Windows Phone development - Andreas Hammar</a></strong><object id="__sse12687926" width="425" height="355"><param name="movie" value="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=techdays-2012-beginning-windows-phone-development-andreashammar-120425105712-phpapp01&amp;stripped_title=techdays-2012-beginning-windows-phone-development-andreas-hammar&amp;userName=AndreasHammar" /><param name="allowFullScreen" value="true" /><param name="allowScriptAccess" value="always" /><param name="wmode" value="transparent" /><embed name="__sse12687926" src="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=techdays-2012-beginning-windows-phone-development-andreashammar-120425105712-phpapp01&amp;stripped_title=techdays-2012-beginning-windows-phone-development-andreas-hammar&amp;userName=AndreasHammar" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" wmode="transparent" width="425" height="355"></embed></object>
<div style="padding-bottom: 12px; padding-left: 0px; padding-right: 0px; padding-top: 5px">View more <a href="http://www.slideshare.net/">presentations</a> from <a href="http://www.slideshare.net/AndreasHammar">Andreas Hammar</a>.</div>
</p></div>
]]></content:encoded>
			<wfw:commentRss>http://blog.jayway.com/2012/04/25/beginning-windows-phone-developmentslides-and-code-from-techdays-sweden-2012/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[Windows 8] CSharp targets not found in Blend 5 after Windows Phone SDK</title>
		<link>http://blog.jayway.com/2012/04/23/windows-8-csharp-targets-not-found-in-blend-5-after-windows-phone-sdk/</link>
		<comments>http://blog.jayway.com/2012/04/23/windows-8-csharp-targets-not-found-in-blend-5-after-windows-phone-sdk/#comments</comments>
		<pubDate>Mon, 23 Apr 2012 07:20:29 +0000</pubDate>
		<dc:creator>Håkan Reis</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[blend]]></category>
		<category><![CDATA[windows 8]]></category>
		<category><![CDATA[windows phone]]></category>

		<guid isPermaLink="false">http://blog.jayway.com/?p=13332</guid>
		<description><![CDATA[I had a little accident last week and needed a computer fast. The only thing I could get was a computer with Windows 8 Consumer Preview already installed. That was actually no problem as I’m currently working on a Windows 8 project. Problem is that I also work on a number of Windows Phone projects. [...]]]></description>
			<content:encoded><![CDATA[<p>I had a little accident last week and needed a computer fast. The only thing I could get was a computer with Windows 8 Consumer Preview already installed. That was actually no problem as I’m currently working on a Windows 8 project. Problem is that I also work on a number of Windows Phone projects. </p>
<p>Apart from the XNA installation problem, the WP SDK was no problem to install and all seemed fine, until I opened up the Windows 8 project in Blend… or actually tried to open it up.</p>
<p>Whatever I did I was greeted with the same message:</p>
<p><a href="http://blog.jayway.com/wordpress/wp-content/uploads/2012/04/Message.png" rel="lightbox"><img title="Message" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="Message" src="http://blog.jayway.com/wordpress/wp-content/uploads/2012/04/Message_thumb.png" width="590" height="142" /></a></p>
<p>I tried a number of (time consuming) things here, repair of VS11, uninstall of Blend 5 beta and reinstall and in the end a complete reinstall (as in uninstall/install) of Visual Studio 11. No luck.</p>
<p>The I actually started to read the error message:</p>
<blockquote><p>… The imported project &quot;C:\Program Files (x86)\MSBuild\Microsoft\WindowsXaml\v10.0\Microsoft.Windows.UI.Xaml.CSharp.targets&quot; was not found. Confirm that the path in the &lt;import&gt; declaration is correct, and that the file exists on disk. …</p>
</blockquote>
<p>First thought was to check the project file but why would I need to change that, it worked before. Nope, the problem is obviously that the MSBuild targets are not found where it’s supposed to be.&#160; Second try was to copy the actual files to the v10.0 path. That didn’t do it either, led to a couple of new problems instead. </p>
<p>Finally I found the problem after some experimenting (remember, this is Windows 8, searching the net will get you about 3 hits – none of them relevant). The solution was to add an Environment variable to the system to get it running.</p>
<ol>
<li>Right click on Computer, select Properties</li>
<li>Select Advanced system settings</li>
<li>Down to the right you find Environment variables (they get a bit harder to find for each version of Windows…)</li>
<li>Add the System variable <em>VisualStudioVersion</em><strong> </strong>with a value of <em>11.0</em> and that’s it</li>
</ol>
<p><a href="http://blog.jayway.com/wordpress/wp-content/uploads/2012/04/Env.png" rel="lightbox"><img title="Env" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="Env" src="http://blog.jayway.com/wordpress/wp-content/uploads/2012/04/Env_thumb.png" width="373" height="172" /></a></p>
<p>Now open up Blend 5 and load your Windows 8 project!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.jayway.com/2012/04/23/windows-8-csharp-targets-not-found-in-blend-5-after-windows-phone-sdk/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Converting to Windows 8 from Windows Phone &#124; Navigation (8 of 12)</title>
		<link>http://blog.jayway.com/2012/04/23/converting-to-windows-8-from-windows-phone-navigation-8-of-12/</link>
		<comments>http://blog.jayway.com/2012/04/23/converting-to-windows-8-from-windows-phone-navigation-8-of-12/#comments</comments>
		<pubDate>Mon, 23 Apr 2012 06:30:29 +0000</pubDate>
		<dc:creator>Andreas Hammar</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[metro]]></category>
		<category><![CDATA[windows 8]]></category>
		<category><![CDATA[windows phone]]></category>
		<category><![CDATA[windows phone 7]]></category>
		<category><![CDATA[winrt]]></category>
		<category><![CDATA[xaml]]></category>

		<guid isPermaLink="false">http://blog.jayway.com/?p=13113</guid>
		<description><![CDATA[Navigation in Windows Phone has a clear legacy from Silverlight, you get around using Uris and query strings. What might have been the best solution for the web is clumsy and cumbersome in a native environment. This has often led to custom wrappers around the navigation APIs. All this has changed in Window 8, navigation [...]]]></description>
			<content:encoded><![CDATA[<p>Navigation in Windows Phone has a clear legacy from Silverlight, you get around using Uris and query strings. What might have been the best solution for the web is clumsy and cumbersome in a native environment. This has often led to custom wrappers around the navigation APIs.</p>
<p>All this has changed in Window 8, navigation feels more modern and easy to use. In this article we’ll take a closer look at the old and new way of navigating.</p>
<p>This post is a part in a series - you can find the full index <a title="Converting to Windows 8 from Windows Phone | Introduction (1 of 12)" href="http://blog.jayway.com/2012/04/04/converting-to-windows-8-from-windows-phone-introduction-1-of-12/">here</a>.</p>
<h2>Differences</h2>
<p>There are two big differences in how navigation works on Windows Phone and Windows 8.</p>
<h3>1. Forward</h3>
<ul>
<li>On Windows Phone, pages are navigated to using a Uri and data passed as a query string </li>
<li>On Windows 8, pages are navigated to by passing the type, and data passed as an object </li>
</ul>
<h3>2. Back</h3>
<ul>
<li>Windows Phone has a physical back button and a back stack </li>
<li>Windows 8 has to implement a back button, if one is wanted, within the UI </li>
</ul>
<p>This means that the navigation code will have to be rewritten and data passed differently.</p>
<p>We feel that the Windows 8 way of navigating is preferable. Especially passing data is much better done by passing objects than sending simple values through the query string.</p>
<p>One could serialize an entire object as XML or JSON and pass on the query string, but that is a sub-optimal solution, and the query string is limited to 2050 characters and hard coded strings are needed to read from the query string.</p>
<h2>Navigation</h2>
<p>So, lets begin by looking at how navigation between two pages is done on Windows Phone.</p>
<pre class="brush: csharp;">// navigate
private void NavigateButton_Click(object sender, RoutedEventArgs e)
{
     NavigationService.Navigate(new Uri(&quot;/Page.xaml?key=value&quot;, UriKind.Relative));
}

//receive data
protected override void OnNavigatedTo(NavigationEventArgs e)
{
    string value = NavigationContext.QueryString[&quot;key&quot;];
    base.OnNavigatedTo(e);
}</pre>
<p>Nothing you haven’t seen before, lets dive straight to the Windows 8 way of navigating. Our setup is a main page containing a Frame in which all pages will be shown.</p>
<pre class="brush: csharp;">&lt;Grid Background=&quot;{StaticResource BackgroundBrush}&quot;&gt;
     &lt;Frame x:Name=&quot;ContentFrame&quot; /&gt;
&lt;/Grid&gt;</pre>
<p>Then what we’ve done is sent our “ContentFrame” into a static Navigate class.</p>
<pre class="brush: csharp;">public static class Navigate
{
     private static Frame _rootFrame;
     public static void SetRootFrame(Frame rootFrame)
     {
          _rootFrame = rootFrame;
     }
     public static void To(Type page, object data)
     {
          _rootFrame.Navigate(page, data);
     }
}</pre>
<p>This gives us the ability to, wherever we are in our application, navigate like this:</p>
<pre class="brush: csharp;">Navigate.To(typeof(SearchPage), searchQuery);</pre>
<p>And receiving data is as simple as:</p>
<pre class="brush: csharp;">protected override void OnNavigatedTo(NavigationEventArgs e)
{
     var searchQuery = (SearchQuery)e.Parameter;
}</pre>
<p>The big advantage here is getting rid of all magic strings. The risk of misspelling and running into run-time errors is gone now that we use the compiler as our spell checker. Plus, it’s a heck of a lot more convenient to pass data as objects instead of strings.</p>
<h2>Page cache</h2>
<p>When pressing the back key in a Windows Phone application to go back, two things will happen:</p>
<ul>
<li>You’re taken back to the previous page (or out of the application if you were on the start page)</li>
<li>A saved page is loaded, i.e. a page that still has all the data it had when you navigated away from it</li>
</ul>
<p>If you implement a back button on Windows 8 and use it, you will soon realize that you are not taken back to a cached instance of the page, instead the page that you navigate back to is created again. Hence if you are on a search page, tap on an item in the search result and then go back the search result will be cleared, very frustrating.</p>
<p>To get around this you could either save your view models in a cache and load those, or…</p>
<pre class="brush: csharp;">public SearchPage()
{
     InitializeComponent();
     NavigationCacheMode = NavigationCacheMode.Enabled;
}</pre>
<p>That row will activate the cache and give the same behavior as Windows Phone has, very nice.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.jayway.com/2012/04/23/converting-to-windows-8-from-windows-phone-navigation-8-of-12/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Disjoint Commands in CQRS+DDD+ES</title>
		<link>http://blog.jayway.com/2012/04/20/disjoint-commands-in-cqrs-ddd-es/</link>
		<comments>http://blog.jayway.com/2012/04/20/disjoint-commands-in-cqrs-ddd-es/#comments</comments>
		<pubDate>Fri, 20 Apr 2012 15:59:09 +0000</pubDate>
		<dc:creator>Henrik Feldt</dc:creator>
				<category><![CDATA[Architecture]]></category>
		<category><![CDATA[asynchronous]]></category>
		<category><![CDATA[cqrs]]></category>

		<guid isPermaLink="false">http://blog.jayway.com/?p=13308</guid>
		<description><![CDATA[I was sitting here reading the paper 'Impossibility of Distributed Consensus with One Faulty Process' and came upon this lemma: Lemma: Suppose that from some configuration C, the schedules µ1 and µ2 lead to configurations C1, C2, respectively. If the set of processes taking steps in µ1 and µ2, respectively, are disjoint, then µ2 can [...]]]></description>
			<content:encoded><![CDATA[<p>I was sitting here reading the paper '<a href="http://blog.jayway.com/wordpress/wp-content/uploads/2012/04/Impossibility-of-Distributed-Consensus-with-One-Faulty-Process.pdf" title="application/pdf - the paper">Impossibility of Distributed Consensus with One Faulty Process</a>' and came upon this lemma:</p>
<p><em><strong>Lemma</strong>: Suppose that from some configuration C, the schedules µ1 and µ2 lead to configurations C1, C2, respectively. If the set of processes taking steps in µ1 and µ2, respectively, are disjoint, then µ2 can be applied to C1 and µ1 can be applied to C2, and both lead to the same configuration C3.<br />
<strong>Proof</strong>: The result follows at once from the system definition, since µ1 and µ2 does not interact.</em></p>
<p>I realized this could be rewritten with CQRS vocab:</p>
<p><em>Call all events resulting from applying a command onto an entity, a schedule.<br />
Suppose that from some initial state of an aggregate C, the schedules µ1 and µ2 lead to states C1, C2, respectively. If the commands resulting in schedules µ1 and µ2, respectively, are disjoint, then µ2 can be applied to an aggregate in state C1 and µ1 can be applied to an aggregate in state C2, and both lead to the same final aggregate state, C3.</em></p>
<p>This gives us the vocabulary for reasoning about when commands cause the same end state, no matter their ordering - they are then disjoint! We can start writing code like this (pseudo):</p>
<p><script src="https://gist.github.com/2429892.js"> </script></p>
<pre>InternalStateOfAllFields</pre>
<p> could simply hash all fields and compare the hash.</p>
<p>There would also need to be a method for specifying what commands require previously sent commands to be applied, filtering out those 2-variations of commands which don't share common initial states from previously applied schedules.</p>
<p>Would this hold? Comments?</p>
<p><span style="font-size:small"><a href="http://www.codeproject.com/Articles/26050/Permutations-Combinations-and-Variations-using-C-G#pre8" title="algorithm for finding all variations of items in a set">new Variations()</a></span></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.jayway.com/2012/04/20/disjoint-commands-in-cqrs-ddd-es/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Windows phone projects always break at unhandled exceptions</title>
		<link>http://blog.jayway.com/2012/04/20/windows-phone-projects-always-break-at-unhandled-exceptions/</link>
		<comments>http://blog.jayway.com/2012/04/20/windows-phone-projects-always-break-at-unhandled-exceptions/#comments</comments>
		<pubDate>Fri, 20 Apr 2012 13:04:20 +0000</pubDate>
		<dc:creator>Andreas Hallberg</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[Tips & Tricks]]></category>
		<category><![CDATA[visual studio]]></category>
		<category><![CDATA[windows phone]]></category>
		<category><![CDATA[wp7]]></category>

		<guid isPermaLink="false">http://blog.jayway.com/?p=13300</guid>
		<description><![CDATA[Here’s a quick fact that would have saved me quite some time of frustration and fruitless googling had I known it: When debugging Windows Phone applications in Visual Studio 2010, user-unhandled exceptions will always break into the debugger, regardless of how much you fiddle with Debug &#124; Exceptions or Tools &#124; Options &#124; Debugging: Windows [...]]]></description>
			<content:encoded><![CDATA[<p>Here’s a quick fact that would have saved me quite some time of frustration and fruitless googling had I known it: When debugging Windows Phone applications in Visual Studio 2010, user-unhandled exceptions will always break into the debugger, regardless of how much you fiddle with Debug | Exceptions or Tools | Options | Debugging:</p>
<blockquote><p>Windows Phone projects always break at unhandled exceptions. You can select Exceptions from the Debug menu and then change these settings, <strong>but changes are not honored</strong>. This command is present only in the Windows Phone Add-in for Visual Studio 2010.</p>
</blockquote>
<p>(<a href="http://msdn.microsoft.com/en-us/library/ff402572(v=vs.92).aspx" target="_blank">MSDN</a>, scroll down to “Exception handling configuration”. Emphasis is mine.)</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.jayway.com/2012/04/20/windows-phone-projects-always-break-at-unhandled-exceptions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Report from Scala Days 2012</title>
		<link>http://blog.jayway.com/2012/04/19/report-from-scala-days-2012/</link>
		<comments>http://blog.jayway.com/2012/04/19/report-from-scala-days-2012/#comments</comments>
		<pubDate>Thu, 19 Apr 2012 14:49:13 +0000</pubDate>
		<dc:creator>Anders Eriksson</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[conference]]></category>
		<category><![CDATA[report]]></category>
		<category><![CDATA[scala]]></category>
		<category><![CDATA[scaladays]]></category>

		<guid isPermaLink="false">http://blog.jayway.com/?p=13267</guid>
		<description><![CDATA[On April 17-18 the three of us attended the Scala Days 2012 conference in London. Many of the most known and active contributors to the Scala community were there - either as attendee or speaker. The conference was fully booked with 400 participants and so many on waiting list. We would like to give a [...]]]></description>
			<content:encoded><![CDATA[<p><em></em>On April 17-18 the three of us attended the <a title="Scala Days 2012" href="http://days2012.scala-lang.org/" target="_blank">Scala Days 2012</a> conference in London. Many of the most known and active contributors to the Scala community were there - either as attendee or speaker. The conference was fully booked with 400 participants and so many on waiting list. We would like to give a summary and our thoughts about this conference.</p>
<p><strong>Keynotes</strong></p>
<p>As it happened two of four keynotes on this Scala conference were mostly about other programming languages than Scala. The opening talk that <a href="http://en.wikipedia.org/wiki/Guy_L._Steele,_Jr.">Guy Steele</a> did was about <a title="Fortress" href="http://projectfortress.java.net/" target="_blank">Fortress</a>. Steele is a computer scientist who worked on the early Java versions as well as other languages. Fortress is<del datetime="2012-04-23T17:37:23+00:00"><strong></strong></del> a programming language designed for high-performance computing trying to push the boundaries on providing a highly readable syntax, especially for a mathematical purpose. In his talk Steele showed similarities and difference between Scala and Fortress. His talk gave some very interesting insights into language design and showed how both languages can learn from each other. He mentioned that programming should be like writing on a whiteboard...</p>
<div id="attachment_13355" class="wp-caption alignleft" style="width: 310px"><a href="http://blog.jayway.com/wordpress/wp-content/uploads/2012/04/IMGP4396.jpg" rel="lightbox"><img class="size-medium wp-image-13355   " title="Simon_Peyton_Jones_1" src="http://blog.jayway.com/wordpress/wp-content/uploads/2012/04/IMGP4396-300x235.jpg" alt="" width="300" height="235" /></a><p class="wp-caption-text">Simon Peyton-Jones in bare foot action</p></div>
<p>The second keynote was held by <a href="http://research.microsoft.com/en-us/people/simonpj/">Simon Peyton-Jones</a> who is a researcher at Microsoft Lab in Cambridge. His area of research is mainly Functional Programming and Haskell. He demonstrated a lot of Haskell codes and walked through a practical actor implementation in Haskell.</p>
<p>The creator of Scala and founder of Typesafe - <a href="http://lampwww.epfl.ch/~odersky/">Martin Odersky</a> - held the third keynote on the second day of conference on "Where Scala is going?". He quickly discussed the new features and improvements in future 2.10 release. The greatest news is that you can use Scala reflection API in 2.10. Martin mentioned the difficulty of integrating the reflection API into the Scala core and how they have managed to do that. Then he talked about Scala Macro! It will be experimental in 2.10 release but it's a start of a game changer in Scala ecosystem.</p>
<div id="attachment_13365" class="wp-caption alignright" style="width: 310px"><a href="http://blog.jayway.com/wordpress/wp-content/uploads/2012/04/IMGP4397.jpg" rel="lightbox"><img class="size-medium wp-image-13365" title="IMGP4397" src="http://blog.jayway.com/wordpress/wp-content/uploads/2012/04/IMGP4397-300x208.jpg" alt="" width="300" height="208" /></a><p class="wp-caption-text">Martin Odersky on Where Scala&#39;s going?</p></div>
<p>The last keynote was given by Antony Rose the founder Zeebox. The talk was mainly about visionary behind a revolutionary social TV and not really something about Scala at all. The only thing he mentioned was that they use Scala in their backend system.</p>
<p>There were around 70 great talks totally at the conference. Here are some of our personal favourites:</p>
<p><strong>Talks</strong></p>
<p><em>Akka2: Distributed by Design</em>: Jonas Bonér talked about the new <a href="http://doc.akka.io/docs/akka/2.0.1/cluster/cluster.html">cluster module in Akka</a>.</p>
<p><em>The Future I was promised</em>: Viktor Klang talked about <a href="http://docs.scala-lang.org/sips/pending/futures-promises.html">Futures and Promises</a> and how they can be used to compose asynchronous dataflows.</p>
<p><em>Concurrent Programming with Futures, Offers and Brokers</em>: Marius Eriksen from twitter explained how they tackle concurrency issues with <a href="http://twitter.github.com/effectivescala/#Twitter's standard libraries-Futures">Futures</a>, <a href="http://twitter.github.com/effectivescala/#Twitter's standard libraries-Offer/Broker">Offers and Brokers</a>.</p>
<p><em>Stackless Scala with Free Monads</em>: Rúnar Bjarnason showed how <a href="http://days2012.scala-lang.org/sites/days2012/files/bjarnason_trampolines.pdf">Trampolining technique</a> can be used to get rid of stack overflow problem.</p>
<p><em>How to map and fold over an HList in shapeless</em>: Miles Sabin talked about <a href="https://github.com/milessabin/shapeless">Shapeless</a> and how one can do map and fold on an heterogeneous list</p>
<p><em>Practical Scalaz: Using One of Scala's Most Controversial Libraries</em>: Jordan West discussed how <a href="http://code.google.com/p/scalaz/">Scalaz</a> library is heavily used at StackMob</p>
<p><em>Spark in Action</em>: Matei Zaharia demonstrated <a href="http://www.spark-project.org/">Spark</a> that is a cluster computing framework that outperforms Hadoop by up to 30x in applications where repeated map reduce tasks have to be performed.</p>
<p><em>Spray: REST on Akka</em>: Mathias Doenitz talked about <a href="http://www.spray.cc/">Spray</a> that is a suit of lightweight Scala libraries for building and consuming RESTful web services on top of Akka</p>
<p><em>High Performance Embedded DSLs with Delite</em>: Arvind Sujeeth explained how one can use <a href="https://github.com/stanford-ppl/Delite">Delite</a> that is a framework for building high performance embedded DSLs in Scala.</p>
<p><em>Pettswood - Executable Documentation for Scala Acceptance Testing:</em> Chris Agmen-Smith gave a lot of insight on having users describe the requirements directly in his <a title="Pettswood" href="https://github.com/agmenc/Pettswood" target="_blank">Pettswood</a> tool.</p>
<p><em>Making games and solving puzzles in Scala</em>: 12 year old Shadaj Laddad gave a great talk and explained how he learned programming in Scala and how he has fun with it solving puzzles and writing games.</p>
<p><strong>Conclusions</strong></p>
<ul>
<li>A very high level on the conference talks. It appears that there has been a lot of advances recently in Scala.</li>
<li>IntelliJ IDE and Scala IDE are both powerful enough to enable handy and cool features for Scala enthusiasts. The Scala tool support is getting better all the time.</li>
<li>Scala community has shown a great passion for improvement and being open to critics that we think is really valuable. See <a href="http://docs.scala-lang.org/sips/index.html">Scala Improvement Process</a> (SIP) for an example.</li>
<li>Some languages exist in Industry and some other exist only in academia. Scala is where academy and industry meet each other. There were around 14-15 people from EPFL in the conference and that are mostly PhDs. It's a secure feeling that a lot of researcher and PhD students heavily contribute to Scala community while keeping the stability for industry.</li>
<li>Skillsmatter did a really good job organizing Scala Days, and many of the talks already came up as podcast during the conference. You'll find them here: <a title="scaladays" href="http://skillsmatter.com/event/scala/scala-days-2012" target="_blank">http://skillsmatter.com/event/scala/scala-days-2012</a></li>
</ul>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.jayway.com/2012/04/19/report-from-scala-days-2012/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Converting to Windows 8 from Windows Phone &#124; Cache and working with storage (7 of 12)</title>
		<link>http://blog.jayway.com/2012/04/19/converting-to-windows-8-from-windows-phone-cache-and-working-with-storage-7-of-12/</link>
		<comments>http://blog.jayway.com/2012/04/19/converting-to-windows-8-from-windows-phone-cache-and-working-with-storage-7-of-12/#comments</comments>
		<pubDate>Thu, 19 Apr 2012 06:30:03 +0000</pubDate>
		<dc:creator>Peter von Lochow</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[metro]]></category>
		<category><![CDATA[windows 8]]></category>
		<category><![CDATA[windows phone]]></category>
		<category><![CDATA[windows phone 7]]></category>
		<category><![CDATA[xaml]]></category>

		<guid isPermaLink="false">http://blog.jayway.com/?p=13079</guid>
		<description><![CDATA[Just as with most Windows Phone applications, you typically add value to a Windows 8 application when caching data. You gain some offline ability as well as a quick and snappy application that doesn’t need to go online and download data all the time. In Reseguiden’s application we are not actually saving any data in [...]]]></description>
			<content:encoded><![CDATA[<p>Just as with most Windows Phone applications, you typically add value to a Windows 8 application when caching data. You gain some offline ability as well as a quick and snappy application that doesn’t need to go online and download data all the time.</p>
<p>In <a href="http://www.windowsphone.com/sv-SE/apps/dd415e08-2de8-431a-9c0a-b431efaa115b">Reseguiden’s application</a> we are not actually saving any data in our cache. This is because all data really need to be fresh so we really can’t cache it any longer than the application runs. But we do save previous searches (only the query, not the result) that makes it possibly for users to flip through previous searches in a pivot even in the application is restarted.</p>
<p><a href="http://blog.jayway.com/wordpress/wp-content/uploads/2012/04/07.-saved-searches.jpg" rel="lightbox"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto; padding-top: 0px" title="Saved searches" border="0" alt="Saved searches" src="http://blog.jayway.com/wordpress/wp-content/uploads/2012/04/07.-saved-searches_thumb.jpg" width="224" height="371" /></a></p>
<p>The plan is to implement the same functionality for the Windows 8 client.</p>
<p>This post is a part in a series - you can find the full index <a href="http://blog.jayway.com/2012/04/04/converting-to-windows-8-from-windows-phone-introduction-1-of-12/">here</a>.</p>
<h2>The Windows Phone code</h2>
<p>Today, when persisting to Windows Phone isolated storage we use the following code.</p>
<pre class="brush: csharp; ruler: true; auto-links: false; smart-tabs: false;">protected void Save(string directory, string fileName, string data)
{
    using (var store = IsolatedStorageFile.GetUserStoreForApplication())
    {
        using (var writer = new StreamWriter(store.OpenFile(GetPath(directory, fileName), FileMode.Create)))
        {
            writer.Write(data);
        }
    }
}</pre>
<p>No magic, just simple code, but one thing to note – all is written synchronously. So if we don’t put this on a separate thread, than the UI thread, we risk freezing the UI while reading/writing data.</p>
<h2>Different types of storage</h2>
<p>Before we throw ourselves at the Windows 8 implementation, it is probably best to look a little bit closer at the different storage options that we have.</p>
<ul>
<li><strong>Local</strong><br />
Works basically the same way as the storage that we are used to when developing for Windows Phone. Persists data locally on your device and the only way for a user to remove the data is to uninstall the application. You would typically put data here that you don’t need to share between devices and data that your application depends on to work. </li>
<li><strong>Roaming</strong>Data that syncs between devices (using the users live id). Here you typically place data containing settings and preferences. This storage should not be used to store large amount of data. </li>
<li><strong>Temporary</strong>Similar to local, the difference is that there are no guarantee that this data is there when your application asks for it. The user can clean it at any time using a disc cleanup. This basically means that the application never really can count on the data being there. Perfect to use as a cache. </li>
</ul>
<p>So, in order to save our earlier searches we will use temporary storage. Thus allowing the user to clear old searches without us having to implement that functionality in our application.</p>
<h2></h2>
<h2>Implementation for Windows 8</h2>
<p>First of all, the one thing in common for all the storage types is that you access them all through Windows Runtime, compared with Windows Phone where we access storage through .NET. This means that our code will look quite different in comparison. </p>
<p>Since this is Windows 8 we got access to <strong>await</strong> and <strong>async</strong> which is good since any method call that potentially could take longer than 50ms is asynchronous in Windows Runtime.</p>
<pre class="brush: csharp; ruler: true; auto-links: false; smart-tabs: false;">public async Task SaveFile(string fileName, string content)
{
    var temporaryFolder = ApplicationData.Current.TemporaryFolder;
    var file = await temporaryFolder.CreateFileAsync(fileName, CreationCollisionOption.ReplaceExisting);          

    IRandomAccessStream writeStream = await file.OpenAsync(FileAccessMode.ReadWrite);
    IOutputStream outputStream = writeStream.GetOutputStreamAt(0);

    var dataWriter = new DataWriter(outputStream);
    dataWriter.WriteString(content);

    await dataWriter.StoreAsync();
    await outputStream.FlushAsync();
} </pre>
<p>Two thing worth mentioning here. First of all – we don’t need to use <strong>using </strong>since nothing needs to be disposed. Secondly – we do this completely asynchronously. So if we would have stored/read 5Mb JSON, this code would have been much better than the Windows Phone code. </p>
<p>Since we are using the temporary folder we also get the clear-cache-feature for free. They user doesn’t need to uninstall the application in order to clear whatever we are saving. We could, of course, have added functionality for clearing the cache in our application – but why bother if Windows 8 can do it for us?</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.jayway.com/2012/04/19/converting-to-windows-8-from-windows-phone-cache-and-working-with-storage-7-of-12/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Configuring Jasmine to work with Maven and JQuery Fixtures</title>
		<link>http://blog.jayway.com/2012/04/17/configuring-jasmine-to-work-with-maven-and-jquery-fixtures/</link>
		<comments>http://blog.jayway.com/2012/04/17/configuring-jasmine-to-work-with-maven-and-jquery-fixtures/#comments</comments>
		<pubDate>Tue, 17 Apr 2012 17:38:45 +0000</pubDate>
		<dc:creator>Johan Haleby</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Testing]]></category>
		<category><![CDATA[automated testing]]></category>
		<category><![CDATA[jasmine]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[maven]]></category>

		<guid isPermaLink="false">http://blog.jayway.com/?p=13225</guid>
		<description><![CDATA[For me unit testing Javascript has been an issue for quite a while. Our backend server usually have a lot of tests at various levels but the Javascript service and view layers have been more or less neglected in terms of automated tests. Using Selenium is one option but if your UI is subject to [...]]]></description>
			<content:encoded><![CDATA[<p>For me unit testing Javascript has been an issue for quite a while. Our backend server usually have a lot of tests at various levels but the Javascript service and view layers have been more or less neglected in terms of automated tests. Using Selenium is one option but if your UI is subject to frequent changes Selenium tests can be quite cumbersome and time consuming to use and maintain. So without any automated tests for the Javascript code you can probably guess where we end up having the most bugs? Using Java, Maven is the defacto build tool and you want your Javascript tests to integrate with Maven as smooth as possible. A requirement is also that the tests must run headless on our continous integration server and while in development mode we want to avoid restarting the container when updating our Jasmine specifications and Javascript production code.</p>
<h2>Introducing the Jasmine Maven Plugin</h2>
<p>At first glance the <a href="http://searls.github.com/jasmine-maven-plugin/">Jasmine Maven plugin</a> seem to be perfect for the job. It supports running our tests headlessly from Maven using HtmlUnit as well as from a Jetty container. It's simple to get started and you're up and running in no time:</p>
<pre class="bash">&nbsp;
mvn jasmine:bdd
&nbsp;</pre>
<p>This goal starts an embedded Jetty server that assumes that the production code is in the <code>src/main/javascript</code> folder and the Jasmine specs are in the <code>src/test/javascript</code> folder. Connect to <code>http://localhost:8234</code> and all your Jasmine specs are executed and the outcome is presented on an HTML page. This gives you a rapid turn-around time, you can simply change the Javascript code and hit refresh in the browser and the specification suite is re-executed. Nice! In my current project this almost worked out of the box. All we had to do was to change the <code>jsSrcDir</code> property in our Jasmine Maven plugin configuration in the <code>pom.xml</code> to <code>${project.basedir}/src/main/webapp/javascript</code> and we were able to run our specifications.</p>
<h2>How about headless?</h2>
<p>I was very impressed by how simple it was to get everything working using the <code>jasmine:bdd</code> goal. But when running the <code>jasmine:test</code> to exectue the specs in headless mode things did not work as smoothly:</p>
<pre class="java">&nbsp;
<span style="color: #66cc66;">&#91;</span>ERROR<span style="color: #66cc66;">&#93;</span> Failed to execute goal com.<span style="color: #006600;">github</span>.<span style="color: #006600;">searls</span>:jasmine-maven-plugin:<span style="color: #cc66cc;">1.1</span><span style="color: #cc66cc;">.0</span>:test <span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">default</span><span style="color: #66cc66;">&#41;</span> on project my-project: The jasmine-maven-plugin encountered an exception:
<span style="color: #66cc66;">&#91;</span>ERROR<span style="color: #66cc66;">&#93;</span> java.<span style="color: #006600;">lang</span>.<a href="http://www.google.com/search?hl=en&amp;q=allinurl%3ARuntimeException+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">RuntimeException</span></a>: org.<span style="color: #006600;">openqa</span>.<span style="color: #006600;">selenium</span>.<span style="color: #006600;">WebDriverException</span>: com.<span style="color: #006600;">gargoylesoftware</span>.<span style="color: #006600;">htmlunit</span>.<span style="color: #006600;">ScriptException</span>: ReferenceError: <span style="color: #ff0000;">&quot;service&quot;</span> is not defined. <span style="color: #006600;"><span style="color: #66cc66;">&#40;</span>file</span>:/home/johan/devtools/java/projects/my-project/code/target/jasmine/src/some.<span style="color: #006600;">js</span>#<span style="color: #cc66cc;">3</span><span style="color: #66cc66;">&#41;</span>
..
&nbsp;</pre>
<p>The reason is that a function called "service" couldn't be found in <code>some.js</code> which is the Javascript file we're testing. It's actually not that surprising when you think about it. When using the <code>jasmine:bdd</code> goal Jetty loads the index page of our web application automatically and thus all scripts are loaded. When running outside the container, HtmlUnit doesn't know that some functions in <code>some.js</code> depends on functions defined in other Javascript files. We need to tell Jasmine to load them before it executes these specifications. This is done by adding <code>preloadSources</code> to the Jasmine Maven plugin configuration. Let's say that the "service" function is defined in <code>x.js</code> which in turn depends on <code>y.js</code> then this is how you would configure it:</p>
<pre class="xml">&nbsp;
<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;configuration<span style="font-weight: bold; color: black;">&gt;</span></span></span>
  ..
<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;preloadSources<span style="font-weight: bold; color: black;">&gt;</span></span></span>
 	<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;include<span style="font-weight: bold; color: black;">&gt;</span></span></span>${jasmine.test.resources.folder}/y.js<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/include<span style="font-weight: bold; color: black;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;include<span style="font-weight: bold; color: black;">&gt;</span></span></span>${jasmine.test.resources.folder}/x.js<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/include<span style="font-weight: bold; color: black;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;include<span style="font-weight: bold; color: black;">&gt;</span></span></span>${jasmine.test.resources.folder}/some.js<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/include<span style="font-weight: bold; color: black;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/preloadSources<span style="font-weight: bold; color: black;">&gt;</span></span></span>
  ..
<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/configuration<span style="font-weight: bold; color: black;">&gt;</span></span></span></pre>
<p>After this change we were able to run the specs both headlessly using <code>jasmine:test</code> and inside the browser using the <code>jasmine:bdd</code> goal. Keep in mind that the order of includes in <code>preloadSources</code> are important. Also if you have cyclic dependencies between your Javascript files you will need to refactor them.</p>
<h2>Using JQuery Fixtures</h2>
<p>When testing a function that interacts with the DOM it's good to be able to provide some fixture data that can be loaded during the test. One way to do this is to use the <a href="https://github.com/velesin/jasmine-jquery">Jasmine JQuery</a> plugin. It allows you do load HTML fixtures from your test, for example:</p>
<p><b>myfixture.html</b></p>
<pre>&nbsp;
&lt;div id=&quot;fixtureId&quot;&gt;some content&lt;/div&gt;
&nbsp;</pre>
<p><b>Usage:</b></p>
<pre class="javascript">&nbsp;
loadFixtures<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'myfixture.html'</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
<span style="color: #009900; font-style: italic;">// Run test</span>
some.<span style="color: #006600;">methodToTest</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
<span style="color: #009900; font-style: italic;">// Expect that the methodToTest has modified the content in the div</span>
expect<span style="color: #66cc66;">&#40;</span>$<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'#fixtureId'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">to</span>...;
&nbsp;</pre>
<p>In Jasmie JQuery you can configure the path to where it should look for the fixtures, e.g.</p>
<pre class="javascript">&nbsp;
jasmine.<span style="color: #006600;">getFixtures</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">fixturesPath</span> = <span style="color: #3366CC;">'spec/fixtures'</span>;
&nbsp;</pre>
<p>This will intruct the plugin to look for fixtures in the <code>target/spec/fixtures</code> folder on the file system. But now we run into a problem. The reason is that the <code>jasmine:bdd</code> and <code>jasmine:test</code> goals look for resources in a different ways. When using <code>jasmine:bdd</code> the path to the folder where the fixtures are located cannot be configured to a folder on the file system. Rather it has to be a resource on Jetty server that serves out the static HTML fixture files. The <code>jasmine:test</code> on the other hand require the fixtures to be in the target folder of your Maven build. This has actually been reported as a <a href="https://github.com/searls/jasmine-maven-plugin/issues/36">bug</a> on the Jasmine Maven plugin web site.</p>
<h2>The work-around</h2>
<p>So how can we fix this? Unfortunatly there's no 100% clean solution unless you want to fork the Jasmine Maven project but as a work-around we can make use of Maven profiles. The trick is to set a different fixture path when running the <code>jasmine:test</code> and <code>jasmine:bdd</code> goal. This can be achieved by pre-loading a different script for configuring the fixture directory for each goal. Assume that we have our HTML fixtures in the <code>src/test/javascript/fixtures</code> folder on the file system then these are the two different scripts needed:</p>
<p><b>file_system_fixtures.js</b></p>
<pre class="javascript">&nbsp;
jasmine.<span style="color: #006600;">getFixtures</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">fixturesPath</span> = <span style="color: #3366CC;">'spec/fixtures'</span>;
&nbsp;</pre>
<p><b>web_resource_fixtures.js</b></p>
<pre class="javascript">&nbsp;
jasmine.<span style="color: #006600;">getFixtures</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">fixturesPath</span>= <span style="color: #3366CC;">'src/test/javascript/fixtures'</span>;
&nbsp;</pre>
<p>In our project we run <code>mvn clean install</code> (and thus run the <code>jasmine:test</code> implicitly during test execution phase) much more often than <code>jasmine:bdd</code> and for this reason it's probably better to configure the latter in a special profile. The first thing to do is to create a Maven build property that points to the <code>file_system_fixtures.js</code> file:</p>
<pre class="xml">&nbsp;
<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;properties<span style="font-weight: bold; color: black;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;jasmine</span>.test.resources.folder<span style="font-weight: bold; color: black;">&gt;</span></span>${project.basedir}/src/test/resources/jasmine<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/jasmine</span>.test.resources.folder<span style="font-weight: bold; color: black;">&gt;</span></span>
      <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;jasmine</span>.fixture.setup<span style="font-weight: bold; color: black;">&gt;</span></span>${jasmine.test.resources.folder}/jasmine_fixture_setup_test.js<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/jasmine</span>.fixture.setup<span style="font-weight: bold; color: black;">&gt;</span></span>
<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/properties<span style="font-weight: bold; color: black;">&gt;</span></span></span>
&nbsp;</pre>
<p>Secondly we alter the <code>preloadSources</code> configuration under Jasmine Maven plugin to load the Jasmine JQuery script and configure the correct fixture folder by running our <code>file_system_fixtures.js</code> script configured by the build property:</p>
<pre class="xml">&nbsp;
<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;configuration<span style="font-weight: bold; color: black;">&gt;</span></span></span>
  ..
<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;preloadSources<span style="font-weight: bold; color: black;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;include<span style="font-weight: bold; color: black;">&gt;</span></span></span>${jasmine.test.resources.folder}/jasmine-jquery-1.3.1.js<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/include<span style="font-weight: bold; color: black;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;include<span style="font-weight: bold; color: black;">&gt;</span></span></span>${jasmine.fixture.setup}<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/include<span style="font-weight: bold; color: black;">&gt;</span></span></span>
 	<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;include<span style="font-weight: bold; color: black;">&gt;</span></span></span>${jasmine.test.resources.folder}/y.js<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/include<span style="font-weight: bold; color: black;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;include<span style="font-weight: bold; color: black;">&gt;</span></span></span>${jasmine.test.resources.folder}/x.js<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/include<span style="font-weight: bold; color: black;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;include<span style="font-weight: bold; color: black;">&gt;</span></span></span>${jasmine.test.resources.folder}/some.js<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/include<span style="font-weight: bold; color: black;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/preloadSources<span style="font-weight: bold; color: black;">&gt;</span></span></span>
  ..
<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/configuration<span style="font-weight: bold; color: black;">&gt;</span></span></span>
&nbsp;</pre>
<p>Now when running <code>jasmine:test</code> the fixtures will be found on the file system but we still need to make things work for the <code>jasmine:bdd</code> goal. To solve this we create the following Maven profile:</p>
<pre class="xml">&nbsp;
<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;profiles<span style="font-weight: bold; color: black;">&gt;</span></span></span>
<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;profile<span style="font-weight: bold; color: black;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;id<span style="font-weight: bold; color: black;">&gt;</span></span></span>bdd<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/id<span style="font-weight: bold; color: black;">&gt;</span></span></span>
<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;properties<span style="font-weight: bold; color: black;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;jasmine</span>.fixture.setup<span style="font-weight: bold; color: black;">&gt;</span></span>${jasmine.test.resources.folder}/web_resource_fixtures.js<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/jasmine</span>.fixture.setup<span style="font-weight: bold; color: black;">&gt;</span></span>
    <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/properties<span style="font-weight: bold; color: black;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/profile<span style="font-weight: bold; color: black;">&gt;</span></span></span>
<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/profiles<span style="font-weight: bold; color: black;">&gt;</span></span></span>
&nbsp;</pre>
<p>What we do here is to override the <code>jasmine.fixture.setup</code> property to point to our <code>web_resource_fixtures.js</code> script which configures the Jasmine JQuery fixture folder to work in Jetty. Thus whenever you need to use <code>jasmine:bdd</code> you also need to use the <code>bdd</code> profile:</p>
<pre class="bash">&nbsp;
mvn jasmine:bdd -Pbdd
&nbsp;</pre>
<h2>Conclusion</h2>
<p>If you've read this far you've probably seen that it's not trivial to get Jasmine tests running in Maven, at least not if you want it to work in both headless mode and non-headless mode at the same time. To me this is a big obsticle when trying to convince people to start writing unit tests for Javascript code. These things simply have to work, we need the feedback from our continous integration server and it needs to be simple and fast to use during development. The work-around suggested here is not perfect but at least it's acceptable once you've configured everything. Hopefully the issue will be resolved in Jasmine Maven in the future and I also hope that this blog can lower the barrier to get started with the testing Javascript from Maven somewhat. I know that this is something that's lacking in many projects.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.jayway.com/2012/04/17/configuring-jasmine-to-work-with-maven-and-jquery-fixtures/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Introducing the Google Guava Cache</title>
		<link>http://blog.jayway.com/2012/04/16/introducing-the-google-guava-cache/</link>
		<comments>http://blog.jayway.com/2012/04/16/introducing-the-google-guava-cache/#comments</comments>
		<pubDate>Mon, 16 Apr 2012 06:40:31 +0000</pubDate>
		<dc:creator>Mikael Karlsson</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Tips & Tricks]]></category>
		<category><![CDATA[cache]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[Guava]]></category>

		<guid isPermaLink="false">http://blog.jayway.com/?p=13166</guid>
		<description><![CDATA[Google Guava is a library packed with useful stuff that can be very handy in almost any Java project, including libraries for immutable collections, functional programming, I/O and much more. I have been taking the Guava Cache library for a spin, and I will definitely have much use for it in future projects. At first [...]]]></description>
			<content:encoded><![CDATA[<p>Google Guava is a library packed with useful stuff that can be very handy in almost any Java project, including libraries for immutable collections, functional programming, I/O and much more. I have been taking the Guava Cache library for a spin, and I will definitely have much use for it in future projects.</p>
<p>At first glance, the Guava Cache doesn't look very different from the caches that you probably have written so many times in the past - a fancy Cache class on top of a HashMap with some timeout functionality. Except from now on, you don't have to reinvent the wheel. Digging a little deeper, the Guava Cache also offers different expiration behaviors, along with other features that might come in handy.</p>
<p>The Guava Cache is an incremental cache, in the sense that when you request an object from the cache, it checks to see if it already has the corresponding value for the supplied key. If it does, it simply returns it (assuming it hasn’t expired). If it doesn't already have the value, it uses a CacheLoader to fetch the value and then it stores the value in the cache and returns it. This way, the cache is growing as new values are requested.</p>
<p>The only thing you need to provide is the implementation for the abstract load method of the CacheLoader class. This is the method that is used to fetch the value to be cached. You can do this as an anonymous class, but creating a new class that extends CacheLoader is the way I prefer to do it (it's cleaner and helps when unit testing/mocking). Please note that this method is expected to never return null, or there is no way for the Cache to tell whether this record has not been fetched yet or if it’s value is just empty.</p>
<p>So let's not waste another minute - let's get our hands dirty with the Guava Cache! You will need the Guava jar file, which can be downloaded from the Guava website. Or, if you're using maven, just include this dependency in your pom:</p>
<pre>&lt;dependency&gt;
  &lt;groupId&gt;com.google.guava&lt;/groupId&gt;
  &lt;artifactId&gt;guava&lt;/artifactId&gt;
  &lt;version&gt;11.0.2&lt;/version&gt;
&lt;/dependency&gt;</pre>
<p>The next thing you need to do is to create the Cache object. Caches are created using the CacheBuilder. Let’s look at a basic example of a cache with keys of type String holding Object values:</p>
<pre class="brush: java; ruler: true; auto-links: false; smart-tabs: false;">LoadingCache&lt;String, Object&gt; cache = CacheBuilder.newBuilder()
  .build(new CacheLoader&lt;String, Object&gt;() {
     @Override public Object load(String key) throws Exception {
       return new Object();
     }
  });</pre>
<p>If we request an Object that is not yet stored in the cache, a new object is simply created by our CacheLoader object. In real life, however, you would probably be digging the value out from something like a database or perhaps a web service.</p>
<p>Using the CacheBuilder, you can specify the characteristics of the cache, like timeouts, max size and other properties. The build() method then takes your CacheLoader as the only argument.</p>
<p>In the next example we will create a cache that holds Animal objects, with a timeout of 5 minutes. This is our very basic non-fancy Animal class:</p>
<pre class="brush: java; ruler: true; auto-links: false; smart-tabs: false;">package com.jayway.guava;

public class Animal {
	private final String name;

	public Animal(String name) {
		this.name = name;
	}

	@Override
	public String toString() {
		return "Animal/" + name;
	}
}</pre>
<p>Let’s create a cache for our Animals:</p>
<pre class="brush: java; ruler: true; auto-links: false; smart-tabs: false;">LoadingCache&lt;String, Animal&gt; animalCache = CacheBuilder.newBuilder()
  .maximumSize(1000)
  .expireAfterWrite(5, TimeUnit.MINUTES) })
  .build(new AnimalCacheLoader());</pre>
<p>The maximum size of the cache is set to 1000 objects. When that limit is reached, the cache will begin to evict the objects that are not recently used (actually, the Guava Cache may start dropping objects before the maximum is reached, see <a href="http://blog.jayway.com/2012/04/16/introducing-the-google-guava-cache/#comment-79838">Kevin's comment</a> explaining this).</p>
<p>expireAfterWrite lets us decide how long a cached Animal may live, before it is considered too old and thrown away. We could also set another timeout value using the expireAfterAccess method, which tells the cache to throw away values that has not been read (or written) in a certain amount of time.</p>
<p>The AnimalCacheLoader class is the class responsible for populating the cache, and extends the abstract Guava class CacheLoader:</p>
<pre class="brush: java; ruler: true; auto-links: false; smart-tabs: false;">package com.jayway.guava;

import com.google.common.cache.CacheLoader;

public class AnimalCacheLoader extends CacheLoader&lt;String, Animal&gt; {
	@Override
	public Animal load(String key) throws Exception {
		return new Animal(key);
	}
}</pre>
<p>This is enough to make the cache work. To get an Animal from the cache, simply use the get method:</p>
<pre class="brush: java; ruler: true; auto-links: false; smart-tabs: false;">Animal animal = animalCache.get(“monkey”);
System.out.println(animal);</pre>
<p>This piece of code will print:</p>
<pre>Animal/monkey</pre>
<p>and it will place our new monkey in the cache.</p>
<p>As you can see, the Guava Cache is really simple to use, and it can save us time not having to write our own logic for the caching. And if you trust the Google Guava team enough, you don’t have to write unit tests for your cache either (but it could possibly be a good idea to write tests for your CacheLoader.load implementation).</p>
<p>The Guava Cache also has some nice statistics build in, which can be very handy if you want to know how and if your cache is really used. Just call the stats method on the cache and it will give you a nice <a href="http://docs.guava-libraries.googlecode.com/git/javadoc/com/google/common/cache/CacheStats.html">CacheStats</a> object which has all the numbers you’ll need.</p>
<p>That’s my breif introduction to the basics of the Google Guava Cache. I hope you will find it useful. Read more about Guava at <a href="http://code.google.com/p/guava-libraries/">the Guava Project Homepage</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.jayway.com/2012/04/16/introducing-the-google-guava-cache/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Converting to Windows 8 from Windows Phone &#124; Working with third party libraries and JSON (6 of 12)</title>
		<link>http://blog.jayway.com/2012/04/16/converting-to-windows-8-from-windows-phone-working-with-third-party-libraries-and-json-6-of-12/</link>
		<comments>http://blog.jayway.com/2012/04/16/converting-to-windows-8-from-windows-phone-working-with-third-party-libraries-and-json-6-of-12/#comments</comments>
		<pubDate>Mon, 16 Apr 2012 06:40:00 +0000</pubDate>
		<dc:creator>Peter von Lochow</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[metro]]></category>
		<category><![CDATA[windows 8]]></category>
		<category><![CDATA[windows phone]]></category>
		<category><![CDATA[windows phone 7]]></category>
		<category><![CDATA[xaml]]></category>

		<guid isPermaLink="false">http://blog.jayway.com/?p=13063</guid>
		<description><![CDATA[Right now, one of the big differences between Windows Phone and Windows 8 is what third party components you can use. For Windows Phone you have a huge selection of components that you can choose from to get help with anything from MVVM to animations. We used several when implementing Reseguidens sista-minuten application. One we [...]]]></description>
			<content:encoded><![CDATA[<p>Right now, one of the big differences between Windows Phone and Windows 8 is what third party components you can use. For Windows Phone you have a huge selection of components that you can choose from to get help with anything from MVVM to animations. We used several when implementing <a href="http://www.windowsphone.com/sv-SE/apps/dd415e08-2de8-431a-9c0a-b431efaa115b">Reseguidens sista-minuten</a> application. One we used quite extensively throughout the application is <a href="https://github.com/ServiceStack/ServiceStack.Text">ServiceStack.Text</a> to parse JSON.</p>
<p>If we had been lucky we would have been able to re use the same libraries in Windows 8. If we had been smart we would have isolated all third party libraries so we easily could swap them.</p>
<p>Since we where unlucky and did not isolate third party libraries properly, we are now writing a blog post about the importance of isolating external components and how to use the built in JSON parser in .NET 4.5.</p>
<p>This post is a part in a series - you can find the full index <a title="Converting to Windows 8 from Windows Phone | Introduction (1 of 12)" href="http://blog.jayway.com/2012/04/04/converting-to-windows-8-from-windows-phone-introduction-1-of-12/">here</a>.</p>
<h2>The problem</h2>
<p>To be perfectly clear – the problem is not third party components by themselves. The problem is that we end up with dependencies to libraries that is not built as a Windows 8 library. This is a problem because even if we can reference them in our project, we won’t get it accepted in Windows Marketplace.</p>
<p>In other words – it is futile to cling on to components not built for Windows 8 if you ever want to distribute your application.</p>
<h2>JSON parsing</h2>
<p>Since we cannot use the JSON parsing provided by ServiceStack.Text (since it is not built for Windows 8 ) we need to replace it with something else. Here we got three alternatives.</p>
<ol>
<li>Ignore everything we said and keep on using it as a proof of concept. We won't get any compilation error but we cannot distribute our application.</li>
<li>ServiceStack.Text is open source. Fork, modify and push.</li>
<li>Find a replacement. This is what we did – meet <a href="http://msdn.microsoft.com/en-us/library/system.json.jsonobject(v=vs.110).aspx">JsonObject</a>.</li>
</ol>
<p>JsonObject has been available as a NuGet package before but has now, much like HttpClient, merged with .NET 4.5. The big advantage of using JsonObject is that it’s similar to ServiceStack.Text in how you use it.</p>
<pre class="brush: csharp; ruler: true; auto-links: false; smart-tabs: false;">// working with ServiceStack.Text
var departures = json.ArrayObjects("departures").ConvertAll(x =&gt; new DepartureIVM(x));

// working with JsonObject
var departures = jsonObject.GetNamedArray("departures");
for (uint i = 0; i &lt; departures.Count; i++)
{
     var departure = departures.GetObjectAt(i);
     Departures.Add(new DepartureIVM(departure));
}</pre>
<p>JsonObject is perhaps somewhat chattier, but you could easily get the same syntax with som extension methods.</p>
<p>So, what did this mean for us? Well, basically to go through the entire application and replace all JSON parsing (spread through the entire application) with a Windows 8 compatible version. Not a lot of work, but a lot of time could have been saved if we would have isolated the actual JSON parsing and usage of ServiceStack.Text.</p>
<h2>Thoughts about third party components</h2>
<p>There are many, many libraries out there that you can use to enhance the user experience or the development experience when creating a Windows Phone application. You got MVVM frameworks, serialization frameworks, Silverlight toolkit, cache frameworks and many more. They all add something (also complexity and another layer of abstraction), but they can also get in the way when porting your Windows Phone application to Windows 8.</p>
<p>If we, for example, had choose to use a MVVM framework, and then not been able to find a Windows 8 compatible version, we would have been stuck with a lot of unusable code that we would have to rewrite completely before migrating.</p>
<p>We are all in agreement that you really should try to limit the amount of frameworks you add to a Windows Phone project. Usually, you can manage just as well without them. Often it is even better to write a couple of lines by yourself to get the exact functionality that you need instead of adding a framework that kind of give you that functionality. The risk that you eventually might need to work around your almost-perfect-framework (or get in trouble when converting to Windows 8…) is too big to never reinvent the wheel.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.jayway.com/2012/04/16/converting-to-windows-8-from-windows-phone-working-with-third-party-libraries-and-json-6-of-12/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Converting to Windows 8 from Windows Phone &#124; HttpClient vs. HttpWebRequest (5 of 12)</title>
		<link>http://blog.jayway.com/2012/04/12/converting-to-windows-8-from-windows-phone-httpclient-vs-httpwebrequest-5-of-12/</link>
		<comments>http://blog.jayway.com/2012/04/12/converting-to-windows-8-from-windows-phone-httpclient-vs-httpwebrequest-5-of-12/#comments</comments>
		<pubDate>Thu, 12 Apr 2012 06:35:00 +0000</pubDate>
		<dc:creator>Peter von Lochow</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[metro]]></category>
		<category><![CDATA[windows 8]]></category>
		<category><![CDATA[windows phone]]></category>
		<category><![CDATA[windows phone 7]]></category>
		<category><![CDATA[xaml]]></category>

		<guid isPermaLink="false">http://blog.jayway.com/?p=12932</guid>
		<description><![CDATA[Just to be clear, this is not a necessary step for us to take in our conversion process. But it’s a step that spreads some light on some of the differences regarding how you write code for Windows Phone and Windows 8. You can even say that it will show how much easier life gets [...]]]></description>
			<content:encoded><![CDATA[<p>Just to be clear, this is not a necessary step for us to take in our conversion process. But it’s a step that spreads some light on some of the differences regarding how you write code for Windows Phone and Windows 8. You can even say that it will show how much easier life gets with C#5 and .NET 4.5.</p>
<p>We’ll take a look a the heart of the application – where the data is fetched from the server. Usually, I prefer to do a web request using <a href="http://msdn.microsoft.com/en-us/library/system.net.httpwebrequest.aspx">HttpWebRequest</a> instead of <a href="http://msdn.microsoft.com/en-us/library/system.net.webclient.aspx">WebClient</a>. Mostly because a callback from a HttpWebRequest is not executed on the UI thread (explained <a href="http://blog.jayway.com/2012/01/18/webclientwebrequest-threading-untangled/">here</a> by Andreas). This gives us the opportunity to do some heavy lifting on a background thread (such as parsing JSON or XML) not ruining the user experience.</p>
<p>But now – the much loved HttpWebRequest, must step aside for HttpClient that came with .NET 4.5.</p>
<p>This post is a part in a series - you can find the full index <a title="Converting to Windows 8 from Windows Phone | Introduction (1 of 12)" href="http://blog.jayway.com/2012/04/04/converting-to-windows-8-from-windows-phone-introduction-1-of-12/">here</a>.</p>
<h2>Using HttpWebRequest</h2>
<p>This code is more or less directly copied from our Windows Phone application. As you can see we do a simple web request.</p>
<pre class="brush: csharp; ruler: true; auto-links: false; smart-tabs: false;">public void DownloadData(string url, Action&lt;JsonObject&gt; handleResponse, Action&lt;Exception&gt; handleException)
{
    var httpWebRequest = WebRequest.CreateHttp(url);
    var requestContext = new RequestContext(handleResponse, handleException, httpWebRequest);
    httpWebRequest.BeginGetResponse(RequestCompleted, requestContext);
}

private void RequestCompleted(IAsyncResult result)
{
    var requestContext = (RequestContext)result.AsyncState;
    try
    {
        var httpWebRequest = requestContext.Request;
        using (var webResponse = httpWebRequest.EndGetResponse(result))
        {
            using (var reader = new StreamReader(webResponse.GetResponseStream()))
            {
                var jsonObject = JsonObject.Parse(reader.ReadToEnd());
                Dispatch.ToUiThread(() =&gt; requestContext.HandleResponse(jsonObject));
            }
        }
    }
    catch (Exception e)
    {
        Dispatch.ToUiThread(() =&gt; requestContext.HandleException(e));
    }
}</pre>
<p>We also send in two actions with the request, that handles either a successful response or a failure. This pattern has worked well for us, but as you can see the code is quite messy. Much of that comes from having to handle the callback (and it gets even worse if we want to do a POST) in a different method.</p>
<h2>Using HttpClient</h2>
<p>One big reason that <a href="http://msdn.microsoft.com/en-us/library/system.net.http.httpclient(v=vs.110).aspx">HttpClient</a> is so nice to use has actually more to do with language features than HttpClient itself. Let’s take a look on how we can rewrite or web request using HttpClient, <strong>async</strong> and <strong>await</strong>.</p>
<pre class="brush: csharp; ruler: true; auto-links: false; smart-tabs: false;">public async Task&lt;JsonObject&gt; GetAsync(string uri)
{
    var httpClient = new HttpClient();
    var response = await httpClient.GetAsync(uri);

    response.EnsureSuccessStatusCode();

    string content = await response.Content.ReadAsStringAsync();
    return await Task.Run(() =&gt; JsonObject.Parse(content));
}</pre>
<p>Much nicer isn’t it? We can still do everything that we could do before, the difference is that we can get rid of the callback thus making the code more readable. In fact, we can make it even slimmer!</p>
<pre class="brush: csharp; ruler: true; auto-links: false; smart-tabs: false;">public async Task&lt;JsonObject&gt; GetAsync(string uri)
{
    var httpClient = new HttpClient();
    var content = await httpClient.GetStringAsync(uri);
    return await Task.Run(() =&gt; JsonObject.Parse(content));
}</pre>
<p>Very nice indeed. So we have actually replace two methods and 20 lines of code with a single method with 3 lines of code. It’s stuff like this that makes it hard to keep a common codebase between Windows Phone 7 and Windows 8. There are just too many goodies in Windows 8 that you want to use.</p>
<h2>Thoughts</h2>
<p>We think that  it’s ok to just go wild and do any changes to you want in your Windows 8 project. You can just ignore that it looks different from your Windows Phone project. Later, when Windows Phone 8 arrives you already have a solid foundation that you can re-use when updating your Windows Phone application.</p>
<p>So don’t be afraid of refactoring and improving your existing code. You’ll be able to use it later on.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.jayway.com/2012/04/12/converting-to-windows-8-from-windows-phone-httpclient-vs-httpwebrequest-5-of-12/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Working with expectations &#8211; Software quality characteristics game</title>
		<link>http://blog.jayway.com/2012/04/10/working-with-expectations-software-quality-characteristics-game/</link>
		<comments>http://blog.jayway.com/2012/04/10/working-with-expectations-software-quality-characteristics-game/#comments</comments>
		<pubDate>Tue, 10 Apr 2012 21:56:15 +0000</pubDate>
		<dc:creator>Sigurdur Birgisson</dc:creator>
				<category><![CDATA[Testing]]></category>
		<category><![CDATA[Tips & Tricks]]></category>
		<category><![CDATA[games]]></category>
		<category><![CDATA[software quality characteristics]]></category>
		<category><![CDATA[tools]]></category>

		<guid isPermaLink="false">http://blog.jayway.com/?p=13082</guid>
		<description><![CDATA[When working with our mission of creating an organization wide test strategy I was thinking about quality related problems we have in some projects. I realized that the expected quality is not explicitly stated anywhere. This means neither customer nor development team are aligned about which level of quality is expected to be delivered when [...]]]></description>
			<content:encoded><![CDATA[<p>When working with our mission of creating an <a href="http://blog.jayway.com/2011/12/01/organization-wide-test-strategy-step1-deriving-our-quality-values/">organization wide test strategy</a> I was thinking about quality related problems we have in some projects. I realized that the expected quality is not explicitly stated anywhere. This means neither customer nor development team are aligned about which level of quality is expected to be delivered when done. I needed something to achieve a better awareness of quality requirements and a light weight way of stating them explicitly.<span id="more-13082"></span></p>
<p>I wanted</p>
<ul>
<li>     a solution that would fit into all of our different projects in my organization</li>
<li>     something that when applied works in a proactive way with quality</li>
<li>     an easy to use tool for development teams to work with customers about quality</li>
</ul>
<p>&nbsp;</p>
<h2>Working with already existing work</h2>
<p>I already knew about <a href="http://www.satisfice.com/tools/satisfice-tsm-4p.pdf" target="_blank">James Bachs Heuristic Test Strategy Model</a>, and thought I would use that as a starting point. Or actually, my starting point was the <a href="http://thetesteye.com/blog/2011/11/software-quality-characteristics-1-1/" target="_blank">Software Quality Characteristics created by TheTestEye</a> which are originally inspired by James' model. When I later came back to HTSM I realized thats what I was working with as well. Let me explain.</p>
<p>I want to align expectations on quality before development, thus before any quality can be perceived. What I actually want to do within HTSM is to optimize Quality Criteria work for successful delivery. Project environment will briefly be the same in our different projects, thus these parts will not be a part of this exercise. Product elements are usually discussed about just before being developed, and later on I will show how these will be affected by our game. The derived test techniques is something that the team will be able to make decisions on when knowing about the inputs, where Quality Criteria is an important part.</p>
<h2>Playing games with Software quality criteria</h2>
<p>Quality is a complex thing. To ease the conversation we will talk about the quality criteria, as referred to by James as:<br />
<em>A quality criterion is some requirement that defines what the product should be. By considering different criteria, you will be better able to plan tests that discover important problems fast.</em></p>
<p>Thus, I take the <a href="http://thetesteye.com/blog/2011/11/software-quality-characteristics-1-1/" target="_blank">Software Quality Characteristics</a> and work on them as they would have been requirements. In agile and in my organization we call them user stories or just stories. I print them separately on bigger index cards with the main title and context question a little bigger than the sub-characteristics. <a href="https://docs.google.com/open?id=0B7Uj_b0Dkk50emg0XzlnQjd1TG8">Find the index cards here</a>.</p>
<p>Then I play the <a href="http://innovationgames.com/2020-vision/" target="_blank">20/20 vision innovation game</a> (by Luke Hohmann) with the customer, regarding the quality of the product. I explain to them that we all of course value quality highly, but as with anything there needs to be some sort of prioritization. This will enable the team even more , since they will know what type of quality matters when delivering their stories. The result will be a prioritized list which explicitly states which types of quality matter the most to the business stakeholders.</p>

<a href='http://blog.jayway.com/2012/04/10/working-with-expectations-software-quality-characteristics-game/img_0775/' title='Quality characteristics index cards'><img width="150" height="150" src="http://blog.jayway.com/wordpress/wp-content/uploads/2012/04/IMG_0775-e1334093859260-150x150.jpg" class="attachment-thumbnail" alt="Quality characteristics index cards" title="Quality characteristics index cards" /></a>
<a href='http://blog.jayway.com/2012/04/10/working-with-expectations-software-quality-characteristics-game/img_0779/' title='Prioritized quality characteristics'><img width="150" height="150" src="http://blog.jayway.com/wordpress/wp-content/uploads/2012/04/IMG_0779-e1334093718650-150x150.jpg" class="attachment-thumbnail" alt="Prioritized quality characteristics" title="Prioritized quality characteristics" /></a>

<h2>Value gained</h2>
<p>Now I have a common ground to build on when I want to work with quality in our projects. The abstract word of quality has been over bridged with the acknowledged set of quality characteristics that explain themselves with the understandable questions attached.</p>
<p>The tool works in our projects in a proactive way, since it is possible to apply regardless of the project/product context before any development work is done. However it needs to be applied after some common understanding of scope has been reached.</p>
<p>Nothing extra is needed to use this tool, except for the things that is anyway required in our projects like an open minded and active customer and development team.</p>
<h2>Real value</h2>
<p>The real value in this is not really the prioritized list of quality characteristics. Its the gained discussion on what is important for the customer, that matters. For example, imagine this exercise done when having a project scope of derived user stories but before much effort has been done in development. When speaking about security as quality, it really sounds differently in a customers mind than when talking about the "Use https" story. Then at least there was such a story, but maybe not prioritized high enough. If there is no such story, then maybe it needs to be added before doing anything else. What we are doing is actually taking the discussion about scope from a completely different angle than people are used to, which will give interesting results.</p>
<h2>Different viewpoints</h2>
<p>Of course I already have some ways in mind to alter this approach.</p>
<h3>Prioritization strategy</h3>
<p>The 20/20 vision suits well when there is not very many people working on the same set. A colleague of mine pointed this out as a weakness of the tool. If there are more people that should be involved then maybe a partitioning or dotting game would be more suitable. However, since we want to play this game with the people that matter it really has to be a small group of people. If not only THE one person that matters. But of course, if there is a better way to get the prioritization done with the gained discussion being constructive.</p>
<h3>Product contexts</h3>
<p>There could be certain areas in the product that you are developing that are very different in context, for example if there is an enterprise back-end integration and then having mobile clients. Then you would want to differentiate these by creating separate lists for these, one for the back-end and one for the iOS and Android apps respectively. Why would you separate the two client apps? Logic behind business decisions like this is not trivial, but an example would be that the business strategy suggests the iOS app needs to be launched first with an astounding success while the Android app needs to fill the needs for the early adopters that dont have iOS devices. This app maybe does not need the same type of stability focus as the iOS app, but with more options for compatibility in the fragmented Android domain.</p>
<h3>Story or feature level quality characteristics</h3>
<p>Some stories or features are more important or bigger (or whatever more) than others. If this is the case and there are uncertainties regarding the quality expected at delivery it might be useful to take out the quality characteristics index cards to facilitate a customer discussion around the quality. It does not have to take very long for either side to realize where the solution needs to be cut.</p>
<h3>Breaking quality stories into pieces</h3>
<p>People will have a hard time prioritizing, that is to be expected. Some parts of a certain quality may be more important than the rest of it and some other quality. I think it should be preceded with awareness, but you might in some cases want to break away a sub-quality from its index card to enable the discussion to go forward to completeness instead of a stale.</p>
<h3>Internal and external quality characteristics</h3>
<p>Depending on the context it could be important to blend internal and external quality. However, I think it might be important to have them separated in the discussions. I suspect that in our projects we will probably most of the time need to have them separate.</p>
<h2>Discussion</h2>
<p>It should be noted that I have not tried the approach on many projects just yet. My colleagues that I shared the idea with have first been suspicious to it, but then mostly come to the conclusion that it might be an easy way of getting to the right discussion with our clients regarding quality.<br />
I tried it with two different stakeholders in my current project, although not /the one that matters most/. They both had their views on the quality needed, but the prioritization game actually got them to talk to me about quality in a more understandable way. Or actually, by getting them to express their needs in their own words, I could translate the general wordings of quality characteristics to the project context. That way we got on the same page of expectations on quality.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.jayway.com/2012/04/10/working-with-expectations-software-quality-characteristics-game/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Converting to Windows 8 from Windows Phone &#124; XAML has a new home (4 of 12)</title>
		<link>http://blog.jayway.com/2012/04/10/converting-to-windows-8-from-windows-phone-xaml-has-a-new-home-4-of-12/</link>
		<comments>http://blog.jayway.com/2012/04/10/converting-to-windows-8-from-windows-phone-xaml-has-a-new-home-4-of-12/#comments</comments>
		<pubDate>Tue, 10 Apr 2012 07:40:06 +0000</pubDate>
		<dc:creator>Peter von Lochow</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[metro]]></category>
		<category><![CDATA[windows 8]]></category>
		<category><![CDATA[windows phone]]></category>
		<category><![CDATA[windows phone 7]]></category>
		<category><![CDATA[xaml]]></category>

		<guid isPermaLink="false">http://blog.jayway.com/?p=12904</guid>
		<description><![CDATA[The perhaps most obvious difference between Windows Phone and Windows 8 is that XAML is no longer a part of .NET in Windows 8. The reason for it being so obvious is that all references to System.Windows breaks the build. Simply put – XAML now resides in Windows Runtime instead of .NET. The problem is [...]]]></description>
			<content:encoded><![CDATA[<p>The perhaps most obvious difference between Windows Phone and Windows 8 is that XAML is no longer a part of .NET in Windows 8. The reason for it being so obvious is that all references to System.Windows breaks the build. Simply put – XAML now resides in Windows Runtime instead of .NET.</p>
<p>The problem is quite easy to fix. In this post we will discuss why XAML has moved and how you deal with it.</p>
<p>This post is a part in a series - you can find the full index <a title="Converting to Windows 8 from Windows Phone | Introduction (1 of 12)" href="http://blog.jayway.com/2012/04/04/converting-to-windows-8-from-windows-phone-introduction-1-of-12/">here</a>.</p>
<h2>Why move it?</h2>
<p>In order to understand why they have made the trouble to move XAML I think that we first need to look at all languages and technologies that can be used building Windows 8 metro applications.</p>
<ul>
<li>HTML 5 and Javascript</li>
<li>XAML and C++</li>
<li>XAML and VB.NET/C#</li>
</ul>
<p>So – you can use any of these to build metro applications and they all got in common that they use Windows Runtime to access native functionality in Windows 8. Since all got Windows Runtime in common it could be a good idea to place common functionality there as well, for example how to define the UI. So by moving XAML (and HTML 5) into Windows Runtime it is possible for both C++ and VB.NET/C# to use the same XAML library. Something that was not possible as long as XAML was a part of .NET and was compiled to IL code.</p>
<p>So what does this mean for us? Very little it turns out. Basically all XAML that we are used to in .NET are available in Windows Runtime. All that we really need to do is to switch namespace.</p>
<h2>Solution</h2>
<p>As I mentioned earlier – there is no big deal to correct the compilation errors that occurs when moving all of our code to Windows 8. Here is a list showing the namespaces in .NET and Windows Runtime.</p>
<table width="621" border="0" cellspacing="0" cellpadding="2">
<tbody>
<tr>
<td valign="top" width="313"><span style="font-family: Consolas;"><strong>System.Windows</strong></span><br />
<span style="font-family: Consolas;"><strong>System.Windows</strong>.Automation<br />
<strong>System.Windows</strong>.Automation.Peers<br />
<strong>System.Windows</strong>.Automation.Provider<br />
<strong>System.Windows</strong>.Automation.Text<br />
<strong>System.Windows</strong>.Controls<br />
<strong>System.Windows</strong>.Controls.Primitives<br />
<strong>System.Windows</strong>.Data<br />
<strong>System.Windows</strong>.Documents<br />
<strong>System.Windows</strong>.Input<br />
<strong>System.Windows</strong>.Interop<br />
<strong>System.Windows</strong>.Markup<br />
<strong>System.Windows</strong>.Media<br />
<strong>System.Windows</strong>.Media.Animation<br />
<strong>System.Windows</strong>.Media.Imaging<br />
<strong>System.Windows</strong>.Media.Media3D<br />
<strong>System.Windows</strong>.Navigation<br />
<strong>System.Windows</strong>.Printing<br />
<strong>System.Windows</strong>.Resources<br />
<strong>System.Windows</strong>.Shapes</span></td>
<td valign="top" width="306"><span style="font-family: Consolas;"><strong>Windows.UI.Xaml</strong><br />
<strong>Windows.UI.Xaml</strong>.Automation<br />
<strong>Windows.UI.Xaml</strong>.Automation.Peers<br />
<strong>Windows.UI.Xaml</strong>.Automation.Provider<br />
<strong>Windows.UI.Xaml</strong>.Automation.Text<br />
<strong>Windows.UI.Xaml</strong>.Controls<br />
<strong>Windows.UI.Xaml</strong>.Controls.Primitives<br />
<strong>Windows.UI.Xaml</strong>.Data<br />
<strong>Windows.UI.Xaml</strong>.Documents<br />
<strong>Windows.UI.Xaml</strong>.Input<br />
<strong>Windows.UI.Xaml</strong>.Interop<br />
<strong>Windows.UI.Xaml</strong>.Markup<br />
<strong>Windows.UI.Xaml</strong>.Media<br />
<strong>Windows.UI.Xaml</strong>.Media.Animation<br />
<strong>Windows.UI.Xaml</strong>.Media.Imaging<br />
<strong>Windows.UI.Xaml</strong>.Media.Media3D<br />
<strong>Windows.UI.Xaml</strong>.Navigation<br />
<strong>Windows.UI.Xaml</strong>.Printing<br />
<strong>Windows.UI.Xaml</strong>.Resources<br />
<strong>Windows.UI.Xaml</strong>.Shapes</span></td>
</tr>
</tbody>
</table>
<p>&nbsp;</p>
<p>As you can see it is quite obvious what needs to be done (feel free to optimize by using Ctrl + Shift + F,H).</p>
<p><a href="http://blog.jayway.com/wordpress/wp-content/uploads/2012/04/change-namespace.png" rel="lightbox"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: block; float: none; margin-left: auto; margin-right: auto; padding-top: 0px; border: 0px;" title="Change namespace" src="http://blog.jayway.com/wordpress/wp-content/uploads/2012/04/change-namespace_thumb.png" alt="Change namespace" width="253" height="356" border="0" /></a></p>
<p>That is all.</p>
<p>This is, of course, one of the simpler fixes that you need to do (and that you cannot escape) while converting to Windows 8. Look at it as a warm up for the issues further ahead.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.jayway.com/2012/04/10/converting-to-windows-8-from-windows-phone-xaml-has-a-new-home-4-of-12/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

