<?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>Blog.Project13.pl &#187; coding</title>
	<atom:link href="http://www.blog.project13.pl/index.php/category/coding/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.blog.project13.pl</link>
	<description>The Blog of a Coder</description>
	<lastBuildDate>Sun, 05 Feb 2012 02:28:52 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>[Scala] Implicit Manifest tip</title>
		<link>http://www.blog.project13.pl/index.php/coding/1445/scala-implicit-manifest-tip/</link>
		<comments>http://www.blog.project13.pl/index.php/coding/1445/scala-implicit-manifest-tip/#comments</comments>
		<pubDate>Sat, 04 Feb 2012 16:20:07 +0000</pubDate>
		<dc:creator>Ktoso</dc:creator>
				<category><![CDATA[coding]]></category>
		<category><![CDATA[english]]></category>
		<category><![CDATA[scala]]></category>
		<category><![CDATA[manifest]]></category>
		<category><![CDATA[marshalling]]></category>
		<category><![CDATA[tips]]></category>
		<category><![CDATA[tricks]]></category>

		<guid isPermaLink="false">http://www.blog.project13.pl/?p=1445</guid>
		<description><![CDATA[Hello again! Today I&#8217;d like to show a nice little trick you can do in Scala to make your methods look more &#8220;like Scala&#8221;, and require less typing :-) Let&#8217;s take a look at the two methods bellow: // before: val cookie = unmarshall&#40;classOf&#91;Cookie&#93;, jsonRepresentingACookie&#41; &#160; // which is the same as the bellow sample [...]]]></description>
			<content:encoded><![CDATA[<p>Hello again! Today I&#8217;d like to show a nice little trick you can do in Scala to make your methods look more &#8220;like Scala&#8221;, and require less typing :-) Let&#8217;s take a look at the two methods bellow:</p>
<div class="geshi no java">
<ol>
<li class="li1">
<div class="de1"><span class="co1">// before:</span></div>
</li>
<li class="li1">
<div class="de1">val cookie = unmarshall<span class="br0">&#40;</span>classOf<span class="br0">&#91;</span>Cookie<span class="br0">&#93;</span>, jsonRepresentingACookie<span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="co1">// which is the same as the bellow sample in Java</span></div>
</li>
<li class="li1">
<div class="de1"><span class="co1">// Cookie cookie = unmarshall(Cookie.class, jsonRepresentingACookie)</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="co1">// after:</span></div>
</li>
<li class="li1">
<div class="de1">val cookie = unmarshall<span class="br0">&#91;</span>Cookie<span class="br0">&#93;</span><span class="br0">&#40;</span>jsonRepresentingACookie<span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="co1">// which would look like this in Java:</span></div>
</li>
<li class="li1">
<div class="de1"><span class="co1">// Cookie cookie = unmarshall&lt;cookie&gt;(json) // NOT enough&lt;/cookie&gt;</span></div>
</li>
</ol>
</div>
<p>In our example we&#8217;ll want to unmarshall a Cookie object from it&#8217;s string representation, a pretty typical task. In order to do that (for example with JAX-B), we&#8217;ll need a Class object we can pass to the deserializer &#8211; so it can work all the field mappings etc. Obviously the second example in Java just isn&#8217;t enough &#8211; we need the Class object, and just using &lt;Cookie&gt; isn&#8217;t enough to retain this type information. Scala obviously suffers from the exact same problem as it&#8217;s a JVM issue (type erasure, grrr!).</p>
<p>But even so, the above Scala code will work fine if we do some tricks in the method definition. We&#8217;ll resort to using: </p>
<ul>
<li> a second (implicit) argument list</li>
<li> Manifest[T]</li>
</ul>
<p>That&#8217;s a bunch of scary looking terms, but it&#8217;s actually quite easy. Let&#8217;s take a look at the definition of the Scala version of unmarshall.<br />
</p>
<div class="geshi no java">
<ol>
<li class="li1">
<div class="de1">def unmarshal<span class="br0">&#91;</span>T<span class="br0">&#93;</span><span class="br0">&#40;</span>str: <span class="kw3">String</span><span class="br0">&#41;</span><span class="br0">&#40;</span>implicit manifest: <span class="kw3">Manifest</span><span class="br0">&#91;</span>T<span class="br0">&#93;</span><span class="br0">&#41;</span>: T = <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; val unmarshaller = createUnmarshaller<span class="br0">&#40;</span>manifest.<span class="me1">erasure</span><span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; unmarshal<span class="br0">&#40;</span>str, unmarshaller<span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#125;</span></div>
</li>
</ol>
</div>
<p>First, let&#8217;s analyze the signature of this method. Obviously it&#8217;s parameterized method, thus we need the [T] in front of it. Next is the argument list, with just one argument &#8211; str, the string representation we want to unmarshall &#8211; easy. Now for the more fun part &#8211; the <strong>second argument list</strong>. Yeah, you can have multiple argument lists in Scala. &#8220;Why?&#8221;, you ask? For example in our case the second list is implicit &#8211; this means that the compiler will figure out and try to fill in these arguments with matching types it finds in scope. In the case of supplying a Manifest[T] it&#8217;s fairly easy &#8211; it will just create the manifest based on the T type, during runtime at the call site of the method, and pass it into unmarshall.</p>
<p>A Manifest[T] can be thought of like a &#8220;better&#8221; a Class[_] which contains full type information &#8211; so for example we wouldn&#8217;t loose the information contained in a List&lt;Cookie&gt; like we would with plain Java (where we would have to hack around this JVM issue via a <a href="http://google-gson.googlecode.com/svn/tags/1.1.1/docs/javadocs/com/google/gson/reflect/TypeToken.html" title="Google Gson TypeToken" target="_blank" onclick="urchinTracker('/outgoing/google-gson.googlecode.com/svn/tags/1.1.1/docs/javadocs/com/google/gson/reflect/TypeToken.html?referer=');">TypeToken</a>). Anyway, thanks to the Manifest we&#8217;re able to get the Class we need to get our unmarshalling done! <strong>Manifest.erasure</strong> contains the type we need. If you want to read more about Manifest, the <a href="http://www.scala-lang.org/api/current/scala/reflect/Manifest.html" onclick="urchinTracker('/outgoing/www.scala-lang.org/api/current/scala/reflect/Manifest.html?referer=');">ScalaDoc</a> about it does a really nice job explaining how to use it.</p>
<p>&#8212; EXTRA for Scala Geeks &#8212; </p>
<p>You may have noticed the word &#8220;<strong>implicitly</strong>&#8221; appearing from time to time in Scala discussions. It&#8217;s a shorthand for accessing shorthand passed implicits. Let me explain this on our example &#8211; so instead of the code above we could do the following (which does the same thing):</p>
<div class="geshi no java">
<ol>
<li class="li1">
<div class="de1">def unmarshal<span class="br0">&#91;</span>T: <span class="kw3">Manifest</span><span class="br0">&#93;</span><span class="br0">&#40;</span>str: <span class="kw3">String</span><span class="br0">&#41;</span>: T = <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; val unmarshaller = createUnmarshaller<span class="br0">&#40;</span>implicitly<span class="br0">&#91;</span><span class="kw3">Manifest</span><span class="br0">&#91;</span>T<span class="br0">&#93;</span><span class="br0">&#93;</span>.<span class="me1">erasure</span><span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; unmarshal<span class="br0">&#40;</span>str, unmarshaller<span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="co1">// and a quick Repl check if it really does what we think it should:</span></div>
</li>
<li class="li1">
<div class="de1"><span class="co1">//</span></div>
</li>
<li class="li1">
<div class="de1"><span class="co1">// scala&gt; def unmarshal[T: Manifest](str: String) = {</span></div>
</li>
<li class="li1">
<div class="de1"><span class="co1">// &nbsp; &nbsp; &nbsp;| implicitly[Manifest[T]].erasure</span></div>
</li>
<li class="li1">
<div class="de1"><span class="co1">// &nbsp; &nbsp; &nbsp;| }</span></div>
</li>
<li class="li1">
<div class="de1"><span class="co1">// unmarshal: [T](str: String)(implicit evidence$1: Manifest[T])java.lang.Class[_]</span></div>
</li>
</ol>
</div>
<p>So instead of creating a second argument list we say that the Type parameter T will be used as a Manifest. And then we can access it via the implicitly magic method. This approach has been made possible since Scala 2.8, due to how often the above pattern was discovered in real life code.<br />
Anyway &#8211; it&#8217;s up to you which version you like the most.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.blog.project13.pl/index.php/coding/1445/scala-implicit-manifest-tip/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Scala SBT and Test Dependencies</title>
		<link>http://www.blog.project13.pl/index.php/coding/1434/scala-sbt-and-test-dependencies/</link>
		<comments>http://www.blog.project13.pl/index.php/coding/1434/scala-sbt-and-test-dependencies/#comments</comments>
		<pubDate>Thu, 26 Jan 2012 23:00:39 +0000</pubDate>
		<dc:creator>Ktoso</dc:creator>
				<category><![CDATA[coding]]></category>
		<category><![CDATA[english]]></category>
		<category><![CDATA[scala]]></category>
		<category><![CDATA[#maven]]></category>
		<category><![CDATA[compile]]></category>
		<category><![CDATA[dependencies]]></category>
		<category><![CDATA[project management]]></category>
		<category><![CDATA[sbt]]></category>

		<guid isPermaLink="false">http://www.blog.project13.pl/?p=1434</guid>
		<description><![CDATA[Remember the ol&#8217; days with Maven where you had to create a project for just about anything if you wanted to keep your depencencies clean and separated? We&#8217;ve encountered such a problem with a current project, and started to tackle it &#8220;the maven way&#8221;. It wasn&#8217;t too long that we&#8217;ve realized that we&#8217;re in scala [...]]]></description>
			<content:encoded><![CDATA[<p>Remember the ol&#8217; days with <strong>Maven</strong> where you had to create a project for just about anything if you wanted to keep your depencencies clean and separated? We&#8217;ve encountered such a problem with a current project, and started to tackle it &#8220;the maven way&#8221;. It wasn&#8217;t too long that we&#8217;ve realized that we&#8217;re in scala world now and things should have been fixed or made possible quite some time ago&#8230; :-)</p>
<p>The case is this: We have a common configuration (a bunch of <strong>scala objects</strong>) and some helper framework to help us in writing unit tests that integrate with the model. And then there&#8217;s the model obviously. If you&#8217;d like to allow people to use this test scoped helper framework, if should be in another project (which using maven conventions would usually be called something like &#8220;model-testing&#8221;) and it would be used as a dependency in the maven project which wanted to test some model related behaviours. The problem with maven here is that it would require us to put those helpers into a new project, and also&#8230; put the configuration scala objects into another projects &#8211; as they&#8217;d need to be shared among the <strong>helper utils</strong>, the model and all projects using both of them (the details about &#8220;why?&#8221; are a bit specific to the project, but depending on how it&#8217;s structured and how it should work that would be the way to go with maven).</p>
<p>Thank goodness we weren&#8217;t unaware of the excticing strengths that sbtr gives us, and instead of creating multiple projects we were able to got away with just exposing the test sources as classpath dependencies for the projects which would need the model. This can be done via:</p>
<div class="geshi no scala">
<div class="head">// in projects/Build.scala</div>
<ol>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">object TheProjectBuild extends Build {
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; import Dependencies._
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; import BuildSettings._
</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; lazy val iUseTheModel: Project = Project(
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &quot;i-use-the-model&quot;,
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; file(&quot;i-use-the-model&quot;),
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; settings = buildSettings ++
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; Seq(libraryDependencies ++= Seq(/*deps*/)
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; ) dependsOn(model % &quot;compile-&gt;compile;test-&gt;test&quot;)
</div>
</li>
<li class="li1">
<div class="de1">}</div>
</li>
</ol>
</div>
<p>All the magic is in the second-to-last line. It&#8217;s something <strong>sbt</strong> calls &#8220;<strong><a title="per-configuration classpath dependencies" href="https://github.com/harrah/xsbt/wiki/Getting-Started-Multi-Project" onclick="urchinTracker('/outgoing/github.com/harrah/xsbt/wiki/Getting-Started-Multi-Project?referer=');">per-configuration classpath dependencies</a></strong>&#8220;. And if explained in layman terms means &#8220;<em>i want the classpath used in the lefthand project in the scope X to be used in the right hand project in scope Y</em>&#8220;. So in our example we define that we depend on the model project (a Project instance), and declare that it&#8217;s compile classpath should be included in OUR compile classpath, and it&#8217;s test classpath should be included in our test classpath. You could do the same with &#8220;it&#8221; (for integration tests) for example&#8230; or for any other (so called) &#8220;Configuration&#8221; defined within <strong>sbt</strong>.</p>
<p>Using this we were able to avoid creating a &#8220;bazzilion&#8221; (a number which you can&#8217;t count to) of projects to achieve a simple goal &#8211; share test helpers. I&#8217;m getting more and more excicted about Scala and it&#8217;s tooling. As you can see <strong>SBT</strong> enables you to do some quite expressive and powerful things which would be impossible to do in maven for example. If there is any downside to <strong>SBT</strong> then it&#8217;s that the documentation is a bit chaotic, but the guys are really working on that, so I&#8217;m full of hope and optimism about it. :-)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.blog.project13.pl/index.php/coding/1434/scala-sbt-and-test-dependencies/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>[conference] Deep Dive Into RoboGuice @ Cracow.Mobi</title>
		<link>http://www.blog.project13.pl/index.php/project13/1389/conference-deep-dive-into-roboguice-cracow-mobi/</link>
		<comments>http://www.blog.project13.pl/index.php/project13/1389/conference-deep-dive-into-roboguice-cracow-mobi/#comments</comments>
		<pubDate>Sat, 10 Dec 2011 00:12:54 +0000</pubDate>
		<dc:creator>Ktoso</dc:creator>
				<category><![CDATA[android]]></category>
		<category><![CDATA[coding]]></category>
		<category><![CDATA[english]]></category>
		<category><![CDATA[polish]]></category>
		<category><![CDATA[Project13]]></category>
		<category><![CDATA[conference]]></category>
		<category><![CDATA[di]]></category>
		<category><![CDATA[fun]]></category>
		<category><![CDATA[guice]]></category>
		<category><![CDATA[ioc]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[jsr330]]></category>
		<category><![CDATA[presentation]]></category>
		<category><![CDATA[slides]]></category>
		<category><![CDATA[tweets]]></category>

		<guid isPermaLink="false">http://www.blog.project13.pl/?p=1389</guid>
		<description><![CDATA[Today I have presented yet another *new* Android Talk at the Cracow.Mobi conference. This time I focused on RoboGuice, and Guice in general. As from what I&#8217;ve seen a lot of android apps still get written without dependency injection &#8211; which saddens me &#8211; static global variables or weird helpers still come up in apps [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.cracow.mobi" onclick="urchinTracker('/outgoing/www.cracow.mobi?referer=');"><img class="alignright size-medium wp-image-1413" style="background: white; padding: 5px; margin: 5px;" title="logo" src="http://www.blog.project13.pl/wp-content/uploads/2011/12/logo-300x107.png" alt="" width="150" height="70" /></a><br />
Today I have presented yet another *new* <strong>Android</strong> Talk at the <a href="http://cracow.mobi" onclick="urchinTracker('/outgoing/cracow.mobi?referer=');">Cracow.Mobi</a> conference. This time I focused on <a href="http://code.google.com/p/roboguice/" onclick="urchinTracker('/outgoing/code.google.com/p/roboguice/?referer=');"><strong>RoboGuice</strong></a>, and Guice in general.</p>
<p>As from what I&#8217;ve seen a lot of android apps still get written without dependency injection &#8211; which saddens me &#8211; static global variables or weird helpers still come up in apps I do security / performance / code quality audits for &#8211; so I thought that&#8217;s something I need to teach the general audience.</p>
<p>The conference is a 2 day event. Organized by 2 students from Politechnika Krakowska (and a few of their helpers of course), and it&#8217;s a free event. We, as <a href="http://www.llp.pl" onclick="urchinTracker('/outgoing/www.llp.pl?referer=');">Lunar Logic Polska</a>, were proud to be one of the main sponsors of the event. I also personally helped out with a few tips etc, as part of the <a href="http://www.java.pl" onclick="urchinTracker('/outgoing/www.java.pl?referer=');">PolishJUG</a> and <a href="http://krakow.gtug.pl" onclick="urchinTracker('/outgoing/krakow.gtug.pl?referer=');">KrakówGTUG</a>. We also got some swag from the polish Google office which was a really nice gesture from them&#8230; :-) <em>But back to the presentation! Here it is:</em></p>
<p><iframe id="android-conference-deep-dive" src="http://www.blog.project13.pl/wp-content/uploads/2011/12/presentation.html" width="100%" height="450"></iframe></p>
<p><script type="text/javascript">// < ![CDATA[
// < ![CDATA[
// < ![CDATA[
(function() {
function resizeMe(){
   var iFrame =  document.getElementById('android-conference-deep-dive');
   var iFrameBody;
   if ( iFrame.contentDocument ) 
   { // FF
     iFrameBody = iFrame.contentDocument.getElementsByTagName('body')[0];
   }
   else if ( iFrame.contentWindow ) 
   { // IE
     iFrameBody = iFrame.contentWindow.document.getElementsByTagName('body')[0];
   }
 iFrameBody.style.cssText = "zoom: 0.5; -moz-transform: scale(0.5); -moz-transform-origin: 0 0;"
 }
resizeMe();
setTimeout(resizeMe, 500);
})();
// ]]&gt;</script></p>
<p><strong>You can actually use RIGHT/LEFT and H controls in the above iframe to go through the presentation!</strong> <a title="Sources for it are available on my github" href="https://github.com/ktoso/cracow-mobi-android-di" target="_blank" onclick="urchinTracker('/outgoing/github.com/ktoso/cracow-mobi-android-di?referer=');">Sources for it are available on my github</a>.</p>
<p><a href="http://www.blog.project13.pl/wp-content/uploads/2011/12/awesome_tweet_thanks.png"><img class="aligncenter size-medium wp-image-1421" title="awesome_tweet_thanks" src="http://www.blog.project13.pl/wp-content/uploads/2011/12/awesome_tweet_thanks-300x122.png" alt="" width="400" /></a></p>
<p>From the audiences response etc, it seems that this one has been the cleanest, in the sense of &#8220;most fluent&#8221; presentation I&#8217;ve done up until today. I&#8217;ve also went into the code and showed off some minor details. <em>In <a href="http://www.jetbrains.com/idea/" onclick="urchinTracker('/outgoing/www.jetbrains.com/idea/?referer=');">Intellij IDEA 11</a> of course &#8211; be sure to check it out if you&#8217;re an Android (or any kind of) developer! The productivity boost it gives you is &#8220;zomg wooot!&#8221; ;-)</em></p>
<p>I also really enjoyed the talks I was able to attend, and met some old (and possibly quite a few new?) friends. Hope to see you all again!</p>
<p><strong>UPDATE!</strong></p>
<p>This post has been awesomely mentioned by @roboguice :-)</p>
<p><a href="http://www.blog.project13.pl/wp-content/uploads/2011/12/roboguice_cool_tweet.png"><img class="aligncenter size-medium wp-image-1429" title="roboguice_cool_tweet" src="http://www.blog.project13.pl/wp-content/uploads/2011/12/roboguice_cool_tweet-300x135.png" alt="" width="400" /></a></p>
<p><strong>UPDATE 2!</strong></p>
<p>An awesome insider tip from within LLP I recieved today:</p>
<blockquote><p>One guy told me that he was on an Android presentation by some long-haired guy and that it was really good, way better than the rest ;)</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.blog.project13.pl/index.php/project13/1389/conference-deep-dive-into-roboguice-cracow-mobi/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>[release] Kanbanery for IntelliJ (and Android!)</title>
		<link>http://www.blog.project13.pl/index.php/project13/1372/release-kanbanery-for-intellij-and-android/</link>
		<comments>http://www.blog.project13.pl/index.php/project13/1372/release-kanbanery-for-intellij-and-android/#comments</comments>
		<pubDate>Mon, 17 Oct 2011 01:08:56 +0000</pubDate>
		<dc:creator>Ktoso</dc:creator>
				<category><![CDATA[coding]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[Project13]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[free software]]></category>
		<category><![CDATA[intellij]]></category>
		<category><![CDATA[kanban]]></category>
		<category><![CDATA[kanbanery]]></category>
		<category><![CDATA[open source]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[release]]></category>

		<guid isPermaLink="false">http://www.blog.project13.pl/?p=1372</guid>
		<description><![CDATA[After not even one day of hacking, I&#8217;m releasing my first IntelliJ IDEA plugin. It enables &#8220;Tasks&#8221; (that default plugin in IntelliJ) to see tasks on the Kanbanery.com board. Thanks to this you&#8217;re able to commit always &#8220;refering to&#8221; some specific task. Using GitHub and Kanbanery such commits are linked back to the task on [...]]]></description>
			<content:encoded><![CDATA[<p>After not even one day of hacking, I&#8217;m releasing my first <strong>IntelliJ IDEA</strong> plugin. It enables &#8220;<strong>Tasks</strong>&#8221; (that default plugin in IntelliJ) to see tasks on the <strong><a href="http://www kanbanery.com" onclick="urchinTracker('/outgoing/www_kanbanery.com?referer=');">Kanbanery.com</a></strong> board.</p>
<p style="text-align: center;"><img class="aligncenter" title="Kanbanery and Intellij" src="https://github.com/ktoso/kanbanery-for-intellij/raw/master/doc/commit_github_task_id_kanbanery.png" alt="" width="546" height="265" /></p>
<p>Thanks to this you&#8217;re able to commit always &#8220;refering to&#8221; some specific task. Using <strong>GitHub</strong> and Kanbanery such commits are linked back to the task on the board, which makes code reviews very pleasant :-)</p>
<p style="text-align: center;"><img class="aligncenter" src="https://github.com/ktoso/kanbanery-for-intellij/raw/master/doc/switch_task_q_gives_a_nice_info.png" alt="" width="556" height="209" /></p>
<p style="text-align: left;">As we&#8217;re using Kanbanery in our team, I&#8217;ll hopefully have some time and ideas to make this plugin even more useful over time :-) So in case you&#8217;re interested just download the plugin from your IntelliJ or head to <a href="https://github.com/ktoso/kanbanery-for-intellij" onclick="urchinTracker('/outgoing/github.com/ktoso/kanbanery-for-intellij?referer=');">github to look at the source code</a> or <a href="plugins.intellij.net/plugin/edit/?pid=6363">vote for this plugin on it&#8217;s site</a>.</p>
<p style="text-align: center;"><img class="aligncenter" src="https://g0.gstatic.com/android/market/pl.project13.kanbanery/f-1024-0" alt="" width="517" height="252" /></p>
<p style="text-align: left;">Oh&#8230; Seems like I forgot to announce that I&#8217;ve also released a <strong><a title="Kanbanery for Android" href="https://market.android.com/details?id=pl.project13.kanbanery" target="_blank" onclick="urchinTracker('/outgoing/market.android.com/details?id=pl.project13.kanbanery&amp;referer=');">Android client for Kanbanery</a></strong> :-) Yup, that&#8217;s true, so got ahead and check it out if you&#8217;d like to. This one still needs some polishing, but the idea is to keep it in one codebase but develop for both, tablets and normal phones, so some things are a little bit tricky :-) I love to use it on my XOOM, but I&#8217;ll work hard to make the phone versions as awesome as the tablet one.</p>
<p style="text-align: center;"><img class="aligncenter" src="https://ssl.gstatic.com/android/market/pl.project13.kanbanery/ss-1280-7-0" alt="" width="523" height="327" /></p>
]]></content:encoded>
			<wfw:commentRss>http://www.blog.project13.pl/index.php/project13/1372/release-kanbanery-for-intellij-and-android/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[Android] java.lang.SecurityException: Permission Denial &#8211; when launching Activity</title>
		<link>http://www.blog.project13.pl/index.php/coding/1368/android-java-lang-securityexception-permission-denial-when-launching-activity/</link>
		<comments>http://www.blog.project13.pl/index.php/coding/1368/android-java-lang-securityexception-permission-denial-when-launching-activity/#comments</comments>
		<pubDate>Wed, 12 Oct 2011 10:36:18 +0000</pubDate>
		<dc:creator>Ktoso</dc:creator>
				<category><![CDATA[coding]]></category>
		<category><![CDATA[english]]></category>

		<guid isPermaLink="false">http://www.blog.project13.pl/?p=1368</guid>
		<description><![CDATA[Just a quick tip if you ever happen to run into such an error: Launching application: pl.project13.kanbanery/pl.project13.kanbanery .ui.activities.InitActivity. DEVICE SHELL COMMAND: am start -D -n "pl.project13.kanbanery/pl.proj ect13.kanbanery.ui.activities.InitActivity" Starting: Intent { cmp=pl.project13.kanbanery/.ui.activities.InitAct ivity } java.lang.SecurityException: Permission Denial: starting Intent { flg =0x10000000 cmp=pl.project13.kanbanery/.ui.activities.InitActivity } from null (pid=13301, uid=2000) not exported from uid 10061 The error is [...]]]></description>
			<content:encoded><![CDATA[<p>Just a quick tip if you ever happen to run into such an error:</p>
<pre><code>
Launching application: pl.project13.kanbanery/pl.project13.kanbanery
.ui.activities.InitActivity.

DEVICE SHELL COMMAND: am start -D -n "pl.project13.kanbanery/pl.proj
ect13.kanbanery.ui.activities.InitActivity"

Starting: Intent { cmp=pl.project13.kanbanery/.ui.activities.InitAct
ivity }

java.lang.SecurityException: Permission Denial: starting Intent { flg
=0x10000000 cmp=pl.project13.kanbanery/.ui.activities.InitActivity } from null (pid=13301, uid=2000) not exported from uid 10061</code></pre>
<p>The error is on your side and it&#8217;s a super simple one. You have an activity defined <strong>two times in your AndroidManifest.xml</strong>. Just remove the duplicate to get things rolling again ;-)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.blog.project13.pl/index.php/coding/1368/android-java-lang-securityexception-permission-denial-when-launching-activity/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Keeping processes alive using God&#8217;s power</title>
		<link>http://www.blog.project13.pl/index.php/coding/1338/keeping-processes-alive-using-gods-power/</link>
		<comments>http://www.blog.project13.pl/index.php/coding/1338/keeping-processes-alive-using-gods-power/#comments</comments>
		<pubDate>Thu, 04 Aug 2011 17:48:21 +0000</pubDate>
		<dc:creator>Ktoso</dc:creator>
				<category><![CDATA[coding]]></category>
		<category><![CDATA[english]]></category>
		<category><![CDATA[guide]]></category>
		<category><![CDATA[terminal heroes]]></category>
		<category><![CDATA[admin]]></category>
		<category><![CDATA[centos]]></category>
		<category><![CDATA[devops]]></category>
		<category><![CDATA[fedora]]></category>
		<category><![CDATA[god]]></category>
		<category><![CDATA[keep alive]]></category>
		<category><![CDATA[process watch]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://www.blog.project13.pl/?p=1338</guid>
		<description><![CDATA[God is a nice &#8220;framework&#8221; and daemon to watch Linux processes and restart them if necessary. As I&#8217;ve configured it today to work on an ubuntu machine here&#8217;s a quick howto: First install ruby, gem and god. apt-get install ruby, rubygems gem install god Then paste this initscript into /etc/init.d/god: got init script. Configure it [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://god.rubyforge.org/" onclick="urchinTracker('/outgoing/god.rubyforge.org/?referer=');"><strong>God</strong></a> is a nice &#8220;framework&#8221; and daemon to watch Linux processes and restart them if necessary. As I&#8217;ve configured it today to work on an ubuntu machine here&#8217;s a quick howto:</p>
<p>First install ruby, gem and god.</p>
<pre>
apt-get install ruby, rubygems
gem install god
</pre>
<p>Then paste this initscript into <strong>/etc/init.d/god</strong>: <a href="http://openmonkey.com/2008/05/27/god-init-script-for-debian-ubuntu-systems/" onclick="urchinTracker('/outgoing/openmonkey.com/2008/05/27/god-init-script-for-debian-ubuntu-systems/?referer=');">got init script</a>. Configure it to use <strong>/etc/god/config.rb</strong> for example, and there do some minor setup (using ruby, yay) so we can get emails if something happenes:</p>
<div class="geshi no ruby">
<ol>
<li class="li1">
<div class="de1"><span class="kw3">require</span> <span class="kw4">File</span>.<span class="me1">dirname</span><span class="br0">&#40;</span><span class="kw2">__FILE__</span><span class="br0">&#41;</span> <span class="sy0">+</span> <span class="st0">&#39;/watches.rb&#39;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="co1"># mailer configuration</span></div>
</li>
<li class="li1">
<div class="de1"><span class="co1"># &#8230;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="re2">God::Contacts::Email</span>.<span class="me1">delivery_method</span> = <span class="re3">:sendmail</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">God.<span class="me1">contact</span><span class="br0">&#40;</span><span class="re3">:email</span><span class="br0">&#41;</span> <span class="kw1">do</span> <span class="sy0">|</span>c<span class="sy0">|</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; c.<span class="me1">name</span> = <span class="st0">&#39;ktoso&#39;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; c.<span class="me1">to_email</span> = <span class="st0">&#39;konrad.malawski@llp.pl&#39;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="kw1">end</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="co1"># include all watches</span></div>
</li>
<li class="li1">
<div class="de1">God.<span class="kw3">load</span> <span class="st0">&quot;/etc/god/watches/*.rb&quot;</span></div>
</li>
</ol>
</div>
<p>And then all that&#8217;s left to implement is a watch, so create an <strong>/etc/god/watches/xvbf.rb</strong>. It&#8217;s using a nice DSL to configure how God should act when a process dies etc:</p>
<div class="geshi no ruby">
<ol>
<li class="li1">
<div class="de1">God.<span class="me1">watch</span> <span class="kw1">do</span> <span class="sy0">|</span>w<span class="sy0">|</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; w.<span class="me1">uid</span> = <span class="st0">&quot;jenkins&quot;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; w.<span class="me1">gid</span> = <span class="st0">&quot;jenkins&quot;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; w.<span class="me1">name</span> = <span class="st0">&quot;xvfb&quot;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; w.<span class="me1">interval</span> = <span class="nu0">30</span>.<span class="me1">seconds</span> <span class="co1"># default</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; w.<span class="me1">env</span> = <span class="br0">&#123;</span> <span class="st0">&quot;DISPLAY&quot;</span> <span class="sy0">=&gt;</span> <span class="st0">&quot;:99&quot;</span> <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; w.<span class="me1">start</span> = <span class="st0">&quot;Xvfb -ac :99 &amp;&quot;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; w.<span class="me1">start_grace</span> = <span class="nu0">10</span>.<span class="me1">seconds</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; w.<span class="me1">restart_grace</span> = <span class="nu0">10</span>.<span class="me1">seconds</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; w.<span class="me1">behavior</span><span class="br0">&#40;</span><span class="re3">:clean_pid_file</span><span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; w.<span class="me1">start_if</span> <span class="kw1">do</span> <span class="sy0">|</span>start<span class="sy0">|</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; start.<span class="me1">condition</span><span class="br0">&#40;</span><span class="re3">:process_running</span><span class="br0">&#41;</span> <span class="kw1">do</span> <span class="sy0">|</span>c<span class="sy0">|</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; c.<span class="me1">running</span> = <span class="kw2">false</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; c.<span class="me1">notify</span> = <span class="br0">&#91;</span><span class="st0">&#39;konrad&#39;</span><span class="br0">&#93;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="kw1">end</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="kw1">end</span></div>
</li>
<li class="li1">
<div class="de1"><span class="kw1">end</span></div>
</li>
</ol>
</div>
<p>The code is pretty much self explanatory. We watch if the process Xvfb is running, and if not, after the grace period we restart it. Optional info email could also be sent using the notify property.</p>
<p>That&#8217;s it, have fun automating your build environments!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.blog.project13.pl/index.php/coding/1338/keeping-processes-alive-using-gods-power/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[release] Sidewinder X6 MacroKeys on GNU/Linux</title>
		<link>http://www.blog.project13.pl/index.php/fun/1333/1333/</link>
		<comments>http://www.blog.project13.pl/index.php/fun/1333/1333/#comments</comments>
		<pubDate>Wed, 27 Jul 2011 22:30:03 +0000</pubDate>
		<dc:creator>Ktoso</dc:creator>
				<category><![CDATA[coding]]></category>
		<category><![CDATA[freedom]]></category>
		<category><![CDATA[fun]]></category>
		<category><![CDATA[terminal heroes]]></category>
		<category><![CDATA[keystroke]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[macro]]></category>
		<category><![CDATA[sidewinder]]></category>
		<category><![CDATA[sidewinder x6 linux]]></category>
		<category><![CDATA[xdotool]]></category>

		<guid isPermaLink="false">http://www.blog.project13.pl/?p=1333</guid>
		<description><![CDATA[I&#8217;ve released my keyboard event mapper for the Microsoft Sidewinder X6 in an quite usable state right now. Take a look at sidewinder-x6-linux-macro-key-events on github. Here&#8217;s a quick description what it does: As the Sidewinder is an Microsoft keyboard, it obviously does all it can to not work at it&#8217;s full potential on GNU/Linux systems [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve released my keyboard event mapper for the <a href="http://www.microsoft.com/poland/hardware/gaming/productdetails.aspx?pid=102" onclick="urchinTracker('/outgoing/www.microsoft.com/poland/hardware/gaming/productdetails.aspx?pid=102&amp;referer=');">Microsoft Sidewinder X6</a> in an quite usable state right now. Take a look at <a href="https://github.com/ktoso/sidewinder-x6-linux-macro-key-events" onclick="urchinTracker('/outgoing/github.com/ktoso/sidewinder-x6-linux-macro-key-events?referer=');">sidewinder-x6-linux-macro-key-events</a> on github. Here&#8217;s a quick description what it does:</p>
<p><a href="http://www.blog.project13.pl/wp-content/uploads/2011/07/sidewinder-x6-macro-keys.jpg"><img class="aligncenter size-full wp-image-1334" title="sidewinder-x6-macro-keys" src="http://www.blog.project13.pl/wp-content/uploads/2011/07/sidewinder-x6-macro-keys.jpg" alt="" width="500" height="375" /></a>As the Sidewinder is an Microsoft keyboard, it obviously does all it can to not work at it&#8217;s full potential on GNU/Linux systems ;-) What my script does is watch for usb events, using <strong>usbmon</strong>, then it filters it searching for events from this keyboard, and then it filters out the discrete keystrokes for them. When such keystroke is found, we launch an bash script located in <strong>actions/S##.sh </strong>which can then do anything you want it to do &#8211; fire up intellij, or send keystrokes. I&#8217;d advice the second idea &#8211; use <a href="http://www.semicomplete.com/projects/xdotool/" onclick="urchinTracker('/outgoing/www.semicomplete.com/projects/xdotool/?referer=');">xdotool</a> to send keyboard events, which you then map in Intellij or Netbeans or KDE/GNOME. Such keycode send looks like this:</p>
<p><code>xdotool key --clearmodifiers ctrl+shift+F1</code></p>
<p>That&#8217;s about it. I also wanted to thank some guys on github, who found my project and it really helped them out :-) Just to cite my fav email:</p>
<blockquote><p>
[...]<br />
I&#8217;m amazed to see that somebody made this keyboard work under linux, I was beggining to lose hope. Great job!<br />
[...]
</p></blockquote>
<p>Thanks for the feedback, it&#8217;s what keeps me going with opensourceing projects like this :-)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.blog.project13.pl/index.php/fun/1333/1333/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[alpha][release] ProtoDoc v1.0 (not production ready)</title>
		<link>http://www.blog.project13.pl/index.php/project13/1321/initial-release-protodoc-v1-0-not-production-ready/</link>
		<comments>http://www.blog.project13.pl/index.php/project13/1321/initial-release-protodoc-v1-0-not-production-ready/#comments</comments>
		<pubDate>Mon, 27 Jun 2011 12:00:45 +0000</pubDate>
		<dc:creator>Ktoso</dc:creator>
				<category><![CDATA[coding]]></category>
		<category><![CDATA[Project13]]></category>
		<category><![CDATA[scala]]></category>
		<category><![CDATA[alpha]]></category>
		<category><![CDATA[free software]]></category>
		<category><![CDATA[github]]></category>
		<category><![CDATA[open source]]></category>
		<category><![CDATA[protocol buffers]]></category>
		<category><![CDATA[release]]></category>

		<guid isPermaLink="false">http://www.blog.project13.pl/?p=1321</guid>
		<description><![CDATA[I&#8217;ve finished a one could say major stepstone in my student project yesterday. I&#8217;ll be implementing this tool to be production ready over the next few months so keep your fingers crossed. But what is it actually? ProtoDoc, is for Google Protocol Buffers what JavaDoc is for Java. As simple as that. In order to [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve finished a one could say major stepstone in my student project yesterday. I&#8217;ll be implementing this tool to be production ready over the next few months so keep your fingers crossed. But what is it actually? <em>ProtoDoc, is for Google Protocol Buffers what JavaDoc is for Java.</em> As simple as that. In order to achieve this I needed to parse Protocol Buffer IDL files and then on top of that do some simple html generation. The tools I used for this are:</p>
<ul>
<li>Scala &#8211; the code is 100% scala</li>
<li>Scala <a href="http://www.google.pl/search?aq=f&#038;sourceid=chrome&#038;ie=UTF-8&#038;q=scala+parser+combinators+documentation" onclick="urchinTracker('/outgoing/www.google.pl/search?aq=f_038_sourceid=chrome_038_ie=UTF-8_038_q=scala+parser+combinators+documentation&amp;referer=');">Parser Combinators</a> &#8211; the &#8220;parser generation DSL&#8221; one might say, begind this parser. It&#8217;s very very amazing and pushing Scala to it&#8217;s best with some crazy implicit conversions flying around all the time :-)</li>
<li>Scarg &#8211; a simple tool for handling command line parameters, <a href="https://github.com/xfire/scarg" onclick="urchinTracker('/outgoing/github.com/xfire/scarg?referer=');">it&#8217;s on github</a></li>
<li>sbt &#8211; Simple Build Tool, let&#8217;s call it &#8220;what maven is for java&#8221; but with a Gradle-ish feel to it. A very nice build tool, actually my fav I&#8217;d say.</li>
<li><a href="http://scalate.fusesource.org/" onclick="urchinTracker('/outgoing/scalate.fusesource.org/?referer=');">Scalate &#8211; a template engine</a>, which implements <a href="http://mustache.github.com/" onclick="urchinTracker('/outgoing/mustache.github.com/?referer=');">Mustache</a> (which I used, as it&#8217;s a very clean lang, NO LOGIC in the view :-)) as one of it&#8217;s template languages</li>
<li>and of course <a href="www.scalatest.org">ScalaTest</a> &#8211; as &#8216;<em>thou shalt test thy code</em>&#8216; :-)</li>
</ul>
<p>It was a very pleasant expirience and I&#8217;m looking forward to implementing a 100% compatible Protocol Buffers parser in Scala&#8230; :-)</p>
<p>There is also a pdf I&#8217;ve written about this project but it&#8217;s not well written and in Polish (university requirements, bleh), but if you want to know more about Scala Parser Combinators, you can take a look at it here: <a href="https://github.com/ktoso/protodoc-scala/blob/master/doc/konrad_malawski_protodoc.pdf?raw=true" onclick="urchinTracker('/outgoing/github.com/ktoso/protodoc-scala/blob/master/doc/konrad_malawski_protodoc.pdf?raw=true&amp;referer=');">doc @ github.com</a>.</p>
<p>The project itself is of course Free Software and Open Source, licensed under the Apache 2 license, so feel free to <a href="https://github.com/ktoso/protodoc-scala" onclick="urchinTracker('/outgoing/github.com/ktoso/protodoc-scala?referer=');">fork protodoc-scala on github</a>!</p>
<p>I&#8217;ll just quote the README from the github page for the rest of the description:</p>
<hr />
Have you ever worked with a BIG Protocol Buffers based application? It would be awesome if it had some kind<br />
of tool like JavaDoc, to always know what each field exactly means, even without having the proto file at hand right now.</p>
<p><em>Oh, wait. That&#8217;s excatly what ProtoDoc is!</em> ProtoDoc is a tool very much like JavaDoc, which scans your proto files and generates<br />
an easily searchable and most informative website with all information about yout ProtoMessages.</p>
<p><strong>It&#8217;s currently not production ready, and allows only for basic Messages to be parsed.</strong> But it should most probably be finished and fully working quite soon.</p>
<p><strong>Live Demo</strong><br />
There is a <a href="http://www.up.project13.pl/protodoc/index.html" onclick="urchinTracker('/outgoing/www.up.project13.pl/protodoc/index.html?referer=');">live demo available here</a>.</p>
<p><strong>Coding notes</strong></p>
<ul>
<li>ProtoDoc is build by <strong>sbt</strong> so if you want to help out hacking, first download <strong>Scala 2.8.1</strong> and sbt :-)</li>
</ul>
<p><strong>Output screenshots</strong><br />
ProtoDoc takes this:</p>
<pre><code>
package pl.project13;

/**
 * This is a simple Message which has some Inner Message defined.
 * Also, note that it has a default value on the name property.
 */
message MessageWithInner {
    /**
     * A number is just a simple property
     */
    required int32 number = 1;

    /**
     * This can be a name of your likeing, the default value is "lorem ipsum" etc
     */
    required string name = 2 [default = "loremipsum"];

    /**
     * Whoa, this is a comment on an inner message!
     * ProtoDoc is so cool!
     */
    message InnerMessage {

        /**
         * This is a comment on an inner messages field, cool~
         * You may use it like this in your generated Java code:
         * setName("StringMyName");
         */
        optional string name = 3;
    }
}</code></pre>
<p>and generates this:</p>
<p><img src="https://raw.github.com/ktoso/protodoc-scala/master/doc/protodoc_main.png" alt="protodoc sample" style="width:420px"/></p>
<p>
Hooray!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.blog.project13.pl/index.php/project13/1321/initial-release-protodoc-v1-0-not-production-ready/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[Me] Git @ Academic IT Festival (SFI) 2011</title>
		<link>http://www.blog.project13.pl/index.php/project13/1304/me-git-academic-it-festival-2011/</link>
		<comments>http://www.blog.project13.pl/index.php/project13/1304/me-git-academic-it-festival-2011/#comments</comments>
		<pubDate>Fri, 06 May 2011 21:31:58 +0000</pubDate>
		<dc:creator>Ktoso</dc:creator>
				<category><![CDATA[coding]]></category>
		<category><![CDATA[fun]]></category>
		<category><![CDATA[polish]]></category>
		<category><![CDATA[Project13]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[konrad malawski]]></category>
		<category><![CDATA[live coding]]></category>
		<category><![CDATA[presentation]]></category>
		<category><![CDATA[SCM]]></category>
		<category><![CDATA[sfi]]></category>
		<category><![CDATA[video]]></category>

		<guid isPermaLink="false">http://www.blog.project13.pl/?p=1304</guid>
		<description><![CDATA[It&#8217;s been a long time since the Academic IT Festival 2011 but I didn&#8217;t have the time to post about it somehow. Anyways, now just a quick recap about it :-) Aparently some people did really like it, see tweets bellow :-) I also got feedback that &#8220;not yet real programmers&#8221;, that is students, didn&#8217;t [...]]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s been a long time since the <a href="http://sfi.org.pl/edition-2011/" onclick="urchinTracker('/outgoing/sfi.org.pl/edition-2011/?referer=');">Academic IT Festival 2011</a> but I didn&#8217;t have the time to post about it somehow. Anyways, now just a quick recap about it :-)</p>
<p>Aparently some people did really like it, see tweets bellow :-) I also got feedback that &#8220;not yet real programmers&#8221;, that is students, didn&#8217;t really get what I was talking about. Well, most of them still uses SVN (well, if they do it&#8217;s a success anyways) as an SCP replacement so there&#8217;s not much they could complain in SVN about if they&#8217;re not making it work anyhow besides just storing files. :-) Some students apparoached me after the lecture and training (yeah, we also did a little git intro with laptops later on) and they were really fired up about it &#8211; even if not yet grasping git&#8217;s power, they felt something&#8217;s on and I am very happy to have invluenced even just a small group to such feelings and thinking.</p>
<p style="text-align: center;"><a href="http://www.blog.project13.pl/wp-content/uploads/2011/05/git_yay1.png"><img class="aligncenter size-full wp-image-1305" title="git_yay1" src="http://www.blog.project13.pl/wp-content/uploads/2011/05/git_yay1.png" alt="" width="501" height="277" /></a></p>
<p><a href="http://sfi.org.pl/edition-2011/speakers" onclick="urchinTracker('/outgoing/sfi.org.pl/edition-2011/speakers?referer=');">I have been invited</a> (via the Call for Papers I participated in) to present a polished up &#8220;Git. Tak. Po prostu.&#8221; speech <a href="http://sfi.org.pl/edition-2011/agenda-2011#git-tak-po-prostu" onclick="urchinTracker('/outgoing/sfi.org.pl/edition-2011/agenda-2011_git-tak-po-prostu?referer=');">at this years IT Festival</a>. It was a really great opportunity to show lot&#8217;s of people (primarily students, and to-be-students but also some currently working people) the joy and beauty of Git. The event was really nice (it&#8217;s constantly improving, since the last few editions I think) and I&#8217;ve had some fun with my pal from work etc. I&#8217;ve also got to know some of the speakers &#8211; really nice guys :-) Anyways, find bellow the video from the presentation recorded by my newly met pal <a href="http://kzubik.cba.pl" onclick="urchinTracker('/outgoing/kzubik.cba.pl?referer=');">kzubik</a> and the polished up slides (they&#8217;re a lot better than the previous ones).</p>
<p>Video:</p>
<p><iframe src="http://player.vimeo.com/video/22299510?portrait=0" width="551" height="413" frameborder="0"></iframe><br />
<a href="http://vimeo.com/22299510" onclick="urchinTracker('/outgoing/vimeo.com/22299510?referer=');">The video is uploaded to Vimeo</a></p>
<p>Slides:</p>
<p><iframe src="http://www.slideshare.net/slideshow/embed_code/7244954" width="425" height="355" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe> </p>
<p><a href="http://www.slideshare.net/ktoso/git-tak-po-prostu-sfi-version" onclick="urchinTracker('/outgoing/www.slideshare.net/ktoso/git-tak-po-prostu-sfi-version?referer=');">http://www.slideshare.net/ktoso/git-tak-po-prostu-sfi-version</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.blog.project13.pl/index.php/project13/1304/me-git-academic-it-festival-2011/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>[JDK7] java.util.Objects &#8211; forgotten feature?</title>
		<link>http://www.blog.project13.pl/index.php/coding/1284/jdk7-java-lang-objects-forgotten-feature/</link>
		<comments>http://www.blog.project13.pl/index.php/coding/1284/jdk7-java-lang-objects-forgotten-feature/#comments</comments>
		<pubDate>Tue, 19 Apr 2011 09:08:51 +0000</pubDate>
		<dc:creator>Ktoso</dc:creator>
				<category><![CDATA[coding]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[jdk7]]></category>
		<category><![CDATA[lang]]></category>
		<category><![CDATA[oop]]></category>
		<category><![CDATA[release]]></category>
		<category><![CDATA[tips]]></category>
		<category><![CDATA[tricks]]></category>

		<guid isPermaLink="false">http://www.blog.project13.pl/?p=1284</guid>
		<description><![CDATA[This time just a quick post about something I&#8217;d really want to share with you all, and that&#8217;s been kind of forgotten during the release of JDK7 &#8211; java.util.Objects! Be sure to check out it&#8217;s javadoc to see what this small helper class can do for you :-) We&#8217;ll focus on two of it&#8217;s methods. [...]]]></description>
			<content:encoded><![CDATA[<p>This time just a quick post about something I&#8217;d really want to share with you all, and that&#8217;s been kind of forgotten during the release of JDK7 &#8211; <strong>java.util.Objects</strong>! Be sure to check out <a href="http://download.java.net/jdk7/docs/api/java/util/Objects.html" onclick="urchinTracker('/outgoing/download.java.net/jdk7/docs/api/java/util/Objects.html?referer=');">it&#8217;s <strong>javadoc</strong></a> to see what this small helper class can do for you :-) We&#8217;ll focus on two of it&#8217;s methods.</p>
<p>Now, we all remember how painful it it to write good equals and hashCode methods, yet we really should implement them to make our collections work the way they should work (HashAnythings, Lists, Sets). So we sometimes use <strong>Apache Commons</strong> to implement these, or just leave the coding to <strong>IntelliJ</strong> or <strong>NetBeans</strong>. The problem with the second, code generating, solution is that it&#8217;s a hell of a mess. Don&#8217;t believe me&#8230;? Just a quick reminder then&#8230;</p>
<div class="geshi no java">
<div class="head">class Test {</div>
<ol>
<li class="li1">
<div class="de1">&nbsp; <span class="kw2">private</span> <span class="kw3">String</span> &nbsp;name<span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="kw2">private</span> <span class="kw3">String</span> &nbsp;surname<span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="kw2">private</span> <span class="kw3">Integer</span> age<span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; @Override</div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="kw2">public</span> <span class="kw4">boolean</span> equals<span class="br0">&#40;</span><span class="kw3">Object</span> o<span class="br0">&#41;</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span><span class="kw2">this</span> == o<span class="br0">&#41;</span> <span class="kw2">return</span> <span class="kw2">true</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span>o == <span class="kw2">null</span> || getClass<span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="sy0">!</span>= o.<span class="me1">getClass</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span> <span class="kw2">return</span> <span class="kw2">false</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; Test test = <span class="br0">&#40;</span>Test<span class="br0">&#41;</span> o<span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span>age <span class="sy0">!</span>= <span class="kw2">null</span> <span class="sy0">?</span> <span class="sy0">!</span>age.<span class="me1">equals</span><span class="br0">&#40;</span>test.<span class="me1">age</span><span class="br0">&#41;</span> : test.<span class="me1">age</span> <span class="sy0">!</span>= <span class="kw2">null</span><span class="br0">&#41;</span> <span class="kw2">return</span> <span class="kw2">false</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span>name <span class="sy0">!</span>= <span class="kw2">null</span> <span class="sy0">?</span> <span class="sy0">!</span>name.<span class="me1">equals</span><span class="br0">&#40;</span>test.<span class="me1">name</span><span class="br0">&#41;</span> : test.<span class="me1">name</span> <span class="sy0">!</span>= <span class="kw2">null</span><span class="br0">&#41;</span> <span class="kw2">return</span> <span class="kw2">false</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span>surname <span class="sy0">!</span>= <span class="kw2">null</span> <span class="sy0">?</span> <span class="sy0">!</span>surname.<span class="me1">equals</span><span class="br0">&#40;</span>test.<span class="me1">surname</span><span class="br0">&#41;</span> : test.<span class="me1">surname</span> <span class="sy0">!</span>= <span class="kw2">null</span><span class="br0">&#41;</span> <span class="kw2">return</span> <span class="kw2">false</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="kw2">return</span> <span class="kw2">true</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; @Override</div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="kw2">public</span> <span class="kw4">int</span> hashCode<span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="kw4">int</span> result = name <span class="sy0">!</span>= <span class="kw2">null</span> <span class="sy0">?</span> name.<span class="me1">hashCode</span><span class="br0">&#40;</span><span class="br0">&#41;</span> : <span class="nu0">0</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; result = <span class="nu0">31</span> <span class="sy0">*</span> result + <span class="br0">&#40;</span>surname <span class="sy0">!</span>= <span class="kw2">null</span> <span class="sy0">?</span> surname.<span class="me1">hashCode</span><span class="br0">&#40;</span><span class="br0">&#41;</span> : <span class="nu0">0</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; result = <span class="nu0">31</span> <span class="sy0">*</span> result + <span class="br0">&#40;</span>age <span class="sy0">!</span>= <span class="kw2">null</span> <span class="sy0">?</span> age.<span class="me1">hashCode</span><span class="br0">&#40;</span><span class="br0">&#41;</span> : <span class="nu0">0</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="kw2">return</span> result<span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#125;</span></div>
</li>
</ol>
</div>
<p>Now that we&#8217;ve remembered how painful it looks, let&#8217;s dive into JDK7:  The full code would look like this (this time equals is also accepting subclasses of Test, the above example didn&#8217;t):</p>
<div class="geshi no java">
<div class="head">package pl.project13;</div>
<ol>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="co2">import java.util.Objects;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="coMULTI">/**</span></div>
</li>
<li class="li1">
<div class="de1"><span class="coMULTI">&nbsp;* Date: 4/19/11</span></div>
</li>
<li class="li1">
<div class="de1"><span class="coMULTI">&nbsp;*</span></div>
</li>
<li class="li1">
<div class="de1"><span class="coMULTI">&nbsp;* @author Konrad Malawski</span></div>
</li>
<li class="li1">
<div class="de1"><span class="coMULTI">&nbsp;*/</span></div>
</li>
<li class="li1">
<div class="de1"><span class="kw2">public</span> <span class="kw2">class</span> Test <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="kw2">private</span> <span class="kw3">String</span> &nbsp;name<span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="kw2">private</span> <span class="kw3">String</span> &nbsp;surname<span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="kw2">private</span> <span class="kw3">Integer</span> age<span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="kw2">public</span> Test<span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="kw2">public</span> Test<span class="br0">&#40;</span><span class="kw3">String</span> name, <span class="kw3">String</span> surname, <span class="kw3">Integer</span> age<span class="br0">&#41;</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="kw2">this</span>.<span class="me1">name</span> = name<span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="kw2">this</span>.<span class="me1">surname</span> = surname<span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="kw2">this</span>.<span class="me1">age</span> = age<span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="kw2">public</span> Test<span class="br0">&#40;</span><span class="kw3">String</span> name, <span class="kw3">String</span> surname<span class="br0">&#41;</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="kw2">this</span>.<span class="me1">name</span> = name<span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="kw2">this</span>.<span class="me1">surname</span> = surname<span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; @Override</div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="kw2">public</span> <span class="kw4">boolean</span> equals<span class="br0">&#40;</span><span class="kw3">Object</span> o<span class="br0">&#41;</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span><span class="kw2">this</span> == o<span class="br0">&#41;</span> <span class="kw2">return</span> <span class="kw2">true</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span><span class="sy0">!</span><span class="br0">&#40;</span>o <span class="kw2">instanceof</span> Test<span class="br0">&#41;</span><span class="br0">&#41;</span> <span class="kw2">return</span> <span class="kw2">false</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="co1">// &nbsp; &nbsp;if (o == null || getClass() != o.getClass()) return false;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; Test that = <span class="br0">&#40;</span>Test<span class="br0">&#41;</span> o<span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="kw4">boolean</span> result = <span class="kw2">true</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; result = result <span class="sy0">&amp;&amp;</span> Objects.<span class="me1">equals</span><span class="br0">&#40;</span><span class="kw2">this</span>.<span class="me1">name</span>, that.<span class="me1">name</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; result = result <span class="sy0">&amp;&amp;</span> Objects.<span class="me1">equals</span><span class="br0">&#40;</span><span class="kw2">this</span>.<span class="me1">surname</span>, that.<span class="me1">surname</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; result = result <span class="sy0">&amp;&amp;</span> Objects.<span class="me1">equals</span><span class="br0">&#40;</span><span class="kw2">this</span>.<span class="me1">age</span>, that.<span class="me1">age</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="kw2">return</span> result<span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; @Override</div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="kw2">public</span> <span class="kw4">int</span> hashCode<span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="kw2">return</span> Objects.<span class="me1">hash</span><span class="br0">&#40;</span>name, surname, age<span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#125;</span></div>
</li>
</ol>
</div>
<p>Note the<strong> Objects.hash() </strong>method, wich is really a lifesaver and also the <strong>Objects.equals()</strong> method which makes our code NullPointerException safe, which the previous version had to tackle by using <strong>?:</strong>&#8230; And it read&#8217;s much nicer, Of course, you could skip the result variable, but I decided to do it like this for the sake of easy reading.</p>
<p>And here is it&#8217;s test:</p>
<div class="geshi no java">
<div class="head">package pl.project13;</div>
<ol>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="co2">import java.util.HashSet;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="co2">import java.util.Set;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="co2">import java.util.TreeSet;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="co2">import static junit.framework.Assert.assertEquals;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="co2">import static junit.framework.Assert.assertFalse;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="co2">import static junit.framework.Assert.assertTrue;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="coMULTI">/**</span></div>
</li>
<li class="li1">
<div class="de1"><span class="coMULTI">&nbsp;* Date: 4/19/11</span></div>
</li>
<li class="li1">
<div class="de1"><span class="coMULTI">&nbsp;*</span></div>
</li>
<li class="li1">
<div class="de1"><span class="coMULTI">&nbsp;* @author Konrad Malawski</span></div>
</li>
<li class="li1">
<div class="de1"><span class="coMULTI">&nbsp;*/</span></div>
</li>
<li class="li1">
<div class="de1"><span class="kw2">public</span> <span class="kw2">class</span> TestTest <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; @org.<span class="me1">junit</span>.<span class="me1">Test</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="kw2">public</span> <span class="kw4">void</span> testEquals<span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="kw2">throws</span> <span class="kw3">Exception</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; Test test = <span class="kw2">new</span> Test<span class="br0">&#40;</span><span class="st0">&quot;Konrad&quot;</span>, <span class="st0">&quot;Malawski&quot;</span>, <span class="nu0">21</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="co1">// true</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; assertTrue<span class="br0">&#40;</span>test.<span class="me1">equals</span><span class="br0">&#40;</span>test<span class="br0">&#41;</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; assertTrue<span class="br0">&#40;</span>test.<span class="me1">equals</span><span class="br0">&#40;</span><span class="kw2">new</span> Test<span class="br0">&#40;</span><span class="st0">&quot;Konrad&quot;</span>, <span class="st0">&quot;Malawski&quot;</span>, <span class="nu0">21</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="co1">// false</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; assertFalse<span class="br0">&#40;</span>test.<span class="me1">equals</span><span class="br0">&#40;</span><span class="kw2">new</span> Test<span class="br0">&#40;</span><span class="st0">&quot;Wacław&quot;</span>, <span class="st0">&quot;Malawski&quot;</span>, <span class="nu0">1825</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; assertFalse<span class="br0">&#40;</span>test.<span class="me1">equals</span><span class="br0">&#40;</span><span class="kw2">new</span> Test<span class="br0">&#40;</span><span class="st0">&quot;Wacław&quot;</span>, <span class="st0">&quot;Malawski&quot;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; assertFalse<span class="br0">&#40;</span>test.<span class="me1">equals</span><span class="br0">&#40;</span><span class="kw2">new</span> Test<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; assertFalse<span class="br0">&#40;</span>test.<span class="me1">equals</span><span class="br0">&#40;</span><span class="kw2">new</span> <span class="kw3">Object</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; assertFalse<span class="br0">&#40;</span>test.<span class="me1">equals</span><span class="br0">&#40;</span><span class="kw2">null</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; @org.<span class="me1">junit</span>.<span class="me1">Test</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="kw2">public</span> <span class="kw4">void</span> testHashCodeOnCollections<span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="kw2">throws</span> <span class="kw3">Exception</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; Test test = <span class="kw2">new</span> Test<span class="br0">&#40;</span><span class="st0">&quot;Konrad&quot;</span>, <span class="st0">&quot;Malawski&quot;</span>, <span class="nu0">21</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="kw4">int</span> sizeBefore<span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="kw4">int</span> sizeAfter<span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="kw3">Set</span> treeSet = <span class="kw2">new</span> HashSet<span class="sy0">&amp;</span>lt<span class="sy0">;&amp;</span>gt<span class="sy0">;</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; treeSet.<span class="me1">add</span><span class="br0">&#40;</span>test<span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; sizeBefore = treeSet.<span class="me1">size</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; treeSet.<span class="me1">add</span><span class="br0">&#40;</span>test<span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; sizeAfter = treeSet.<span class="me1">size</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; assertEquals<span class="br0">&#40;</span>sizeBefore, sizeAfter<span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; @org.<span class="me1">junit</span>.<span class="me1">Test</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="kw2">public</span> <span class="kw4">void</span> testHashCodeOnCollectionsOtherObject<span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="kw2">throws</span> <span class="kw3">Exception</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; Test test = <span class="kw2">new</span> Test<span class="br0">&#40;</span><span class="st0">&quot;Konrad&quot;</span>, <span class="st0">&quot;Malawski&quot;</span>, <span class="nu0">21</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; Test test2 = <span class="kw2">new</span> Test<span class="br0">&#40;</span><span class="st0">&quot;Konrad&quot;</span>, <span class="st0">&quot;Malawski&quot;</span>, <span class="nu0">21</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="kw4">int</span> sizeBefore<span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="kw4">int</span> sizeAfter<span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="kw3">Set</span> treeSet = <span class="kw2">new</span> HashSet<span class="sy0">&amp;</span>lt<span class="sy0">;&amp;</span>gt<span class="sy0">;</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; treeSet.<span class="me1">add</span><span class="br0">&#40;</span>test<span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; sizeBefore = treeSet.<span class="me1">size</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; treeSet.<span class="me1">add</span><span class="br0">&#40;</span>test2<span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; sizeAfter = treeSet.<span class="me1">size</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; assertEquals<span class="br0">&#40;</span>sizeBefore, sizeAfter<span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#125;</span></div>
</li>
</ol>
</div>
<p>Now that was nice wasn&#8217;t it? :-) <strong>Objects </strong>probably isn&#8217;t &#8220;the&#8221; killer feature that JDK7 has, but it&#8217;s a really nice addition, so let&#8217;s get to using it :-) The other utility methods in this class are:</p>
<ul>
<li><strong>static &lt;T&gt; int	compare(T a, T b, Comparator &lt; ? super T&gt; c)</strong><br />
Returns 0 if the arguments are identical and c.compare(a, b) otherwise.</li>
<li><strong>static boolean	deepEquals(Object a, Object b)</strong><br />
Returns true if the arguments are deeply equal to each other and false otherwise.</li>
<li><strong>static boolean	equals(Object a, Object b)</strong><br />
Returns true if the arguments are equal to each other and false otherwise.</li>
<li><strong>static int	hash(Object&#8230; values)</strong><br />
Generates a hash code for a sequence of input values.</li>
<li><strong>static int	hashCode(Object o)</strong><br />
Returns the hash code of a non-null argument and 0 for a null argument.</li>
<li><strong>static &lt;T&gt; T	requireNonNull(T obj)</strong><br />
Checks that the specified object reference is not null.</li>
<li><strong>static &lt;T&gt; T	requireNonNull(T obj, String message)</strong><br />
Checks that the specified object reference is not null and throws a customized NullPointerException if it is.</li>
<li><strong>static String	toString(Object o)</strong><br />
Returns the result of calling toString for a non-null argument and &#8220;null&#8221; for a null argument.</li>
<li><strong>static String	toString(Object o, String nullDefault)</strong><br />
Returns the result of calling toString on the first argument if the first argument is not null and returns the second argument otherwise.</li>
</ul>
<p>Hooray for small litle improvements :-) This class officialy get&#8217;s Duke&#8217;s thumbs up image:</p>
<p style="text-align: center;"><img class="aligncenter" title="Java-duke" src="http://www.blog.project13.pl/wp-content/uploads/2011/04/Java-duke.jpg" alt="" width="200" height="235" /></p>
]]></content:encoded>
			<wfw:commentRss>http://www.blog.project13.pl/index.php/coding/1284/jdk7-java-lang-objects-forgotten-feature/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

