<?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>Johan Brook &#187; Development</title>
	<atom:link href="http://johanbrook.com/development/feed/" rel="self" type="application/rss+xml" />
	<link>http://johanbrook.com</link>
	<description>is a designer and developer with taste</description>
	<lastBuildDate>Tue, 12 Mar 2013 17:09:33 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<item>
		<title>Programming and communication</title>
		<link>http://johanbrook.com/development/programming-communication/</link>
		<comments>http://johanbrook.com/development/programming-communication/#comments</comments>
		<pubDate>Tue, 12 Mar 2013 17:09:33 +0000</pubDate>
		<dc:creator>Johan</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[communication]]></category>
		<category><![CDATA[Documentation]]></category>
		<category><![CDATA[joel spolsky]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[quote]]></category>

		<guid isPermaLink="false">http://johanbrook.com/?p=1513</guid>
		<description><![CDATA[The difference between a tolerable programmer and a great programmer is not how many programming languages they know, and it’s not whether they prefer Python or Java. It’s whether they can communicate their ideas. By writing clear comments and technical specs, they let other programmers understand their code, which means other programmers can use and work with their code instead of rewriting it. Absent this, their code is worthless. By writing clear technical documentation for end users, they allow people to figure out what their code is supposed to do, which is the only way those users can see the value in their code. Joel Spolsky]]></description>
				<content:encoded><![CDATA[<blockquote><p>
The difference between a tolerable programmer and a great programmer is not how many programming languages they know, and it’s not whether they prefer Python or Java. It’s whether they can communicate their ideas. By writing clear comments and technical specs, they let other programmers understand their code, which means other programmers can use and work with their code instead of rewriting it. Absent this, their code is worthless. By writing clear technical documentation for end users, they allow people to figure out what their code is supposed to do, which is the only way those users can see the value in their code.</p>
<footer>Joel Spolsky</footer>
</blockquote>
]]></content:encoded>
			<wfw:commentRss>http://johanbrook.com/development/programming-communication/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Tags and class names – on building flexible markup</title>
		<link>http://johanbrook.com/development/html/flexible-markup/</link>
		<comments>http://johanbrook.com/development/html/flexible-markup/#comments</comments>
		<pubDate>Mon, 11 Mar 2013 08:14:43 +0000</pubDate>
		<dc:creator>Johan</dc:creator>
				<category><![CDATA[HTML]]></category>
		<category><![CDATA[class names]]></category>
		<category><![CDATA[classes]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[Markup]]></category>
		<category><![CDATA[semantic]]></category>

		<guid isPermaLink="false">http://johanbrook.com/?p=1502</guid>
		<description><![CDATA[It is said your markup should be clean and semantic. What does that mean, exactly? As few tags as possible? The correct tags for the job? Few or no ID and class attributes? At least that&#8217;s been the main formula for a while now. Littering ID and class attributes over your markup has been frowned upon. But what does the alternative mean? During my years of coding HTML I&#8217;ve done some bad things. Some really bad things, man. I&#8217;ve coded myself into corners, made huge refactors, and so on. One of the main issues I&#8217;ve seen is that the HTML hasn&#8217;t been flexible enough. I&#8217;ve made my markup and styling too tightly coupled. Sadly, one of the factors of that has been my urge &#8230; <p class="read-more-container"><a class="read-more" href="http://johanbrook.com/development/html/flexible-markup/">Read more →</a></p>]]></description>
				<content:encoded><![CDATA[<p><strong>It is said your markup</strong> should be <em>clean</em> and <em>semantic</em>. What does that mean, exactly? As few tags as possible? The correct tags for the job? Few or no ID and class attributes? At least that&#8217;s been the main formula for a while now. Littering ID and class attributes over your markup has been frowned upon. But what does the alternative mean?</p>
<p>During my years of coding HTML I&#8217;ve done some bad things. Some really bad things, man. I&#8217;ve coded myself into corners, made huge refactors, and so on. One of the main issues I&#8217;ve seen is that the HTML hasn&#8217;t been <strong>flexible</strong> enough. I&#8217;ve made my markup and styling <em>too tightly coupled</em>. Sadly, one of the factors of that has been my urge to do clean and semantic HTML with few attributes on my tags. Changing one thing made me to changes in another place as well. Not DRY.</p>
<p>An example. Here&#8217;s a box for author information in the bottom of a blog post.</p>
<pre><code>&lt;footer&gt;
	&lt;h2&gt;Joe Doe&lt;/h2&gt;

	&lt;img src=&quot;avatar-joe.jpg&quot; alt=&quot;Joe&quot; /&gt;

	&lt;p&gt;
One morning, when Gregor Samsa woke from troubled dreams, he found himself transformed in his bed into a horrible vermin. He lay on his armour-like back, and if he lifted his head a little he could see his brown belly, slightly domed and divided by arches into stiff sections.
	&lt;/p&gt;
	
&lt;/footer&gt;</code></pre>
<p>Minimal but good example of clean HTML. But a bit naïve. How would you style the image avatar in CSS? Piece of cake (assuming the <code>footer</code> element is in an <code>article</code>):</p>
<pre><code>article footer img {
	float: left;
}</code></pre>
<p>Okay. But say you wrap the <code>img</code> tag in a <code>figure</code> for example? Then your styling perhaps doesn&#8217;t behave as expected. If you add more images in the box, weird stuff may happen as well.</p>
<p>The author description (in the <code>p</code> tag) is interesting too. I&#8217;ve made this example minimal, but now the text is wrapped in a single paragraph tag. But what if you need more paragraphs? Other elements in the description? Then some refactorings has to be made.</p>
<pre><code>&lt;footer class=&quot;post-author&quot;&gt;
	&lt;h2&gt;Joe Doe&lt;/h2&gt;

	&lt;figure class=&quot;author-avatar&quot;&gt;	
		&lt;img src=&quot;avatar-joe.jpg&quot; alt=&quot;Joe&quot; /&gt;
	&lt;/figure&gt;

	&lt;div class=&quot;author-bio&quot;&gt;
		&lt;p&gt;
			One morning, when Gregor Samsa woke from troubled dreams, he found himself transformed in his bed into a horrible vermin. He lay on his armour-like back, and if he lifted his head a little he could see his brown belly, slightly domed and divided by arches into stiff sections.
		&lt;/p&gt;
	&lt;/div&gt;
&lt;/footer&gt;</code></pre>
<p>Above you see the markup I would write. Notice the additional <code>class</code> attributes and the <code>div</code> element wrapper.</p>
<h2>But why, oh why?</h2>
<p>Because it lets me write <strong>more robust, flexible and portable HTML</strong>. In my CSS, I don&#8217;t rely on element tags (which may change during time). As long as I don&#8217;t nest the styling too far, my markup will stay the same if I decide to alter the HTML structure (which as you know always happens). </p>
<p>In a way, this is what the idea about the roles of HTML and CSS is all about. Remember the markup is for presentation, structure? And CSS is for styling? So why would the presentation and styling be dependent on each other? With <code>class</code> hooks, the CSS is able to keep a reference to the elements in the markup in a much more reliable way than only doing element hooks. It&#8217;s tricky to write super clean HTML for small sites, and close to impossible for larger sites, with content and HTML spitted out from a CMS or whatever. It&#8217;s your task as a web developer to make your markup and styling go nice together, living in harmony, and using each others&#8217; strengths. I usually keep the mantras <em>modular, re-usable, generalized</em> close to mind.</p>
<p>Classes in your markup is fine. Just don&#8217;t abuse it, keep a sane balance. It&#8217;s like in sex: if it feels good, it&#8217;s probably totally okay to do.</p>
]]></content:encoded>
			<wfw:commentRss>http://johanbrook.com/development/html/flexible-markup/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Object-oriented Programming and Modeling the Real World</title>
		<link>http://johanbrook.com/development/oop-modeling/</link>
		<comments>http://johanbrook.com/development/oop-modeling/#comments</comments>
		<pubDate>Thu, 07 Mar 2013 09:40:16 +0000</pubDate>
		<dc:creator>Johan</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[abstraction]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[domain model]]></category>
		<category><![CDATA[inheritance]]></category>
		<category><![CDATA[Modeling]]></category>
		<category><![CDATA[OOP]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://johanbrook.com/?p=1498</guid>
		<description><![CDATA[Almost everybody begins OOP with this misconception &#8211; objects in real world directly map to OOP objects. Its maybe a good place to start but how many grow up from the initial simplistic rule &#8211; map nouns in requirements to classes. So, you end up with objects that don&#8217;t really mean anything and don&#8217;t do much. Naive use of UML diagrams also leads to this. Discovering abstractions is tricky. One needs to really live with requirements inside out before they present themselves. From a Hacker News comment on this story about Clojure programming. I&#8217;ve seen this myself in school, where we&#8217;ve gone through endless examples of OOP where the classes were a Ball, a Car, a Zebra, or other overused objects &#8230; <p class="read-more-container"><a class="read-more" href="http://johanbrook.com/development/oop-modeling/">Read more →</a></p><p><a href='http://johanbrook.com/development/oop-modeling/' title='permalink'>★ Permalink</a></p>
]]></description>
				<content:encoded><![CDATA[<blockquote><p>Almost everybody begins OOP with this misconception &#8211; objects in real world directly map to OOP objects. Its maybe a good place to start but how many grow up from the initial simplistic rule &#8211; map nouns in requirements to classes. So, you end up with objects that don&#8217;t really mean anything and don&#8217;t do much. Naive use of UML diagrams also leads to this. Discovering abstractions is tricky. One needs to really live with requirements inside out before they present themselves.</p></blockquote>
<p>From a <a href="http://news.ycombinator.com/item?id=5336588">Hacker News comment</a> on <a href="http://www.lispcast.com/java-learn-from-clojure?utm_source=dlvr.it&amp;utm_medium=twitter">this story about Clojure programming</a>. I&#8217;ve seen this myself in school, where we&#8217;ve gone through endless examples of OOP where the classes were a Ball, a Car, a Zebra, or other overused objects in the real world. The thing is, most programming isn&#8217;t about modeling the real world, <em>our</em> world. When writing code you&#8217;re free to do things your way, not being tied to the constraints of the real world thinking.</p>
<p><strong>When we were doing</strong> our first large programming project (which was an awesome 2D game: <a href="http://beta.johanbrook.com/medioqre/">&#8220;Frank the Tank&#8221;</a>), we went straight ahead with a semi-naïve approach when doing the initial domain model. As we went on, more models were thrown in in order to accomodate all possible requirements we had set up. All models were real world things a regular person could understand (&#8220;Player, Enemy, MachineGun&#8221;, etc.). Later on in the modeling stage we started to realize things weren&#8217;t right. We had represented reality in too fine grained detail, and started to rethink our model from a <em>computational</em> perspective. Thinking in high-level abstractions, working with sensible inheritance and interfaces, we started to re-implement everything the way it should be done in a computer game. It worked very well.</p>
<p>Don&#8217;t adhere to everything the professors in university says. Then you&#8217;ll hit a brick wall later on, when you realize the computer&#8217;s reality isn&#8217;t a mirror of your own.</p>
<p><a href='http://johanbrook.com/development/oop-modeling/' title='permalink'>★ Permalink</a></p>
]]></content:encoded>
			<wfw:commentRss>http://johanbrook.com/development/oop-modeling/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>→ &#8220;Learnable Programming&#8221;</title>
		<link>http://worrydream.com/LearnableProgramming/</link>
		<comments>http://johanbrook.com/development/learnable-programming/#comments</comments>
		<pubDate>Tue, 23 Oct 2012 09:00:55 +0000</pubDate>
		<dc:creator>Johan</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[education]]></category>
		<category><![CDATA[learn]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[teach]]></category>

		<guid isPermaLink="false">http://johanbrook.com/?p=1452</guid>
		<description><![CDATA[Programming is a way of thinking, not a rote skill. Learning about &#8220;for&#8221; loops is not learning to program, any more than learning about pencils is learning to draw. Bret Victor&#8217;s essay on &#8220;Learnable Programming&#8221; is a really solid piece on how improvements can be made when creating tools and techniques to learn how to program. I love the amount of detail and work he&#8217;s put down in the article. It&#8217;s not a secret that Victor has huge insights in this area – I&#8217;m especially fond of his Tangle Javascript library and the article &#8220;Ladder of Abstraction&#8221;. During the past month at university, I&#8217;ve acted as a help teacher in the beginner programming course (&#8220;Object Oriented Programming using Java&#8221;). I&#8217;ve &#8230; <p class="read-more-container"><a class="read-more" href="http://johanbrook.com/development/learnable-programming/">Read more →</a></p><p><a href='http://johanbrook.com/development/learnable-programming/' title='permalink'>★ Permalink</a></p>
]]></description>
				<content:encoded><![CDATA[<blockquote><p>Programming is a way of thinking, not a rote skill. Learning about &#8220;for&#8221; loops is not learning to program, any more than learning about pencils is learning to draw.</p></blockquote>
<p>Bret Victor&#8217;s essay on &#8220;Learnable Programming&#8221; is a really solid piece on how improvements can be made when creating tools and techniques to learn how to program. I love the amount of detail and work he&#8217;s put down in the article. It&#8217;s not a secret that Victor has huge insights in this area – I&#8217;m especially fond of his <a href="http://worrydream.com/Tangle/">Tangle Javascript library</a> and the article <a href="http://worrydream.com/LadderOfAbstraction/">&#8220;Ladder of Abstraction&#8221;</a>. </p>
<p>During the past month at university, I&#8217;ve acted as a help teacher in the beginner programming course (&#8220;Object Oriented Programming using Java&#8221;). I&#8217;ve tried to push for a more wider understanding for programming: that the students should learn how to <em>think</em> programming – not just how to create a while-loop in Java. Far too many times I&#8217;ve seen the students get stuck on petty concepts in Java which isn&#8217;t relevant at all in the big plan. The tools to learn are often embarrassingly outdated and weak, and many fail the course. Programming and computer science is a new branch in education – it&#8217;s time to start developing modern techniques for teaching it more efficiently. </p>
<p><a href='http://johanbrook.com/development/learnable-programming/' title='permalink'>★ Permalink</a></p>
]]></content:encoded>
			<wfw:commentRss>http://johanbrook.com/development/learnable-programming/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>→ Linus Torvalds on good programmers</title>
		<link>http://programmers.stackexchange.com/questions/163185/torvalds-quote-about-good-programmer</link>
		<comments>http://johanbrook.com/development/good-programmers/#comments</comments>
		<pubDate>Sun, 23 Sep 2012 19:29:59 +0000</pubDate>
		<dc:creator>Johan</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[content]]></category>
		<category><![CDATA[data structures]]></category>
		<category><![CDATA[Linus Torvalds]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://johanbrook.com/?p=1428</guid>
		<description><![CDATA[Bad programmers worry about the code. Good programmers worry about data structures and their relationships. In the design world, content is everything. Design without context and content is just noise. In the programming world, code is (usually) nothing without data and the structuring of that data. Fail to manage the content and you fail to build a stable and extendable system. ★ Permalink<p><a href='http://johanbrook.com/development/good-programmers/' title='permalink'>★ Permalink</a></p>
]]></description>
				<content:encoded><![CDATA[<blockquote>
<p>Bad programmers worry about the code. Good programmers worry about data structures and their relationships.</p>
</blockquote>
<p>In the design world, content is everything. Design without context and content is just noise. In the programming world, code is (usually) nothing without data and the structuring of that data. Fail to manage the content and you fail to build a stable and extendable system.</p>
<p><a href='http://johanbrook.com/development/good-programmers/' title='permalink'>★ Permalink</a></p>
]]></content:encoded>
			<wfw:commentRss>http://johanbrook.com/development/good-programmers/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Good software is like a knot</title>
		<link>http://johanbrook.com/development/good-software-and-knots/</link>
		<comments>http://johanbrook.com/development/good-software-and-knots/#comments</comments>
		<pubDate>Thu, 09 Aug 2012 10:00:48 +0000</pubDate>
		<dc:creator>Johan</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[complexity]]></category>
		<category><![CDATA[knot]]></category>
		<category><![CDATA[philosophical]]></category>
		<category><![CDATA[problem]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[Simplicity]]></category>

		<guid isPermaLink="false">http://johanbrook.com/?p=1414</guid>
		<description><![CDATA[Warning: philosophical, almost silly, post about knots ahead While I was getting our sailing boat in order for a trip during the past weekend, I had an insight. Good software code is like a reliable knot I was tying some ropes and it hit me how knots can be as beautiful, simple, messy and complex as code is. A good knot should be elegant but robust A good knot should be simple enough to understand and solve by another person The more complex the knot is, the more open it is to vulnerabilities and weaknesses Using existing knots which are proved to work in certain conditions is good A good knot in one situation may not be the optimal choice &#8230; <p class="read-more-container"><a class="read-more" href="http://johanbrook.com/development/good-software-and-knots/">Read more →</a></p>]]></description>
				<content:encoded><![CDATA[<p><em>Warning: philosophical, almost silly, post about knots ahead</em></p>
<p>While I was getting our sailing boat in order for a trip during the past weekend, I had an insight.</p>
<blockquote>
<p>Good software code is like a reliable knot</p>
</blockquote>
<p>I was tying some ropes and it hit me how knots can be as beautiful, simple, messy and complex as code is. </p>
<ul>
<li>A good knot should be elegant but robust</li>
<li>A good knot should be simple enough to understand and solve by another person</li>
<li>The more complex the knot is, the more open it is to vulnerabilities and weaknesses</li>
<li>Using existing knots which are proved to work in certain conditions is good</li>
<li>A good knot in one situation may not be the optimal choice in another
</li>
</ul>
<p>Now switch <em>knot</em> above to <em>piece of code</em> or <em>software</em>.</p>
<p>I reckon you might be able to draw parallels about programming to many areas, but I think knots are one of the clearest comparisons. </p>
]]></content:encoded>
			<wfw:commentRss>http://johanbrook.com/development/good-software-and-knots/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>→ &#8220;Some things I&#8217;ve learnt about programming&#8221;</title>
		<link>http://blog.jgc.org/2012/07/some-things-ive-learnt-about.html</link>
		<comments>http://johanbrook.com/development/some-things-ive-learnt-programming/#comments</comments>
		<pubDate>Thu, 12 Jul 2012 10:40:20 +0000</pubDate>
		<dc:creator>Johan</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[craft]]></category>
		<category><![CDATA[experience]]></category>
		<category><![CDATA[insight]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[skills]]></category>

		<guid isPermaLink="false">http://johanbrook.com/?p=1362</guid>
		<description><![CDATA[To my mind that&#8217;s a craft. I think the best programmers are closer to watchmakers than bridge builders or physicists. Sure, it looks like it&#8217;s science or engineering because of the application of logic and mathematics, but at its core it&#8217;s taking tools in your hands (almost) and crafting something. So many gems in there. ★ Permalink<p><a href='http://johanbrook.com/development/some-things-ive-learnt-programming/' title='permalink'>★ Permalink</a></p>
]]></description>
				<content:encoded><![CDATA[<blockquote><p>To my mind that&#8217;s a craft. I think the best programmers are closer to watchmakers than bridge builders or physicists. Sure, it looks like it&#8217;s science or engineering because of the application of logic and mathematics, but at its core it&#8217;s taking tools in your hands (almost) and crafting something.</p></blockquote>
<p>So many gems in there.</p>
<p><a href='http://johanbrook.com/development/some-things-ive-learnt-programming/' title='permalink'>★ Permalink</a></p>
]]></content:encoded>
			<wfw:commentRss>http://johanbrook.com/development/some-things-ive-learnt-programming/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>&#8216;Systemet&#8217; – A liquor store status web app</title>
		<link>http://johanbrook.com/development/systemet/</link>
		<comments>http://johanbrook.com/development/systemet/#comments</comments>
		<pubDate>Thu, 31 May 2012 10:31:55 +0000</pubDate>
		<dc:creator>Johan</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[API]]></category>
		<category><![CDATA[App]]></category>
		<category><![CDATA[Coffeescript]]></category>
		<category><![CDATA[Heroku]]></category>
		<category><![CDATA[iOS]]></category>
		<category><![CDATA[Mobile]]></category>
		<category><![CDATA[MongoDB]]></category>
		<category><![CDATA[Node]]></category>
		<category><![CDATA[Node.js]]></category>
		<category><![CDATA[Nodejs]]></category>
		<category><![CDATA[öppettider]]></category>
		<category><![CDATA[status]]></category>
		<category><![CDATA[Systembolaget]]></category>

		<guid isPermaLink="false">http://johanbrook.com/?p=1311</guid>
		<description><![CDATA[In Sweden the state has monopoly on all sales of alcohol. It sucks sometimes, especially when it comes to competition and opening hours. More than once I&#8217;ve discovered in panic that the liquor store closes 15.00 on a Saturday (!). I&#8217;ve felt a need for a small utility which tracks down the closest store and gives an answer to the question &#8220;Is the liquor store open?&#8221;. So I built one. Visit the app on systemet.johanbrook.com oppet.systmt.se. The source is on GitHub. I built it with mobiles in mind, but it&#8217;s of course usable on all other web devices. If you&#8217;re on iOS, feel free to add it to your homescreen for quick access and the full experience (I said that because I&#8217;ve &#8230; <p class="read-more-container"><a class="read-more" href="http://johanbrook.com/development/systemet/">Read more →</a></p>]]></description>
				<content:encoded><![CDATA[<p class="ingress"><strong>In Sweden the state has monopoly</strong> on all sales of alcohol. It sucks sometimes, especially when it comes to competition and opening hours. More than once I&#8217;ve discovered in panic that the liquor store closes 15.00 on a Saturday (!). I&#8217;ve felt a need for a small utility which tracks down the closest store and gives an answer to the question <em>&#8220;Is the liquor store open?&#8221;</em>. So I built one.</p>
<p>Visit the app on <del>systemet.johanbrook.com</del> <a href="http://oppet.systmt.se">oppet.systmt.se</a>. The source is on <a href="https://github.com/johanbrook/systemet">GitHub</a>. I built it with mobiles in mind, but it&#8217;s of course usable on all other web devices. If you&#8217;re on iOS, feel free to add it to your homescreen for quick access and the full experience (I said that because I&#8217;ve made an icon and adjusted the app for native mode &#8230;).</p>
<p>Thanks to <a href="http://niklas.jakobsen.se/">Niklas Jakobsen</a> for the awesome subdomain! (&#8220;Öppet&#8221; is Swedish for &#8220;open&#8221;).</p>
<h2>The &#8220;why&#8221;</h2>
<ol>
<li>I wanted to build it</li>
<li>I wanted to learn more about Node.js, MongoDB, CoffeeScript, and web APIs and services</li>
</ol>
<h2>The process</h2>
<p>I started to research ways of getting a list of all stores along with their coordinates and opening hours. Seemed rare at first: 3rd party APIs only offered the product index. But it turned out Systembolaget has official, open API resources for this <a href="http://www.systembolaget.se/Tjanster/Oppna-APIer/">on this page</a>. They are served in XML (uhh ..) and XLS (argh!) format, and are quite badly formatted.</p>
<p>On top of that, the coordinates for the <a href="http://www.systembolaget.se/Assortment.aspx?butikerombud=1">store XML file</a> are in <a href="http://en.wikipedia.org/wiki/RT90">RT90 format</a> – not the &#8220;standard&#8221; WGS coordinate system. Since the app gets regular coordinates from the built-in GeoLocation sensor, I had to convert them from the XML file. My father is a surveyor, and along with some research I found neat formulas for converting RT90 to regular coordinates. The <a href="http://en.wikipedia.org/wiki/Gauss%E2%80%93Kr%C3%BCger_coordinate_system">Gauss-Krüger method</a> is common, and I also found existing Javascript code for the conversion.</p>
<p>After a lot of testing I could start doing the real thing. I began with getting to know <a href="http://nodejs.org">Node.js</a>, <a href="http://expressjs.com/">Express.js</a> better along with basic conventions. Everything went quite fast since the language (Javascript) itself wasn&#8217;t a problem, but instead the Node way of doing things were new to me. I separated the code in two parts:</p>
<ol>
<li><a href="https://github.com/johanbrook/systemet/blob/master/src/routes.coffee">The main app</a> which should serve a start page where client side JS would get the device&#8217;s coordinates, send them as parameters via XHR to my Express app route which should find the closest store and send the data back as JSON.</li>
<li><a href="https://github.com/johanbrook/systemet/blob/master/src/script/import.coffee">The import script</a> which should get the XML from Systembolaget&#8217;s website, parse it as JSON, and insert it into a MongoDB database.</li>
</ol>
<p>I of course didn&#8217;t want to get the whole XML file from the API on every app request, as it would be the only way of doing it. Systembolaget&#8217;s &#8220;API&#8221; isn&#8217;t that sophisticated. Instead I put it all into a Mongo database, which meant I could use all the very useful <a href="http://www.mongodb.org/display/DOCS/Geospatial+Indexing">geospatial indexing features</a> of MongoDB:</p>
<pre class="coffeescript"><code>collection.ensureIndex loc: "2d"
collection.find(loc: $near: [50, 50])</code></pre>
<p>Where <code>[50,50]</code> are the coordinates I would get from the client. Neat. </p>
<h3>Hosting</h3>
<p>I began glueing everything together, and it worked quite well locally. Win! The closest liquor store showed up with the correct dates and hours. But I of course wanted to host it online for me and everybody. I instantly thought on <a href="http://heroku.com">Heroku</a> since they offer Node.js hosting nowadays. They also have free MongoDB instances which would serve my purposes well enough. Since I needed to parse XML from Systembolaget&#8217;s service when it&#8217;s updated, a cronjob service was required. Heroku offers that (for free!) as well.</p>
<p>Node.js deployments on Heroku was something I had never done before – I&#8217;ve only worked with Ruby stacks. Turned out everything went smooth. After fiddling with the MongoDB connection for a while I got everything to work almost painlessly. Kudos to Heroku. </p>
<h3>Conclusion</h3>
<p>The user base of my web app is limited to Swedish readers, but it was fun hack nevertheless. I learned a lot about Node.js and asynchronous programming, which wasn&#8217;t that easy to wrap my head around at first. Node.js was more low level web server stuff than I had previously done before.</p>
<p>Check out the source code in the <a href="https://github.com/johanbrook/systemet">GitHub repo</a> and give feedback.</p>
]]></content:encoded>
			<wfw:commentRss>http://johanbrook.com/development/systemet/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Bdgt for iPhone</title>
		<link>http://johanbrook.com/development/ios/bdgt-for-iphone/</link>
		<comments>http://johanbrook.com/development/ios/bdgt-for-iphone/#comments</comments>
		<pubDate>Tue, 17 Apr 2012 19:58:54 +0000</pubDate>
		<dc:creator>Johan</dc:creator>
				<category><![CDATA[iOS]]></category>
		<category><![CDATA[App]]></category>
		<category><![CDATA[BDGT]]></category>
		<category><![CDATA[budget]]></category>
		<category><![CDATA[economy]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[money]]></category>
		<category><![CDATA[transactions]]></category>

		<guid isPermaLink="false">http://johanbrook.com/?p=1259</guid>
		<description><![CDATA[Personal budgets can be difficult and tedious. When I think of the word “budget”, I instantly think of tables, pen and paper, balance, diagrams, categories, and yadi, yadi … In the end, it’s all about keeping track of transactions and comparing the total cost of these to a given goal. How is this done fast, everywhere, and easy? Our proposal: BDGT for iPhone BDGT is an iPhone app which keeps track of daily transactions and will let you overlook your flow of money. In a simple and quick interface, you’re able to add a transaction, put it in a category, and you’re done. Boom. For now: in BDGT you specify a budget which always is present and shown for you. &#8230; <p class="read-more-container"><a class="read-more" href="http://johanbrook.com/development/ios/bdgt-for-iphone/">Read more →</a></p>]]></description>
				<content:encoded><![CDATA[<p><strong>Personal budgets</strong> can be difficult and tedious. When I think of the word “budget”, I instantly think of tables, pen and paper, balance, diagrams, categories, and yadi, yadi … In the end, it’s all about keeping track of transactions and comparing the total cost of these to a given goal. How is this done fast, everywhere, and easy?</p>
<h2>Our proposal: BDGT for iPhone</h2>
<figure>
<img src="http://f.cl.ly/items/121Z2e0Y2g3d3k1r2M27/facebook_cover_photo.png" alt="BDGT" /><br />
</figure>
<p>BDGT is an iPhone app which keeps track of daily transactions and will let you overlook your flow of money. In a simple and quick interface, you’re able to add a transaction, put it in a category, and you’re done. Boom. For now: in BDGT you specify a budget which always is present and shown for you.</p>
<p>The general idea for the app is to simplify people’s everyday home economy, and help you keeping track of the flow.</p>
<p>Feel free to visit <a href="http://bdgt.me">bdgt.me</a> and follow us on Twitter (<a href="http://twitter.com/bdgtme">@BDGTme</a>), Facebook (<a href="http://www.facebook.com/pages/Bdgt/386636014682653">BDGT</a>), and Tumblr (<a href="http://blog.bdgt.me">blog.bdgt.me</a>). Feel free to ask us anything or give feedback through any of these channels. Don&#8217;t forget to sign up for the newsletter as well.</p>
<p>We hope to release further info, screenshots, and videos during the period until release.</p>
<hr />
We, the creators of BDGT, are <a href="http://tapdudes.com/">Tapdudes</a> with concept and design lead by <a href="http://twitter.com/masviken">Tomas Måsviken</a>.</p>
<p><em>Thank you!</em></p>
]]></content:encoded>
			<wfw:commentRss>http://johanbrook.com/development/ios/bdgt-for-iphone/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>→ A word about testing code</title>
		<link>http://37signals.com/svn/posts/3159-testing-like-the-tsa</link>
		<comments>http://johanbrook.com/development/a-word-about-testing-code/#comments</comments>
		<pubDate>Thu, 12 Apr 2012 08:00:21 +0000</pubDate>
		<dc:creator>Johan</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[coverage]]></category>
		<category><![CDATA[ratio]]></category>
		<category><![CDATA[TDD]]></category>
		<category><![CDATA[Test Driven Development]]></category>
		<category><![CDATA[testing]]></category>
		<category><![CDATA[tests]]></category>
		<category><![CDATA[unit test]]></category>

		<guid isPermaLink="false">http://johanbrook.com/?p=1251</guid>
		<description><![CDATA[If you&#8217;re doing the right amount of testing, there should be a good chance, whenever you kick off a test run, that your actions for the next hour will change depending on the results of the run. If you typically don&#8217;t change your actions based on the information from the tests, then the effort spent to write tests gathering that information was wasted. Comment from the HN thread of the linked article (Permalink) David Heinemeier Hansson writes about sane amounts of software tests, which he ranted a bit about on Twitter today. I haven&#8217;t enough experience with tests yet, so I can&#8217;t give valid comments, but I&#8217;ve begun to understand what he and others are talking about thanks to a &#8230; <p class="read-more-container"><a class="read-more" href="http://johanbrook.com/development/a-word-about-testing-code/">Read more →</a></p><p><a href='http://johanbrook.com/development/a-word-about-testing-code/' title='permalink'>★ Permalink</a></p>
]]></description>
				<content:encoded><![CDATA[<blockquote>
<p>If you&#8217;re doing the right amount of testing, there should be a good chance, whenever you kick off a test run, that your actions for the next hour will change depending on the results of the run. If you typically don&#8217;t change your actions based on the information from the tests, then the effort spent to write tests gathering that information was wasted.</p>
<footer>Comment from the <a href="http://news.ycombinator.com/item?id=3828470">HN thread</a> of the linked article (<a href="http://news.ycombinator.com/item?id=3829086">Permalink</a>)</footer>
</blockquote>
<p><strong>David Heinemeier Hansson writes about</strong> sane amounts of software tests, which he ranted a bit about on Twitter today. I haven&#8217;t enough experience with tests yet, so I can&#8217;t give valid comments, but I&#8217;ve begun to understand what he and others are talking about thanks to a heavy focus on unit tests in a university course. Putting tons of time on writing tests instead of actual code seem insane to me, and David&#8217;s thoughts about having advice on what <em>not to test</em> seems legit to me (I recommend reading the comments on the <a href="http://news.ycombinator.com/item?id=3828470">Hacker News entry</a> as well).</p>
<p>In the end I think it boils down to a healthy balance, as with everything else in life.</p>
<p><a href='http://johanbrook.com/development/a-word-about-testing-code/' title='permalink'>★ Permalink</a></p>
]]></content:encoded>
			<wfw:commentRss>http://johanbrook.com/development/a-word-about-testing-code/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
<!-- This Quick Cache file was built for (  johanbrook.com/development/feed/ ) in 0.36417 seconds, on May 22nd, 2013 at 11:27 am UTC. -->
<!-- This Quick Cache file will automatically expire ( and be re-built automatically ) on May 22nd, 2013 at 12:27 pm UTC -->