<?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>Rich Internet Applications (RIA)</title>
	<atom:link href="http://www.canoo.com/blog/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.canoo.com/blog</link>
	<description></description>
	<lastBuildDate>Wed, 18 Jan 2012 14:30:57 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>The Best Groovy Inspections You&#8217;re Not Using</title>
		<link>http://www.canoo.com/blog/2012/01/18/the-best-groovy-inspections-youre-not-using/</link>
		<comments>http://www.canoo.com/blog/2012/01/18/the-best-groovy-inspections-youre-not-using/#comments</comments>
		<pubDate>Wed, 18 Jan 2012 13:42:37 +0000</pubDate>
		<dc:creator>Hamlet</dc:creator>
				<category><![CDATA[Groovy]]></category>
		<category><![CDATA[hamlet]]></category>
		<category><![CDATA[idea]]></category>

		<guid isPermaLink="false">http://www.canoo.com/blog/?p=2433</guid>
		<description><![CDATA[<script type="text/javascript">dzone_url = "http://www.canoo.com/blog/2012/01/18/the-best-groovy-inspections-youre-not-using/";</script>pre {font-size:95%;} Many, many tools perform static analysis on code. There are all sorts of automated ways to look through your code and tell you if there are likely errors or not. FindBugs, PMD, and CheckStyle are some of the big names from the Java world. On the Groovy side we have two real options: [...]]]></description>
			<content:encoded><![CDATA[<script type="text/javascript">dzone_url = "http://www.canoo.com/blog/2012/01/18/the-best-groovy-inspections-youre-not-using/";</script><style type="text/css">
    pre {font-size:95%;}
</style>
<p>Many, many tools perform static analysis on code. There are all sorts of automated ways to look through your code and tell you if there are likely errors or not. <a href="http://findbugs.sourceforge.net/">FindBugs</a>, <a href="http://pmd.sourceforge.net/">PMD</a>, and <a href="http://checkstyle.sourceforge.net/">CheckStyle</a> are some of the big names from the Java world. On the Groovy side we have two real options: <a href="http://www.jetbrains.com/idea/">IntelliJ IDEA</a> and <a href="http://codenarc.sourceforge.net/">CodeNarc</a>.</p>
<p>This post highlights my favorite static analysis rules for Groovy in IDEA that are not enabled by default. Groovy in IDEA 11 has well over 100 rules, but less than half of them are activated when you install the product. To turn these rules on you&#8217;ll need to go into Settings (Ctrl+Alt+S) and enable them under Inspections.</p>
<p>So here are my favorites that <em>I</em> think <em>you</em> should turn on:</p>
<p><strong>Threading</strong><br />
Threading comes first because these inspections have saved my butt in the past. None of them are enabled by default, so do yourself a favor and enable a few. These ones are all must haves:</p>
<p>* <em>Access to static field locked on instance data</em> &#8211; Reading and writing a static field from multiple threads is not thread-safe. It needs to be done within a synchronized block. Do you know what happens when you synchronize on instance data, like this:<br />
<pre><pre>class MyClass {
&nbsp;&nbsp;&nbsp;&nbsp;static resource
&nbsp;&nbsp;&nbsp;&nbsp;final lock = new Object()

&nbsp;&nbsp;&nbsp;&nbsp;def initialize() {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;synchronized(lock) {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;resource = new Resource()
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;}
}</pre></pre><br />
The object &#8216;lock&#8217; is an instance field, not a static field. So this assignment within the synchronized block is not thread-safe. It is possible that the static field is accessed from multiple threads, which can lead to unspecified side effects.</p>
<p>* <em>Synchronization on non-final field</em> &#8211; If you are accessing a variable within a synchronized block then your synchronization token must be final. Consider this code:<br />
<pre><pre>class MyClass {
&nbsp;&nbsp;&nbsp;&nbsp;def resource
&nbsp;&nbsp;&nbsp;&nbsp;def lock = new Object()

&nbsp;&nbsp;&nbsp;&nbsp;def initialize() {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;synchronized(lock) {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;resource = new Resource()
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;}
}</pre></pre><br />
The field &#8216;lock&#8217; is not final, so different instances of MyClass may have different values for lock. The result is that different threads may be locking on different objects even when operating on the same object. Make your locks final.</p>
<p>* <em>Synchronization on variable initialized with literal</em> &#8211; Do you understand the problem with synchronizing on a primitive literal? Consider this code:<br />
<pre><pre>class MyClass {
&nbsp;&nbsp;&nbsp;&nbsp;def lock = &#039;my lock&#039;

&nbsp;&nbsp;&nbsp;&nbsp;def initialize() {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;synchronized(lock) {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// do something
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;}
}</pre></pre><br />
Strings are interned by the JVM, so the string &#8216;my lock&#8217; may also be used by another class. Numbers are even worse because they can be assigned from a cache. Some other object in the system may be initialized with the same literal, and could create an accidental (or malicious) dead-lock situations.</p>
<p>* <em>Unsynchronized method overrides synchronized method</em> &#8211; In some limited circumstances you may actually want to override a synchronized method with an unsynchronized one. But probably not. More than likely you don&#8217;t even know and you are accidentally creating a subtle bug. If the parent is synchronized then the child should be also. Or better yet, make the parent final.</p>
<p><strong>Probably bugs</strong><br />
* <em>Named arguments of constructor call</em> &#8211; This inspection warns you when something like the following happens when using named arguments, which is almost certainly a bug:<br />
<pre><pre>class Order {
&nbsp;&nbsp;&nbsp;&nbsp; int orderId
}

new Order(orderid: 5)</pre></pre><br />
See the problem? The field is named &#8216;orderId&#8217; with a big &#8216;I&#8217; and the constructor call uses &#8216;orderid&#8217; with a small &#8216;i&#8217;. RuntimeException if you run this code. This is a type of bug that CodeNarc cannot find because the type information of the classes is so limited. IDEA keeps track of types much better and can do nice things like this.</p>
<p>* <em>Access to unresolved expression</em> &#8211; There has been a lot of talk over the years about adding static compilation to Groovy. Some people want to be warned by the compiler or in the IDE if their Groovy code is referencing an object that does not exist. For example, they&#8217;d like this to produce a warning or error:<br />
<pre><pre>def c = { parm -&gt;
&nbsp;&nbsp;&nbsp;&nbsp;println it
}</pre></pre><br />
See the problem? The closure parameter is named &#8216;parm&#8217; but the closure references the parameter by the standard name &#8216;it&#8217;. The access to unresolved expression inspection turns this into a warning or error in the IDE. IDEA is quite smart about it too and knows all about delegate/super and the other Groovy dynamic variables. If you like this sort of thing then be sure to <a href="http://blackdragsview.blogspot.com/2011/10/feeling-grumpy.html">read up</a> on <a href="http://www.jroller.com/melix/entry/groovy_static_type_checker_status">Grumpy mode</a> in Groovy 2, coming soon.</p>
<p><strong>Control Flow</strong><br />
There are many features in Groovy that simplify standard and verbose Java code. Two of these are the Elvis operator and the Null-Safe Dereference. IDEA contains inspections to help you migrate to the new way of writing code with these features.</p>
<p>* <em>Conditional expression can be elvis &#8211; </em>This inspection migrates you from code like this:<br />
<pre>def x = value != null ? value : 2</pre><br />
And suggests you rewrite it into the equivalent Groovy:<br />
<pre>def x = value ?: 2</pre><br />
Is it always safe to make this transformation? (Think about it for a few seconds). GroovyTruth means it is not. Technically speaking, the two code snippets are not equivalent: <em>value != null</em> may be true while <em>value</em> is false, such as when value is an empty String. Overall, I like the inspection but you need to be careful with it.</p>
<p>* <em>Conditional expression can be conditional call &#8211; </em>This inspection promotes the use of the Null-Safe dereference. This following code produces a violation:<br />
<pre>def x = value != null ? value.toString() : null</pre><br />
&#8230; and you will be prompted to transform it ito:<br />
<pre>def x = value?.toString()</pre><br />
These two code blocks really are the same and this can be safely accepted as the correct way to write the code.</p>
<p>* <em>If statement (or conditional) with identical branches </em>- I periodically refactor code and accidentally leave an if or conditional statement with identical branches. These are of course redundant and can be cleaned up by removing the if expression. If you have good unit tests and use automated refactorings then this sort of things happens from time to time. The cleanup reminder is nice.</p>
<p><strong>Error Handling</strong><br />
* <em>Unused catch parameter </em>- My favorite Error Handling inspection is &#8216;Unused catch parameter&#8217;. Consider this code:<br />
<pre><pre>try {
&nbsp;&nbsp;&nbsp;&nbsp;doSomething()
} catch (e) {
&nbsp;&nbsp;&nbsp;&nbsp;LOG.error(&#039;unexpected error occurred&#039;)
}</pre></pre><br />
What happens to the stack trace in this scenario? It gets eaten up, never to appear in a log. You shouldn&#8217;t have any unused catch parameters. If you really don&#8217;t care about the exception then name it &#8216;ignore&#8217; or &#8216;ignored&#8217; to suppress the warning.</p>
<p><strong>Validity issues</strong><br />
* <em>Duplicate switch case</em> &#8211; Groovy has Switch on Steroids, meaning you can put almost any object in the case statement, including regular expressions:<br />
<pre><pre>switch (input) {
&nbsp;&nbsp;&nbsp;&nbsp;case ~/[0-9]/ : println &#039;numeric!&#039;; break
&nbsp;&nbsp;&nbsp;&nbsp;case ~/[0-9]/ : println &#039;a number&#039;; break
}</pre></pre><br />
See the problem? The same regex appears twice. The second case will never be executed, even if it would match. As long as your case statements have literals in them then IDEA can verify that there are no duplicates.</p>
<p><strong>Naming Conventions</strong><br />
Lastly, there are a whole bunch of naming convention inspections that you can activate and configure. If you&#8217;re not using CodeNarc (why not?) then you should at least activate some of these. Standards, on a whole, are good to adhere to.</p>
<p><strong>IDEA Inspections of CodeNarc?</strong><br />
So which should you use, IDEA or CodeNarc? These two tools complement each other. There is good reason to use both CodeNarc and IDEA together. CodeNarc does have more inspections than IDEA, but the IDE integration in IDEA is better. Pressing Alt+Enter typically rewrites the offending code, and the speed of the actions are much better in IDEA. Also, the static analysis rules do not overlap between the products because the CodeNarc developers (that&#8217;s Chris Mair and myself) already use IDEA and made a conscious effort not to duplicate anything.</p>
<p>And if you do want to use CodeNarc and IDEA, then you might try out the <a href="http://plugins.jetbrains.com/plugin/?idea&amp;id=5925">CodeNarc IDEA plugin</a>.</p>
<p>If you like this then you might check out some of my other IDEA related posts: <a href="http://hamletdarcy.blogspot.com/2008/04/10-best-idea-inspections-youre-not.html">The 10 Best Inspections You&#8217;re Not Using (in Java)</a>, or the IDEA archive on <a href="http://hamletdarcy.blogspot.com/search/label/IDEA">my blog</a> and the <a href="http://www.canoo.com/blog/tag/idea/">Canoo blog</a>.</p>
<p>And remember if you need Groovy and Grails help, then give us a call or drop me an email at hamlet.darcy@canoo.com</p>
<script>var dzone_style="2";</script><script language="javascript" src="http://widgets.dzone.com/widgets/zoneit.js"></script>]]></content:encoded>
			<wfw:commentRss>http://www.canoo.com/blog/2012/01/18/the-best-groovy-inspections-youre-not-using/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Android Testing in IntelliJ IDEA</title>
		<link>http://www.canoo.com/blog/2012/01/12/android-testing-in-intellij-idea/</link>
		<comments>http://www.canoo.com/blog/2012/01/12/android-testing-in-intellij-idea/#comments</comments>
		<pubDate>Thu, 12 Jan 2012 13:19:08 +0000</pubDate>
		<dc:creator>Hamlet</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[hamlet]]></category>
		<category><![CDATA[idea]]></category>

		<guid isPermaLink="false">http://www.canoo.com/blog/?p=2411</guid>
		<description><![CDATA[<script type="text/javascript">dzone_url = "http://www.canoo.com/blog/2012/01/12/android-testing-in-intellij-idea/";</script>Google&#8217;s Android site has some fairly detailed instructions for testing Android applications&#8230; from Eclipse. They were nice enough to supply a &#8220;Testing from Other IDEs&#8221; page, but that is nothing more than instructions on using Ant and the command line. Well, if you are using IntelliJ IDEA then you already believe the IDE is going [...]]]></description>
			<content:encoded><![CDATA[<script type="text/javascript">dzone_url = "http://www.canoo.com/blog/2012/01/12/android-testing-in-intellij-idea/";</script><p>Google&#8217;s Android site has some fairly detailed instructions for testing Android applications&#8230; from Eclipse. They were nice enough to supply a &#8220;<a href="http://developer.android.com/guide/developing/testing/testing_otheride.html">Testing from Other IDEs</a>&#8221; page, but that is nothing more than instructions on using Ant and the command line. Well, if you are using IntelliJ IDEA then you already believe the IDE is going to be a better tool than Ant for this. It&#8217;s easy to set up a test project in IDEA and get your tests running. Here are some simple instructions.</p>
<p><strong>Prerequisites</strong></p>
<p>This tutorial assumes you have installed <a href="http://www.jetbrains.com/idea/">IntelliJ IDEA</a> and an <a href="http://developer.android.com/sdk/">Android SDK</a>, and also created an Android project. If you haven&#8217;t yet, then you should read <a href="http://developer.android.com/guide/topics/testing/testing_android.html">Testing Fundamentals</a> accessible from Google&#8217;s <a href="http://developer.android.com/guide/topics/testing/index.html">Testing Home</a> page.</p>
<p><strong>Creating a Test Project</strong></p>
<p>Your Android tests are going to be placed in a separate module from your main Android application. Remember: an IDEA <em>project</em> is composed of several <em>modules</em>. We&#8217;re going to have the main application module and the test module. Each module has it&#8217;s own set of dependencies and classpath. (Eclipse users confused about the terminology should <a href="http://www.jetbrains.com/idea/webhelp/intellij-idea-vs-eclipse-terminology.html">read this</a>). Here are the steps to follow to set up a test project:</p>
<p>1. Have your main project open in IDEA<br />
2. Create a new module using the menu File-&gt;New Module<br />
3. Select &#8220;Create module from scratch&#8221; and click Next<br />
4. Select &#8220;Android Module&#8221;, give the module a new name, and click Next. You should put the module in a directory called &#8220;tests&#8221; that is in your project root. That way your project will follow the same naming conventions that Ant expects, making the project easier to set up in a CI server later. Here is what your wizard screen might look like:</p>
<div id="attachment_2415" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.canoo.com/blog/wp-content/uploads/2012/01/01AddModule.png"><img class="size-medium wp-image-2415" title="Adding an Android Testing Module" src="http://www.canoo.com/blog/wp-content/uploads/2012/01/01AddModule-300x207.png" alt="Adding an Android Testing Module" width="300" height="207" /></a><p class="wp-caption-text">Adding an Android Testing Module</p></div>
<p>5. On the next wizard step just click Next to create a source directory for your files.<br />
6. Finally, on the last wizard step select &#8220;Test&#8221; under Project properties. Make sure it is going to test your module. Then Finish.</p>
<div id="attachment_2422" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.canoo.com/blog/wp-content/uploads/2012/01/02AddModule1.png"><img class="size-medium wp-image-2422" title="02AddModule - Select Test" src="http://www.canoo.com/blog/wp-content/uploads/2012/01/02AddModule1-300x207.png" alt="" width="300" height="207" /></a><p class="wp-caption-text">Select Test as Project Type</p></div>
<p>At this point your two modules exist: the production module and your test module. If you look in the Project View (Alt+1) you will see both modules. Mine are named &#8220;android-testing-in-idea&#8221; and &#8220;tests&#8221;. You&#8217;ll even be given a template test for your main activity. It&#8217;s pretty slim so you will certainly want to write some of your own tests. IDEA isn&#8217;t smart enough to automatically create the test content for you&#8230; at least yet.</p>
<p><span style="font-weight: bold;">Running Tests</span></p>
<p>Running tests is simple. A run configuration to run all tests was created for you when you added the project. Click the &#8216;run triangle&#8217; to run the tests or the &#8216;bug triangle&#8217; to debug the tests. You&#8217;ll be prompted to select an emulator if you don&#8217;t have one set by default.</p>
<div id="attachment_2424" class="wp-caption aligncenter" style="width: 308px"><a href="http://www.canoo.com/blog/wp-content/uploads/2012/01/03ProjectView.png"><img class="size-medium wp-image-2424" title="03ProjectView" src="http://www.canoo.com/blog/wp-content/uploads/2012/01/03ProjectView-298x300.png" alt="run all tests" width="298" height="300" /></a><p class="wp-caption-text">Click to Run All Tests</p></div>
<p>There are other ways to run tests at a more granular level, too. To run all the tests in a package, right click the package and select Run (Ctrl+Shift+F10). To run all the tests in a class, right click the class and select Run (Ctrl+Shift+F10). You can also run individual test methods one at a time. Just right click inside the test method within the IDE editor and select Run (once again, (Ctrl+Shift+F10)).</p>
<p>You may want to switch the emulator version from time to time in order to test across multiple devices. You can bring up the Run Configuration from the drop down menu highlighted in the screenshot above. It opens a screen like this where you configure the run target:</p>
<div id="attachment_2425" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.canoo.com/blog/wp-content/uploads/2012/01/05RunConfigAllTests.png"><img class="size-medium wp-image-2425" title="05RunConfigAllTests" src="http://www.canoo.com/blog/wp-content/uploads/2012/01/05RunConfigAllTests-300x209.png" alt="Configure the Test Run Target" width="300" height="209" /></a><p class="wp-caption-text">Configure the Test Run Target</p></div>
<p>You can switch the emulator here to a different version. Be sure to check out the other tabs as well. The Emulator tab allows you to configure the network speed and latency, and the Logcat tabs lets you configure one or two things about Logcat. Handy.</p>
<p><span style="font-weight: bold;">Viewing Results</span></p>
<p>So you want to view the test results? Well results window probably popped up on screen after you ran the test. Anyway, if you&#8217;re still confused you can click the Run (Alt+4) or Debug (Alt+5) drawer and see the JUnit results. There is also a Logcat drawer to click (sorry no shortcut) to view the logs.</p>
<div id="attachment_2426" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.canoo.com/blog/wp-content/uploads/2012/01/07Results.png"><img class="size-medium wp-image-2426" title="07Results" src="http://www.canoo.com/blog/wp-content/uploads/2012/01/07Results-300x240.png" alt="Viewing Test Results" width="300" height="240" /></a><p class="wp-caption-text">Viewing Test Results</p></div>
<p><strong>Other Tools</strong></p>
<p>The last thing you need to know is a little about the other tools. You can manage your emulator ROMs using the AVD Manager. The menu option for that is Tools -&gt; Android -&gt; AVD Manager. Also, you can change the project compatibility to be a different version of Android OS. It&#8217;s under File-&gt;Project Structure (Ctrl+Alt+Shift+S) then click Module SDK. Finally, if you want to set the project up for continuous integration then head on back to the Ant command line guide from Google. It&#8217;s best not to have the IDEA project file drive your builds.</p>
<p>You made it to the end. Thanks for reading! And remember, Canoo is here to help with your Android and Mobile needs. Email me directly (hamlet.darcy@canoo.com) or give us a phone call. Thanks.</p>
<script>var dzone_style="2";</script><script language="javascript" src="http://widgets.dzone.com/widgets/zoneit.js"></script>]]></content:encoded>
			<wfw:commentRss>http://www.canoo.com/blog/2012/01/12/android-testing-in-intellij-idea/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>IntelliJ IDEA 11 for the Groovy Developer</title>
		<link>http://www.canoo.com/blog/2011/12/20/intellij-idea-11-for-the-groovy-developer/</link>
		<comments>http://www.canoo.com/blog/2011/12/20/intellij-idea-11-for-the-groovy-developer/#comments</comments>
		<pubDate>Tue, 20 Dec 2011 09:51:06 +0000</pubDate>
		<dc:creator>Hamlet</dc:creator>
				<category><![CDATA[Groovy]]></category>

		<guid isPermaLink="false">http://www.canoo.com/blog/?p=2390</guid>
		<description><![CDATA[<script type="text/javascript">dzone_url = "http://www.canoo.com/blog/2011/12/20/intellij-idea-11-for-the-groovy-developer/";</script>pre {font-size:95%;} IntelliJ IDEA 11 was released a few weeks ago, and it contains quite a few new features for the Groovy developer. Everything listed here is in the free and open source Community Edition of IntelliJ IDEA. There are plenty of new Grails features as well, but I wanted to separate out the Ultimate [...]]]></description>
			<content:encoded><![CDATA[<script type="text/javascript">dzone_url = "http://www.canoo.com/blog/2011/12/20/intellij-idea-11-for-the-groovy-developer/";</script><style type="text/css">
pre {font-size:95%;}
</style>
<p><a href="http://www.jetbrains.com/idea/">IntelliJ IDEA 11</a> was released a few weeks ago, and it contains quite a few new features for the Groovy developer. Everything listed here is in the free and open source <a href="http://www.jetbrains.com/idea/free_java_ide.html">Community Edition</a> of IntelliJ IDEA. There are plenty of new Grails features as well, but I wanted to separate out the Ultimate Edition features into a different post. So let&#8217;s jump in.</p>
<h2>Groovy 2.0 Support</h2>
<p>The big promoted feature of IDEA 11 is the Groovy 2.0 support, which is itself mostly Java 7 support. In case you&#8217;re confused: Java 7 added some small language feature to Java (<a href="http://www.canoo.com/blog/2011/07/14/java-7-small-language-changes-screencast/">more here</a>), and Groovy naturally supports the same syntax. The Project Coin Java changes are by definition small language changes, so don&#8217;t expect anything too major in terms of productivity boosts.</p>
<p>The first feature is underscores in numeric literals:<br />
<pre>assert 1000000 == 1_000_000 : &#039;How awesome is that?&#039;</pre>Underscores in Number Literals</p>
<p>Do you really need an explanation of this? OK, here it is then. You can put underscores into numbers and the compiler rips them out. They are just ignored. Just look at the .class file in a decompiler if you don&#8217;t believe me.</p>
<p>The second feature is binary literals:<br />
<pre>assert 0b1001_1001 == 153: &#039;mind == blown&#039;</pre>Binary Literals</p>
<p>This lets you specify integers using a binary format. As far as I can tell, this is mostly used if you&#8217;re constructing bit-masks to represent multiple states within one integer. You know, you could also use objects to do that and it might be clearer. But there are always times when you need this.</p>
<p>The third feature is multi-catch, which is the most useful feature of the three:<br />
<pre><pre>try {
&nbsp;&nbsp;&nbsp;&nbsp;takeArrowToKnee()
} catch (InjuryException
&nbsp;&nbsp;&nbsp;&nbsp; | LowHealthException
&nbsp;&nbsp;&nbsp;&nbsp; | LowStaminaException e) {

&nbsp;&nbsp;&nbsp;&nbsp;becomeTownGuard() // retire to a simpler life
}</pre></pre>Java 7 Multi-Catch</p>
<p>This lets you catch multiple exception types in one catch block. In Java, you can Alt+Enter on an old-style catch to convert it into a multi-catch, but you can&#8217;t yet do that in Groovy. Don&#8217;t worry though, I created a ticket and it will soon be implemented&#8230;</p>
<h2>Refactorings</h2>
<p>For me the Groovy refactorings are one of the killer features of IDEA. There are a pair of nice upgrades in IDEA 11 in this area. The first is that Introduce Parameter works for closures now and not just methods. So if you start with something like this, where the literal 50 is hard-coded:<br />
<pre><pre>def adventure = {

&nbsp;&nbsp;&nbsp;&nbsp;killMonsters() &amp;&amp; collectLoot()
&nbsp;&nbsp;&nbsp;&nbsp;if (health &lt; 50) drinkPotion()
}</pre></pre>Introduce Parameter for Closures</p>
<p>You can highlight the 50 and press Ctrl+Alt+P to Introduce a Parameter:<br />
<pre><pre>def adventure = { int minimum -&gt;

&nbsp;&nbsp;&nbsp;&nbsp;killMonsters() &amp;&amp; collectLoot()
&nbsp;&nbsp;&nbsp;&nbsp;if (health &lt; minimum)&nbsp;&nbsp;drinkPotion()
}</pre></pre>Ctrl+Alt+P to Introduce Parameter</p>
<p>OK, so that is nice. A less well-known intention is the Unwrap Statement intention. Unwrap takes a statement that is wrapped in some sort of loop or conditional, and it removes that conditional. Witness:</p>
<p><a href="http://www.canoo.com/blog/wp-content/uploads/2011/12/unwrap.png"><img src="http://www.canoo.com/blog/wp-content/uploads/2011/12/unwrap.png" alt="" title="unwrap" width="379" height="388" class="aligncenter size-full wp-image-2394" /></a></p>
<p>Start with an If statement, choose to unwrap it, and you&#8217;re left with only the enclosed logic. Now that you know this trick, you will start to use it more often. It&#8217;s surprisingly useful.</p>
<h2>Intentions and Inspections</h2>
<p>There are also a couple of good, new intentions and inspections in 11. On the inspection side is the new &#8220;Incompatible In&#8221; inspection. You can use the &#8216;in&#8217; keyword in, which is normally the inverse of &#8216;contains&#8217;. Using the in keyword to do incompatible type comparisons now triggers an IDE warning:</p>
<p><a href="http://www.canoo.com/blog/wp-content/uploads/2011/12/incompatiblein.png"><img src="http://www.canoo.com/blog/wp-content/uploads/2011/12/incompatiblein.png" alt="" title="incompatiblein" width="406" height="91" class="aligncenter size-full wp-image-2395" /></a></p>
<p>It&#8217;s a dynamically typed language, but as you can see the tools can easily catch your small type errors.</p>
<p>Also in 11 is my favorite intention, Convert JUnit Assertion to Assert. This converts your old-style JUnit assertion methods into Groovy power-asserts:</p>
<p><a href="http://www.canoo.com/blog/wp-content/uploads/2011/12/assert.png"><img src="http://www.canoo.com/blog/wp-content/uploads/2011/12/assert.png" alt="" title="assert" width="417" height="444" class="aligncenter size-full wp-image-2396" /></a></p>
<p>Just position the cursor at the method call and press Alt+Enter. And if you&#8217;re not sure why power asserts are an improvement then <a href="http://hamletdarcy.blogspot.com/2009/05/new-power-assertions-in-groovy.html">read this</a>.</p>
<p>Also in IDEA 11 is &#8216;Split If&#8217; and &#8216;Invert If&#8217;. We wrote these intentions ourselves at Hackergarten in Devoxx. Horray for open source! Split If takes a compound boolean operation like &#8216;if (a &amp;&amp; b) { &#8230; }&#8217; and converts it into &#8216;if (a) { if (b) { &#8230; } }. Invert If takes the boolean conditional in the If and inverts it. Both intentions are invoked with Alt+Enter and they are both described in more detail over at the <a href="http://blogs.jetbrains.com/idea/2011/11/jetbrains-contributes-to-open-source-at-devoxx/">JetBrains IDEA blog</a>.</p>
<p>Besides that, the Import system got some new improvements as well. You can now use Alt+Enter to swap a qualified reference with an import, add a single-member static import, or add an on-demand static import. And my favorite: copy and paste within the IDE now carries the import statements with it. So if you copy a reference to the clipboard and paste it, then IDEA will ask you if you want to update the import statements. Whenever I switch back to a text editor I always miss the seamless import statement management provided by the IDE.</p>
<h2>Groovy Isms</h2>
<p>What else? Well, the IDE is now aware of @Category annotations and gives you correct code completion based on them. And you can finally specify a command line parameter when running a Groovy script from within IDEA. Hint: it&#8217;s the box marked &#8216;Script Parameters&#8217;:</p>
<p><a href="http://www.canoo.com/blog/wp-content/uploads/2011/12/clitest.png"><img src="http://www.canoo.com/blog/wp-content/uploads/2011/12/clitest-300x202.png" alt="" title="clitest" width="300" height="202" class="aligncenter size-medium wp-image-2397" /></a></p>
<p>Managing dependencies with Jars and Grapes got easier. If you annotate a script with @Grape when IDEA has always imported that dependency into the project for you. Well now IDEA removes obsolete @Grapes references when you no longer need them.</p>
<p>Lastly, there are many small UI improvements, such as overriding properties now have a gutter icon to show the relationship, multiple declarations on a single line now have better alignment, and pasting a slashy string now escapes the slashes. There are more as well, but they are even more minor.</p>
<h2>Plus Grails Plus Java Plus&#8230;</h2>
<p>And don&#8217;t forget, all the base improvements of IDEA, especially the speed improvements, will be felt in Groovy. The database UI has improved, the Navbar has improved, Git support has improved. It&#8217;s all there whether you&#8217;re in Java or Groovy. And like I said at the start, Grails has many improvements but they aren&#8217;t covered here&#8230; maybe in a later post after the holidays.</p>
<p>So long and happy holidays!</p>
<p>Need help with Groovy or Grails? Canoo Engineering offers training, consulting, and project delivery. Contact me directly at <a href="mailto://hamlet.darcy@canoo.com">hamlet.darcy@canoo.com</a> for more information.</p>
<script>var dzone_style="2";</script><script language="javascript" src="http://widgets.dzone.com/widgets/zoneit.js"></script>]]></content:encoded>
			<wfw:commentRss>http://www.canoo.com/blog/2011/12/20/intellij-idea-11-for-the-groovy-developer/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>The Art of Groovy Command Expressions in DSLs</title>
		<link>http://www.canoo.com/blog/2011/12/08/the-art-of-groovy-command-expressions-in-dsls/</link>
		<comments>http://www.canoo.com/blog/2011/12/08/the-art-of-groovy-command-expressions-in-dsls/#comments</comments>
		<pubDate>Thu, 08 Dec 2011 09:00:34 +0000</pubDate>
		<dc:creator>Hamlet</dc:creator>
				<category><![CDATA[Groovy]]></category>
		<category><![CDATA[DSLs]]></category>
		<category><![CDATA[hamlet]]></category>

		<guid isPermaLink="false">http://www.canoo.com/blog/?p=2358</guid>
		<description><![CDATA[<script type="text/javascript">dzone_url = "http://www.canoo.com/blog/2011/12/08/the-art-of-groovy-command-expressions-in-dsls/";</script>pre {font-size:95%;} Domain Specific Languages (DSLs) are often littered with the accidental complexity of the host language. Have you ever seen a supposedly &#8220;friendly&#8221; language expression like &#8220;ride(minutes(10)).on(bus).towards(Basel)&#8221;. The newest version of Groovy contains a language feature that aims to eliminate the noise of all those extra periods and parenthesis, so that your DSL looks [...]]]></description>
			<content:encoded><![CDATA[<script type="text/javascript">dzone_url = "http://www.canoo.com/blog/2011/12/08/the-art-of-groovy-command-expressions-in-dsls/";</script><style type="text/css">
pre {font-size:95%;}
</style>
<p><em>Domain Specific Languages (DSLs) are often littered with the accidental complexity of the host language. Have you ever seen a supposedly &#8220;friendly&#8221; language expression like &#8220;ride(minutes(10)).on(bus).towards(Basel)&#8221;. The newest version of Groovy contains a language feature that aims to eliminate the noise of all those extra periods and parenthesis, so that your DSL looks more like &#8220;ride 10.minutes on bus towards Basel&#8221;. This article shows you step-by-step how to use Groovy Command Expressions and plain old metaprogramming to write just this DSL, and also offers advice on when, and when not, to use this new language feature.</em></p>
<h2>The State of the Art with DSLs</h2>
<p>Domain Specific Languages (DSLs) have been in vogue for a long time, and the topic has featured regularly at No Fluff shows for years now. The value proposition of a DSL rests in the idea that programmers and users benefit from expressing their desires in a language closer to English than to Java, using words suited to the problem domain rather than the programming language. The goal is <em>not</em> to create an entire new language, but to create a small language just big enough for users to capture their commands and intents in a more natural way than is typically possible in code.</p>
<p>Different languages support DSLs in various ways. Some languages make it easy to write nice, readable natural language-ish code and others do not. Over the next few pages we&#8217;ll explore the state of the art with Groovy DSLs, starting with looking at some unimaginative Groovy code, seeing how to convert into a better fluent interface, transforming it further using metaprogramming, and finally showing the full power of Groovy Command Expressions. As a sample problem, imagine trying to specify directions on how to get somewhere. By the end of the article you&#8217;ll understand how the Groovy code in Listing 1 works even though to looks almost like plain English sentences.<br />
<pre><pre>stand 7.minutes at busstop
ride 10.stops on bus towards Basel
stand 5.minutes at tramstop
ride 3.stops on tram towards Birsfelden</pre></pre>Listing 1: A DSL for giving Directions</p>
<h2>The Canvas</h2>
<p>We&#8217;ll use the same running example through all of the exercises. So let&#8217;s start by painting out a few primitive ideas. Think of these basic building blocks as the undercoat to our DSL canvas. Thinking about your domain is always a good place to start if you&#8217;re considering writing a DSL. Think, analyze, and compare the domain to see how it should be naturally organized. If you read the example in Listing 1, you may notice a few similarities between the different lines of code. There are actions, such as &#8216;stand&#8217; and &#8216;ride&#8217;. There are vehicles, such as a &#8216;bus&#8217; or a &#8216;tram&#8217;. And there are locations, such as the &#8216;bus stop&#8217;, &#8216;Basel&#8217;, and &#8216;Birsfelden&#8217;. We&#8217;ll model the actions as methods later, so let&#8217;s skip those for now. Vehicles and Locations are fairly straightforward, so we&#8217;ll model those as Java enums, as shown in Listing 2. I&#8217;ve put them in a package so that I can do a static import on them later.<br />
<pre><pre>package nfjs

enum Location {
&nbsp;&nbsp;&nbsp;&nbsp;busstop, Basel, tramstop, Birsfelden
}
enum Vehicle {
&nbsp;&nbsp;&nbsp;&nbsp;bus, tram
}</pre></pre>Listing 2: Modeling Locations and Vehicles</p>
<p>There is also something else in common between all of the instructions from Listing 1. They all have a duration or distance, such as &#8217;7 minutes&#8217; or &#8217;10 stops&#8217;. A duration is a little bit harder to model, but not much so. For sake of simplicity, we&#8217;ll just define a Duration class that represents either a unit of time or a unit of distance, as shown in Listing 3. I applied the TupleConstructor annotation to generate a set of constructors on the object, making it a little easier to work with. <pre><pre>@TupleConstructor
class Duration {
&nbsp;&nbsp;&nbsp;&nbsp;int value
&nbsp;&nbsp;&nbsp;&nbsp;String unit

&nbsp;&nbsp;&nbsp;&nbsp;String toString() {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&quot;$value $unit&quot;
&nbsp;&nbsp;&nbsp;&nbsp;}
}</pre></pre>Listing 3: Modeling a Duration</p>
<p>The last bit of undercoat to apply to our canvas is the Instruction object itself. Listing 1 creates a list of Instructions behind the scenes, so we&#8217;ll need to model those as well. Similar to Duration, it&#8217;s a simple data type with a few properties and is shown in Listing 4.<pre><pre>@TupleConstructor
class Instruction {
&nbsp;&nbsp;String action
&nbsp;&nbsp;Location location
&nbsp;&nbsp;Duration duration
&nbsp;&nbsp;Vehicle vehicle

&nbsp;&nbsp;String toString() {
&nbsp;&nbsp;&nbsp;&nbsp;if (vehicle != null) {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&quot;$action $duration on $vehicle towards $location&quot;
&nbsp;&nbsp;&nbsp;&nbsp;} else {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&quot;$action $duration at $location&quot;
&nbsp;&nbsp;}
}</pre></pre>Listing 4: Modeling an Instruction</p>
<p>An Instruction has an action (stand or ride), a location (bus stop or Basel), a duration (five minutes or three stops), and optionally a vehicle (a bus or a tram). Now that the undercoat is applied, let&#8217;s look at some different ways to construct these Instruction objects.</p>
<h2>Cave Paintings</h2>
<p>The most primitive way to create Instructions is to call the constructors of objects directly. This is hardly a DSL but at least it is an improvement over the Java equivalent. There&#8217;s not much here to be proud of, and list literals like [] and the leftShift operator to add list elements is only a slight improvement over the alternative. At least Listing 5 is rather short.<pre><pre>import static cmdexprs.Location.*
import static cmdexprs.Vehicle.*

instructions = []

instructions &lt;&lt; new Instruction(
&nbsp;&nbsp;&nbsp;&nbsp;&#039;stand&#039;, busstop, new Duration(5, &#039;minutes&#039;) 
)
instructions &lt;&lt; new Instruction(
&nbsp;&nbsp;&nbsp;&nbsp;&#039;ride&#039;, Basel, new Duration(10, &#039;stops&#039;), bus
) </pre></pre>Listing 5: Creating Instructions Explicitly </p>
<p>The problems with this code sample is that there is a lot of accidental complexity: pieces of the underlying programming language bleed through and obscure the intent. In the first instance, only the words &#8216;stand bustop 5 minutes&#8217; are essential to the problem of creating instructions. The other 59 of the 79 characters are non-essential complexity. A 25% signal to noise ratio is pretty poor. The classical solution to this problem (in a sense that it can be applied to Java code as well) is to create a fluent interface around Instruction objects so that the end user is shielded from these implementation details.<br />
<h2>Classicism</h2>
<p>A fluent interface is a way to chain method calls together in order to eliminate a lot of the noise associated with configuring data. Fluent interfaces can be created with statically compiled languages as well (like Java) and requires no special metaprogramming facilities in the host language. The trick is to be creative with method return types. Listing 6 shows the result of improving our signal to noise ration after refactoring to a fluent interface. <pre><pre>stand(minutes(5)).at(busstop)
ride(minutes(10)).on(bus).towards(Basel)</pre></pre>Listing 6: A Fluent Interface for Instructions </p>
<p>This is a big improvement and raises or signal to noise ratio from 25% all the way up to 75%. The only noise left in this example is the parenthesis party nestled between all the interesting bits. Hmmm, looks like someone invited a few periods along as well. We&#8217;ll do better in the next example, but let&#8217;s look at how to implement this fluent interface first.  </p>
<p>As I said, the trick is to be creative with return types. For example, the code &#8216;minutes(5)&#8217; actually instantiates a Duration object for us (Listing 7), which is then passed into the &#8216;stand&#8217; method as an argument.  <pre><pre>def minutes(int length) { 
&nbsp;&nbsp;&nbsp;&nbsp;new Duration(length, &#039;minutes&#039;) 
} </pre></pre>Listing 7: A minutes Method </p>
<p>The trick is to make all of the method calls chain together. So the &#8216;stand&#8217; method needs to return something that has an &#8216;at&#8217; method on it, and that in turn needs to accept a Location parameter and create the actual Instruction. Technically speaking, stand is a higher-order function: it is a method that returns to you a method. Groovy&#8217;s dynamic typing and map-implemented interfaces make this a pretty simple task, as shown in Listing 8.  <pre><pre>def stand(Duration duration) {&nbsp;&nbsp;&nbsp;&nbsp; 
&nbsp;&nbsp;[at: { Location loc -&gt;
&nbsp;&nbsp;&nbsp;&nbsp;instructions &lt;&lt; new Instruction(&#039;stand&#039;, loc, duration)
&nbsp;&nbsp;}]
}</pre></pre>Listing 8: The stand Method returns another Method</p>
<p>In Groovy, an object can be created as a Map literal using the [key: value] syntax. If the keys are Strings and the values or Closures, then that object can be treated as an object and have methods invoked on it, which is what Listing 8 shows.</p>
<p>At first, fluent interfaces often seem complex to implement. But after writing one or two you&#8217;ll often find it is really not too difficult. You have to think differently about how you craft an API, but in the end you can get a lot of usage and nice APIs using a fluent interface instead of metaprogramming. Let&#8217;s turn now towards bouncing some of those pesky parentheses out of the party using a little Groovy metaClass magic.</p>
<h2>Impressionism</h2>
<p>In our tour of DSL art, I&#8217;m calling the next technique impressionism. Like impressionist paintings, it does a slightly better job of capturing the intent than the previous example, but if you examine it closely it doesn&#8217;t seem to be much clearer than the alternatives. The motivating code is in Listing 9, can you spot the difference? <pre><pre>stand(5.minutes).at(busstop)
ride(10.stops).on(bus).towards(Basel)</pre></pre>Listing 9: Five Minutes not Minutes Five</p>
<p>There are two less parentheses, but an added period. &#8216;minutes(5)&#8217; became &#8217;5.minutes&#8217;. The signal to noise ratio improvement is marginal; the advantage here is that the code more closely resembles the away we speak. Nobody sticks their head over the cube wall at 12:05 and asks, &#8220;Do you want to go to lunch in minutes 5?&#8221; Instead, they say &#8220;5 minutes&#8221;, which is exactly what this code says. This is a small change to implement, and listing 10 shows that making the language support singular and plural words is just a few lines of code. <pre><pre>
Integer.metaClass.getMinute&nbsp;&nbsp;= { new Duration(delegate, &#039;minute&#039;) }
Integer.metaClass.getMinutes = { new Duration(delegate, &#039;minutes&#039;) }
Integer.metaClass.getStop&nbsp;&nbsp;&nbsp;&nbsp;= { new Duration(delegate, &#039;stop&#039;) }
Integer.metaClass.getStops&nbsp;&nbsp; = { new Duration(delegate, &#039;stops&#039;) }</pre></pre>Listing 10: Metaprogramming the Duration</p>
<p>What&#8217;s happening here is that we&#8217;re adding a method called &#8216;minutes&#8217; and &#8216;minute&#8217; onto the Integer class, and this method is creating the Duration object for us. Other than replacing the old &#8216;minutes()&#8217; method with these four lines of code, there is no change to the previous example. The code all just stays the same.</p>
<p>The combination of fluent interface and metaprogramming is powerful. Sure, there are some issues with periods and parentheses, but overall it is a pretty big improvement over trying to call constructors and wire objects together in Java. Groovy 1.8 takes things a little bit further and leaves us with the best example yet.</p>
<h2>Expressionism</h2>
<p>The last example is the best. It contains a minimum of accidental complexity and Groovy bleed-through and looks almost like the English language equivalent. For fun, I encourage you to compare Listing 11 with the cave paintings listing in Listing 5. It&#8217;s quite a bit improved.<pre><pre>stand 7.minutes at busstop
ride 10.stops on bus towards Basel</pre></pre>Listing 11: Command Expressions</p>
<p>I call this final version Expressionism, not because it relates very well to the 20th century art movement of the same name, but because it uses a new feature called Command Expressions and is the most expressive of all the examples.</p>
<p>So what are the code changes? You might notice that there are no more listings in this article. That&#8217;s right, command expressions are just the way code may be written now. Listing 11 showing the command expression usage and Listing 9 without the usage are functionally equivalent. &#8216;Stand&#8217; and &#8216;ride&#8217; are still method calls that return the &#8216;at&#8217; and &#8216;on&#8217; methods. As long as the code follows the follows the pattern &#8216;method parameter method parameter method parameter&#8217; then it gets converted into &#8216;method(parameter).method(parameter).method(parameter)&#8217;. You can chain as many together as you like; Groovy won&#8217;t complain. The result is a nice readable chain of expressions without any additional effort. At the time being, Command Expressions are the state of the art when it comes to DSLs in Groovy.</p>
<h2>Art Criticism</h2>
<p>There are a couple of pitfalls to be wary of. Command expressions are shown here in the best possible light in order to display their power. In reality, they are also a little fragile. Any code not following the &#8216;method parameter method parameter&#8217; rhythm doesn&#8217;t easily fit into the command expression pattern. The result is that you might have to twist your words a little to make them fit into this pattern, which moves it away from natural language and towards accidental complexity. Also, there is always the Groovy grammar and keywords to look out for. For instance &#8216;for&#8217;, &#8216;native&#8217;, and other keywords cannot appear in your DSL, a problem which other languages do have solutions for.</p>
<p>Also, it is probably best to avoid command expressions outside of DSLs. The code &#8216;list.collect{ &#8230; } each { &#8230; }&#8217; looks like a syntax error to most Groovy programmers because there is a period missing before the each method call. However, it isn&#8217;t wrong and works just fine. Confusing, but correctly functioning. Currently, Groovy programmers are used to some parentheses and periods, and it&#8217;s confusing to leave them out unless you have good reason.</p>
<h2>Create Your Own Art</h2>
<p>Thus concludes the tour of the state of the art with Groovy DSLs. To start, Groovy fluent interfaces are a great way to organize an API and make it easy to use. While not a true domain specific language, in a low ceremony language like Groovy they can go a long way towards increased expressiveness and better signal to noise ration without resorting to programming trickery. For more power, start to use metaprogramming to fine tune the the exact API you need, and use Groovy Command Expressions when you need them. How go forth and make your next DSL a true work of art.</p>
<p><em>Need help with Groovy? Canoo is ready to tackle any challenge. Contact info@canoo.com to learn more about Groovy Training and Consulting.</em></p>
<script>var dzone_style="2";</script><script language="javascript" src="http://widgets.dzone.com/widgets/zoneit.js"></script>]]></content:encoded>
			<wfw:commentRss>http://www.canoo.com/blog/2011/12/08/the-art-of-groovy-command-expressions-in-dsls/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Canoo Brings Global Code Retreat to Switzerland</title>
		<link>http://www.canoo.com/blog/2011/11/24/canoo-brings-global-code-retreat-to-switzerland/</link>
		<comments>http://www.canoo.com/blog/2011/11/24/canoo-brings-global-code-retreat-to-switzerland/#comments</comments>
		<pubDate>Thu, 24 Nov 2011 19:49:55 +0000</pubDate>
		<dc:creator>Hamlet</dc:creator>
				<category><![CDATA[Events]]></category>

		<guid isPermaLink="false">http://www.canoo.com/blog/?p=2354</guid>
		<description><![CDATA[<script type="text/javascript">dzone_url = "http://www.canoo.com/blog/2011/11/24/canoo-brings-global-code-retreat-to-switzerland/";</script>Next Saturday, 3rd December, Canoo is sponsoring the Swiss installment of the Global Day of Code Retreat. It&#8217;s being held in Lugano, which is easily reachable from Switzerland or Northern Italy. The event is free, lunch is provided, and you&#8217;ll get a chance to practice your programming skills while taking part in a world-wide event [...]]]></description>
			<content:encoded><![CDATA[<script type="text/javascript">dzone_url = "http://www.canoo.com/blog/2011/11/24/canoo-brings-global-code-retreat-to-switzerland/";</script><p>Next Saturday, 3rd December, Canoo is sponsoring the Swiss installment of the <a href="http://coderetreat.com/global_day.html">Global Day of Code Retreat</a>. It&#8217;s being held in <a href="http://www.juglugano.ch/events/meeting_gdc.html">Lugano</a>, which is easily reachable from Switzerland or Northern Italy. The event is free, lunch is provided, and you&#8217;ll get a chance to practice your programming skills while taking part in a world-wide event that criss-crosses the globe. Sound fun? It will be. Here&#8217;s what you need to know:<br />
<a href="http://www.canoo.com/blog/wp-content/uploads/2011/11/gdcr.png"><img class="aligncenter size-medium wp-image-2355" title="gdcr" src="http://www.canoo.com/blog/wp-content/uploads/2011/11/gdcr-300x176.png" alt="" width="300" height="176" /></a><br />
A code retreat is a day long event where programmers get to practice and hone their craft. The format was created three years ago and has been used and improved regularly since then. During the day we&#8217;ll use <a href="http://en.wikipedia.org/wiki/Conway's_Game_of_Life">Conway&#8217;s Game of Life</a> to practice our design, testing, and pair programming skills. The event has a predefined format and will be facilitated by Canooie <a href="http://twitter.com/hamletdrc">Hamlet D&#8217;Arcy</a>. This is quite different from our <a href="http://hackergarten.net/">Hackergartens</a>, so you may want to read up on the format so you know what to expect. Michael Hunger has an excellent synopsis of <a href="http://www.infoq.com/news/2011/11/global_day_of_code_retreat">Code Retreat up on the InfoQ</a> website.</p>
<p>The originator of the idea is <a href="http://coderetreat.com/">Corey Haines</a> and he will be facilitating the first code retreat of the day in Australia and then flying to Hawaii to also facilitate the last retreat of the day. There is most likely a code retreat in your area, just in case you can&#8217;t make it to Lugano. Check out the map to see where you can go.<br />
<iframe width="640" height="480" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.com/maps/ms?msid=211858429594081017615.0004b0b076e7ed3148f35&amp;msa=0&amp;ie=UTF8&amp;t=m&amp;vpsrc=6&amp;ll=27.683528,-22.5&amp;spn=166.415629,90&amp;z=1&amp;output=embed"></iframe><br />
There are several sponsors for the Code Retreat in Lugano: <a href="http://www.canoo.com/">Canoo</a>, <a href="http://www.exmachina.ch/">Ex Machina</a>, and <a href="http://www.jetbrains.com/">JetBrains</a> to name a few. If you show up then expect to leave with some goodies as well as the free lunch. And please, if you plan on coming then be sure to <a href="http://coderetreat.ning.com/events/global-day-of-code-retreat-in-lugano">register on the website</a> so we can provide enough food and coffee.</p>
<p>See you Saturday!</p>
<script>var dzone_style="2";</script><script language="javascript" src="http://widgets.dzone.com/widgets/zoneit.js"></script>]]></content:encoded>
			<wfw:commentRss>http://www.canoo.com/blog/2011/11/24/canoo-brings-global-code-retreat-to-switzerland/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Android Fragmentation</title>
		<link>http://www.canoo.com/blog/2011/11/24/android-fragmentation-article/</link>
		<comments>http://www.canoo.com/blog/2011/11/24/android-fragmentation-article/#comments</comments>
		<pubDate>Thu, 24 Nov 2011 13:28:09 +0000</pubDate>
		<dc:creator>Andreas Hölzl</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[Mobile]]></category>
		<category><![CDATA[andreas]]></category>
		<category><![CDATA[andrei]]></category>
		<category><![CDATA[articles]]></category>
		<category><![CDATA[fragmentation]]></category>

		<guid isPermaLink="false">http://www.canoo.com/blog/?p=2341</guid>
		<description><![CDATA[<script type="text/javascript">dzone_url = "http://www.canoo.com/blog/2011/11/24/android-fragmentation-article/";</script>The latest issue of the german Android360 magazine is featuring an article by our Android experts about fragmentation on the platform. Fragmentation on the Android platform comes in several flavors. Mobile devices in the wild can differ on their installed Android version, their screen size/resolution and their supported hardware features. With the advent of Android [...]]]></description>
			<content:encoded><![CDATA[<script type="text/javascript">dzone_url = "http://www.canoo.com/blog/2011/11/24/android-fragmentation-article/";</script><p><img alt="" src="http://it-republik.de/it/sonderhefte/android/graf/android360-cover-thumb.jpg" title="Android360" class="alignleft" width="100" height="142" style="padding:10px;" /><br />
The latest issue of the <a href="http://www.android360.de">german Android360 magazine</a> is featuring an article by our Android experts about fragmentation on the platform.</p>
<p>Fragmentation on the Android platform comes in several flavors.<br />
Mobile devices in the wild can differ on their installed Android version, their screen size/resolution and their supported hardware features.<br />
With the advent of Android tablets the platform added a new class of supported hardware to its portfolio.<br />
The article summarizes the main does and don&#8217;t to tackle fragmentation successfully.</p>
<p>If you are experiencing fragmentation problems in your Android project or want to avoid them upfront, talk to us. Our <a href="http://www.canoo.com/services/shareacanooie/">share-a-canooie</a> service might be just the right thing for you.</p>
<p>Remember: think Android, think Canoo</p>
<script>var dzone_style="2";</script><script language="javascript" src="http://widgets.dzone.com/widgets/zoneit.js"></script>]]></content:encoded>
			<wfw:commentRss>http://www.canoo.com/blog/2011/11/24/android-fragmentation-article/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>HTML5 for iOS</title>
		<link>http://www.canoo.com/blog/2011/11/01/html5-for-ios/</link>
		<comments>http://www.canoo.com/blog/2011/11/01/html5-for-ios/#comments</comments>
		<pubDate>Tue, 01 Nov 2011 10:36:30 +0000</pubDate>
		<dc:creator>Erik Jan</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[GWT]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[HTML5]]></category>
		<category><![CDATA[iPad]]></category>

		<guid isPermaLink="false">http://www.canoo.com/blog/?p=2330</guid>
		<description><![CDATA[<script type="text/javascript">dzone_url = "http://www.canoo.com/blog/2011/11/01/html5-for-ios/";</script>My grandfather used to say: &#8220;Makkelijker gezegd dan gedaan&#8221; (easier said then done). So when I talked about how HTML5 could be the new platform in-depended development paradigm, in this previous post, I better come with some real world examples instead of only saying it. So that is exactly what I&#8217;ve been doing. My wife [...]]]></description>
			<content:encoded><![CDATA[<script type="text/javascript">dzone_url = "http://www.canoo.com/blog/2011/11/01/html5-for-ios/";</script><p>My grandfather used to say: &#8220;<em>Makkelijker gezegd dan gedaan</em>&#8221; (easier said then done). So when I talked about how HTML5 could be the new platform in-depended development paradigm, in this <a href="http://www.canoo.com/blog/2011/08/25/gwt-and-html5-canvas-the-future-of-the-web/">previous post</a>, I better come with some real world examples instead of only saying it.</p>
<p>So that is exactly what I&#8217;ve been doing. My wife is a bit of an apple fan woman. And she has a book that she would like to publish. She couldn&#8217;t find a publisher, so the next best thing would be to put her book on an iPad, but you still need an publisher to put something on the iBook store and publishers are still stuck in the dark ages. So we&#8217;ve decided to make an application out of her book. Now I&#8217;ve written some objective-c code before and I must say it wasn&#8217;t the best experience I&#8217;ve had. Xcode at that time was awful, it was like writing software 10 years ago. So I started to look for alternatives. It could be a simple html page, but how to create a native iPad application out of that?</p>
<p>I&#8217;ve found something that I&#8217;m really exited about. <a href="http://playn.googlecode.com">Playn</a> is a cross-platform game abstraction library for writing games that compile to multiple platforms one of these is html using gwt. Now if I use this in combination with <a href="http://phonegap.com/">phonegap</a> then I can create a iPad app that can also run on android based pads. Not only that I could make it interactive add a game to the book and best of all do it in Java.</p>
<p>If you think about it, for companies this makes a lot of sense. Unless your companies key platform is iOS, having developers in-house that have objective-c knowledge is expensive. Also hiring external company to build an iPhone app is expensive and they have to work together with you to integrate your existing architecture. So having something like this where one can use existing knowhow to create a android and iPhone solution that works on both platforms is a huge cost saver.</p>
<script>var dzone_style="2";</script><script language="javascript" src="http://widgets.dzone.com/widgets/zoneit.js"></script>]]></content:encoded>
			<wfw:commentRss>http://www.canoo.com/blog/2011/11/01/html5-for-ios/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Android and IDEA for the Eclipse Refugee</title>
		<link>http://www.canoo.com/blog/2011/10/18/android-and-idea-for-the-eclipse-refugee/</link>
		<comments>http://www.canoo.com/blog/2011/10/18/android-and-idea-for-the-eclipse-refugee/#comments</comments>
		<pubDate>Tue, 18 Oct 2011 15:46:21 +0000</pubDate>
		<dc:creator>Hamlet</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[Mobile]]></category>
		<category><![CDATA[Video]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[hamlet]]></category>
		<category><![CDATA[idea]]></category>

		<guid isPermaLink="false">http://www.canoo.com/blog/?p=2302</guid>
		<description><![CDATA[<script type="text/javascript">dzone_url = "http://www.canoo.com/blog/2011/10/18/android-and-idea-for-the-eclipse-refugee/";</script>Earlier this month I switched from writing my Android projects in Eclipse to writing them in IntelliJ IDEA. Overall the experience has been great, and I much prefer using IDEA to Eclipse for Android development. And now that IntelliJ IDEA 11 EAP (Early Access) has a visual layout window, there is almost no reason for [...]]]></description>
			<content:encoded><![CDATA[<script type="text/javascript">dzone_url = "http://www.canoo.com/blog/2011/10/18/android-and-idea-for-the-eclipse-refugee/";</script><p>Earlier this month I switched from writing my Android projects in <a href="http://developer.android.com/sdk/eclipse-adt.html">Eclipse</a> to writing them in <a href="http://www.jetbrains.com/idea/">IntelliJ IDEA</a>. Overall the experience has been great, and I much prefer using IDEA to Eclipse for Android development. And now that <a href="http://confluence.jetbrains.net/display/IDEADEV/IDEA+11+EAP">IntelliJ IDEA 11 EAP (Early Access)</a> has a visual layout window, there is almost no reason for me to write my Android apps in anything else. I wrote this post to help other users along their way when converting between the IDEs. </p>
<h2>Why IntelliJ IDEA for Android?</h2>
<p>There&#8217;s no need to ask why if IDEA is already your favorite IDE or if your company is forcing you to use it. But just in case you&#8217;re not already a raving fanboy, here are some of the features specific to Android that made me want to switch.</p>
<p>Find usages (Alt+F7) is aware of Android XML resources (and the semantic meaning of their content), so searching across project assets is easier. Plus, I just find IDEA&#8217;s search capabilities a little saner than Eclipse&#8217;s. Below you can see what happens when I search from within my layout XML file for a certain widget ID: </p>
<div id="attachment_2304" class="wp-caption aligncenter" style="width: 678px"><a href="http://www.canoo.com/blog/wp-content/uploads/2011/10/01_FindUsages.png"><img src="http://www.canoo.com/blog/wp-content/uploads/2011/10/01_FindUsages.png" alt="01. Find Usages" title="01. Find Usages" width="668" height="236" class="size-full wp-image-2304" /></a><p class="wp-caption-text">Find Usages in IDEA</p></div>
<p>Because IDEA knows about the Android XML resources, refactorings like Rename (Shift+F6) work across Java code and XML. You can rename a widget&#8217;s ID from the XML file and have the Java code updated, or rename from the Java code and have the XML updated. Here I am renaming a widget ID in XML. Nice. In general, I do not search within comments and Strings because it is a little too aggressive.</p>
<p><div id="attachment_2307" class="wp-caption aligncenter" style="width: 452px"><a href="http://www.canoo.com/blog/wp-content/uploads/2011/10/02_Rename.png"><img src="http://www.canoo.com/blog/wp-content/uploads/2011/10/02_Rename.png" alt="02. Rename Refactor" title="02. Rename Refactor" width="442" height="180" class="size-full wp-image-2307" /></a><p class="wp-caption-text">02. Rename Refactor</p></div>
<p>There are several Android specific intentions that make life easier in IDEA. Intentions are the quick-fixes that are activated in Eclipse with Ctrl+1. In IDEA you use Alt+Enter. For example, if there is a static String referenced from your code then you should make that String a resource by moving it to strings.xml. Put your cursor into the String, press Alt+Enter, accept the name suggestion, and you&#8217;re ready to go. Ctrl+Z for undo on refactorings work great, too. One of the big differences between IDEA and Eclipse is refactoring support. In IDEA, the source files do not need to compile in order for refactorings to work. It is quite common to have a broken file and fix it through a couple automated renames or refactors.</p>
<p><div id="attachment_2308" class="wp-caption aligncenter" style="width: 508px"><a href="http://www.canoo.com/blog/wp-content/uploads/2011/10/03_Move.png"><img src="http://www.canoo.com/blog/wp-content/uploads/2011/10/03_Move.png" alt="03. Move Refactor" title="03. Move Refactor" width="498" height="210" class="size-full wp-image-2308" /></a><p class="wp-caption-text">03. Move Refactor</p></div>
<p>Finally, before IDEA 11, the killer feature for Eclipse Android was the visual editor for XML based layout files. Personally, I don&#8217;t often use drag and drop layout editors but I do value seeing my code changes immediately without recompiling and redeploying. Eclipse had the better feature set. But IDEA 11 now has a layout &#8220;Preview&#8221; mode. Make a change in the XML and see it immediately updated in the preview. You can also quickly change the theme, preview in landscape and portrait, switch to night mode, and select different screen sizes. If you absolutely need a visual editor, then Eclipse is the way to go. Otherwise, the Preview in IDEA 11 is good enough. More info available on the <a href="http://blogs.jetbrains.com/idea/2011/10/new-in-intellij-idea-11-preview-of-android-ui-layouts">IDEA blog</a>.</p>
<p><div id="attachment_2311" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.canoo.com/blog/wp-content/uploads/2011/10/04_VisualEditor.png"><img src="http://www.canoo.com/blog/wp-content/uploads/2011/10/04_VisualEditor-300x207.png" alt="04. Visual Preview" title="04. Visual Preview" width="300" height="207" class="size-medium wp-image-2311" /></a><p class="wp-caption-text">04. Visual Preview</p></div>
<p>Let&#8217;s get started with a tour of IDEA.</p>
<h2>Getting Oriented in IDEA</h2>
<p>The basic layout of IDEA is not all that different from Eclipse. You have a main code window (right, in image below), you have a Project View (upper left), and you have a Structure View (lower left). If there is a window for it in Eclipse, then there is probably a window for it in IDEA. A good way to get started and get familiar with IDEA is to read the <a href="http://refcardz.dzone.com/refcardz/intellij-idea-update">DZone IDEA RefCard</a> I wrote a few years ago. It is still relevant today. I highlighted the image to show the relevant details.</p>
<div id="attachment_2314" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.canoo.com/blog/wp-content/uploads/2011/10/05_ProjectView.png"><img src="http://www.canoo.com/blog/wp-content/uploads/2011/10/05_ProjectView-300x225.png" alt="05. Project View" title="05. Project View" width="300" height="225" class="size-medium wp-image-2314" /></a><p class="wp-caption-text">05. Project View</p></div>
<p>At any time you can jump to the code window by pressing Escape, and you can close any open tool window with Shift+Escape. On thing that IDEA does not have is perspectives. Maybe you love Eclipse perspectives. Maybe you love when your code view shrinks up into a postage sized porthole whenever you launch a debugger. Who knows, perhaps this is useful to you somehow. I am trying very hard to be positive here, and the nicest thing I have to say about perspectives is that I hate them. Another thing IDEA does not have is a &#8220;Team Plugin&#8221;. There is no single &#8220;Team&#8221; abstraction that somehow fits on top of every version control system. Instead, when you enable Subversion then you use Subversion features. Git uses Git Features. Version control systems are enabled using the Tools->Enable Version Control menu item. Then the Alt+9 shortcut brings up the Version Control View. </p>
<h2>Running, Debugging, and the Android Tools</h2>
<p>Running and Debugging an application is slightly different in IDEA than in Eclipse. You manage your &#8220;Run Configurations&#8221; using your Run/Debug dropdown menu at the top of the screen: </p>
<div id="attachment_2315" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.canoo.com/blog/wp-content/uploads/2011/10/06_RunDropDown.png"><img src="http://www.canoo.com/blog/wp-content/uploads/2011/10/06_RunDropDown-300x269.png" alt="06. Run/Debug Configurations" title="06. Run/Debug Configurations" width="300" height="269" class="size-medium wp-image-2315" /></a><p class="wp-caption-text">06. Run/Debug Configurations</p></div>
<p>You can create temporary and permanent run configurations. Right clicking a test and choosing Run creates a temporary run config. If you want to run the target repeatedly then just save it so it is permanent. And you Maven users: you can right click a goal in the Maven view and create a run target, such as a run:jetty goal. The Maven support is amazing in IDEA, so you are actually lucky to be a Maven user in this case. </p>
<p>The features of the debuggers are fairly close between the two products. Set a break point by clicking in the gutter (Ctrl+F8), select and right click a reference to add to the watch window. I&#8217;ve noticed that Eclipse users love to enable and disable breakpoints rather than just set and remove them. Well, you can press Ctrl+Shift+F8 to manage all your breakpoints if that&#8217;s the sort of thing you like to do. Also, notice the Logcat tab on the debugger, which shows you the Android log. If you are Running (and not debugging), then the Logcat output is in the &#8220;Android Logcat&#8221; view that you see on the bottom toolbar: </p>
<div id="attachment_2317" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.canoo.com/blog/wp-content/uploads/2011/10/07_DebugWindow.png"><img src="http://www.canoo.com/blog/wp-content/uploads/2011/10/07_DebugWindow-300x277.png" alt="07. Debug Window" title="07. Debug Window" width="300" height="277" class="size-medium wp-image-2317" /></a><p class="wp-caption-text">07. Debug Window</p></div>
<p>The main Android Tools from the SDK are available under the Tools->Android menu. You can export a signed package this way and also launch the AVD to manage your emulators and environments. If you need the other SDK tools like &#8220;hierarchyviewer&#8221; or &#8220;monkeyrunner&#8221; then you&#8217;ll have to launch them from the command line. There is built-in Android testing support in IDEA, and when you run a unit test then the IDE will ask you whether to run it as a JUnit test or an Android test. It remembers your answer, so if you make a mistake then just delete the run configuration and start over. It will ask you again.</p>
<h2>Managing Your IDEA Project</h2>
<p>The two hardest parts of switching IDEs is Project configuration and Web Server configuration. Luckily we avoid the latter in an Android tutorial. But you still need to set up the project. First, some terminology. An &#8220;Eclipse Workspace&#8221; is an &#8220;IDEA Project&#8221;. An &#8220;Eclipse Project&#8221; is an &#8220;IDEA Module&#8221;. An Eclipse Workspace is composed of several projects. An IDEA Project is composed of several modules. If you have Eclipse project files then IDEA should be able to import them with no problems, and this is the fastest way to get started.</p>
<p>The Project is configured using the File->Project Structure menu item. You can also open the window using the Ctrl+Alt+Shift+S shortcut, which I call the Paw Mash because holding your left hand like a bear paw and mashing the keyboard usually suffices to open the window. This is where you specify your source folders, your SDK version, and your dependencies. If there is no Project SDK selected in the dropdown list, or if the list shows an error, then click on the SDKs item in the left side pane to create a new one.</p>
<div id="attachment_2318" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.canoo.com/blog/wp-content/uploads/2011/10/08_Project.png"><img src="http://www.canoo.com/blog/wp-content/uploads/2011/10/08_Project-300x231.png" alt="08. Project Configuration" title="08. Project Configuration" width="300" height="231" class="size-medium wp-image-2318" /></a><p class="wp-caption-text">08. Project Configuration</p></div>
<p>Configure the modules by clicking the module entry on the left side. Here you can mark certain folders as source or as tests. By default, a fresh IDEA Android project has no &#8220;tests&#8221; folder, so you should add the folder and then come in here as mark it as Test Sources. You can also change some of the Android compiler settings by clicking the Android facet shown in the middle. </p>
<div id="attachment_2319" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.canoo.com/blog/wp-content/uploads/2011/10/09_ModuleSource.png"><img src="http://www.canoo.com/blog/wp-content/uploads/2011/10/09_ModuleSource-300x155.png" alt="09. Module Configuration" title="09. Module Configuration" width="300" height="155" class="size-medium wp-image-2319" /></a><p class="wp-caption-text">09. Module Configuration</p></div>
<p>One last thing to configure before leaving the window. If you are writing JUnit tests then you&#8217;ll need to add JUnit to your project dependencies. If you just annotate a method as @Test then IDEA prompts you to add the junit.jar to your classpath. The problem is that they add it as the last dependency, which causes the test to fail with the error &#8220;java.lang.RuntimeException: Stub!&#8221;. Come into this window and move JUnit up in the dependency list. Or configure Ivy/Maven/Whatever to do this automatically for you. </p>
<div id="attachment_2320" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.canoo.com/blog/wp-content/uploads/2011/10/10_ModuleDependencies.png"><img src="http://www.canoo.com/blog/wp-content/uploads/2011/10/10_ModuleDependencies-300x124.png" alt="10. Module Dependencies" title="10. Module Dependencies" width="300" height="124" class="size-medium wp-image-2320" /></a><p class="wp-caption-text">10. Module Dependencies</p></div>
<p>That&#8217;s the quick tour of Project Structure&#8230; lets move on to Settings. Settings are the options not directly related to compiling the project. Things like code style, version control, plugins, and much more. Open Settings using File->Settings or use your Claw Attack to hit Ctrl+Alt+S. I call this shortcut the claw attack because if you pinch your left hand into an eagle claw and swoop it down on your keyboard then the Settings window usually opens right up. It helps to let out a mighty, &#8220;Ka-KAW&#8221; when you do it.</p>
<p>There are thousands of settings in here. I heard the advice recently that new users of either IDE should spent a few hours just clicking around the settings page, and I honestly think that is pretty good advice. If you know what you&#8217;re looking for but can&#8217;t find it, then enter your search term in the upper left side search box and the settings list dynamically displays only those pages with matching entries. For instance, if you know you want to show line numbers, then type in Line or Line Numbers and click through the resulting pages. In this case, the highlighting you see in the image was created by IDEA and is used to point you to the correct setting.</p>
<div id="attachment_2321" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.canoo.com/blog/wp-content/uploads/2011/10/11_Settings.png"><img src="http://www.canoo.com/blog/wp-content/uploads/2011/10/11_Settings-300x226.png" alt="11. Settings Configuration" title="11. Settings Configuration" width="300" height="226" class="size-medium wp-image-2321" /></a><p class="wp-caption-text">11. Settings Configuration</p></div>
<p>You most definitely want to change some of the default settings. Showing Line Numbers is under Editor->Appearance. Changing your tabs and space settings are done on a per-file type basis, and is accessed from Editor -> Code Style. By default IDEA allows you to place the cursor past the end of the line in a text file, and you turn this off under the Editor page. And Version Control is something you really must configure as well, which is under Version Control. <a href="http://www.jetbrains.com/idea/webhelp/using-github-integration.html">GitHub integration</a> in IDEA is tip-top and goes beyond just Git support, but lately I&#8217;ve been using and recommending <a href="https://bitbucket.org">BitBucket</a> for free, private git hosting. In general I find myself using the IDE to make local commits and manage changelists, and the command line to perform pushes.</p>
<h2>Links</h2>
<p>That&#8217;s it! There are tons of ways to learn more, and here are my favorite links:</p>
<ul>
<li><a href="http://refcardz.dzone.com/refcardz/intellij-idea-update">IntelliJ IDEA RefCard</a> from me</li>
<li><a href="http://hamletdarcy.blogspot.com/2010/10/intellij-idea-shortcut-wallpaper.html">IDEA Shortcut Wallpaper</a> from me again</li>
<li>JetBrains&#8217; <a href="http://www.jetbrains.com/idea/documentation/migration_faq.html">IDEA Q&#038;A for Eclipse Users</a></li>
<li><a href="http://hamletdarcy.blogspot.com/2008/02/10-helpful-hints-on-moving-from-eclipse.html">10 Hints for Moving from Eclipse to IDEA</a> from me</li>
<li>All of my <a href="http://hamletdarcy.blogspot.com/search/label/IDEA">IDEA Related Blog Posts</a></li>
<li>All of Canoo&#8217;s <a href="http://www.canoo.com/blog/tag/idea/">IDEA Related Blog Posts</a></li>
<li><a href="http://tv.jetbrains.net/tags/hamlet">My Other Videos on JetBrains.tv</a></li>
<li><a href="http://hamletdarcy.blogspot.com/2011/05/intellij-idea-keyboard-stickers.html">IDEA Keyboard Stickers</a>, so you can learn the shortcuts</li>
<li>And last, you could try <a href="http://www.jetbrains.com/idea/webhelp/">reading the manual</a></li>
</ul>
<p>As always, feel free to keep in touch by leaving a comment. You can read more from me on my blog at <a href="http://hamletdarcy.blogspot.com/">http://hamletdarcy.blogspot.com/</a>, see <a href="http://www.youtube.com/hamletdrc">my YouTube channel</a> for more screencasts, and follow me on Twitter:&nbsp;<a href="http://twitter.com/hamletdrc">@HamletDRC</a></p>
<script>var dzone_style="2";</script><script language="javascript" src="http://widgets.dzone.com/widgets/zoneit.js"></script>]]></content:encoded>
			<wfw:commentRss>http://www.canoo.com/blog/2011/10/18/android-and-idea-for-the-eclipse-refugee/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>JavaOne 2011 Thursday and wrap-up</title>
		<link>http://www.canoo.com/blog/2011/10/07/javaone-2011-thursday-and-wrap-up/</link>
		<comments>http://www.canoo.com/blog/2011/10/07/javaone-2011-thursday-and-wrap-up/#comments</comments>
		<pubDate>Fri, 07 Oct 2011 05:15:10 +0000</pubDate>
		<dc:creator>Dierk</dc:creator>
				<category><![CDATA[Grails]]></category>
		<category><![CDATA[Groovy]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[JavaFX]]></category>
		<category><![CDATA[JavaOne]]></category>
		<category><![CDATA[Swing]]></category>
		<category><![CDATA[canoo]]></category>
		<category><![CDATA[conference]]></category>
		<category><![CDATA[Dierk König]]></category>

		<guid isPermaLink="false">http://www.canoo.com/blog/?p=2291</guid>
		<description><![CDATA[<script type="text/javascript">dzone_url = "http://www.canoo.com/blog/2011/10/07/javaone-2011-thursday-and-wrap-up/";</script>Opinions expressed in the post are solely my own and not necessarily those of my employer. Thursday started with the Community Keynote. Well, it actually started with a 25 minutes IBM presentation about their cloud story. This had obviously nothing to do with the topic of the event and later speakers pointed this out rather [...]]]></description>
			<content:encoded><![CDATA[<script type="text/javascript">dzone_url = "http://www.canoo.com/blog/2011/10/07/javaone-2011-thursday-and-wrap-up/";</script><div id="_mcePaste"><em>Opinions expressed in the post are solely my own and not necessarily those of my employer.</em></div>
<div><em><br />
</em></div>
<div>Thursday started with the Community Keynote. Well, it actually started with a 25 minutes IBM presentation about their cloud story. This had obviously nothing to do with the topic of the event and later speakers pointed this out rather frankly. At least it was interesting to hear that there is a job title like &#8220;Cloud Architect&#8221;.</div>
<div id="_mcePaste">The real part of the Community Keynote started with a <em>quiet moment to honor Steve Jobs</em>.</div>
<div id="_mcePaste">Later on, various winners of the Duke choice award and JUG luminaries cared for a lighter mood again, presented their work and asked the audience for participation in their local JUGs and in the advancement of Java via the OpendJDK. The JavaPosse appeared on stage and presented a funny show.</div>
<div id="_mcePaste">It was also announced that many of the JavaOne talks will be available on parleys.com, which provide by far the best experience when it comes to viewing live-captured talks.</div>
<div id="_mcePaste">Afterwards I attended the ZeroTurnaround (JRebel) talk on classloader issues. The rather big room (~300 ppl) was packed and left the impression that many Java developers share a common pain around classloaders. It was a good talk, covering the basics and typical pifalls. The only surprise for me was *how* easily you can end up with a classloader leak.</div>
<div id="_mcePaste">In order to improve my fathering skills, I went into Ken Sipe&#8217;s talk on &#8220;Rocking the Gradle&#8221;, where I met Adam Bien. Ken is a great presenter. However, convincing the crowd is a challenge especially as many Maven users seem to suffer from the Stockholm syndrome.</div>
<div id="_mcePaste">Then onto &#8220;Visualization of Geomaps and Topic Maps with JavaFX 2.0&#8243;, which had some interesting visuals captured <a href="http://www.lodgon.com/lodgon/NEWS/Artikelen/2010/9/22_Our_CTO_presented_a_JavaOne_session_on_JavaFX.html">here</a>.</div>
<div>For me JavaOne 2011 finished with Jim Clarke and Dean Iverson on GroovyFX, where they made some really good points suggesting that Groovy is the best language to drive the JavaFX 2.0 API.</div>
<div>As a side note, James Weaver introduced me to Jim Clarke by pointing out &#8220;He is from *<strong>Canoo</strong>*&#8221;. Then the discussion went into how well-known Canoo is in the community and that all employees must be true geniuses to achieve so much with so few people <img src='http://www.canoo.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </div>
<div>Fazit: Still, JavaOne is nowhere near where it was before the Oracle acquisition both in terms of size and in terms of being an unparalleled community experience. Distribution all over various hotels just doesn&#8217;t feel right. However, meeting friends has been and still remains the most important part of JavaOne and the conference still delivers on that account.</div>
<div id="_mcePaste">Important topics were new Java versions, JavaEE (+cloud), and Java for the Desktop with 50+ talks on JavaFX. Whenever the audience was asked about which alternative languages they use, Groovy was the clear winner. It appears that in the mainstream, Groovy has become the default choice for dynamic programming on the JVM.</div>
<div id="_mcePaste">The topic of concurrent programming was in my eyes underrepresented. Guillaume and myself had simple usage of GPars in our demos but for such a big and increasingly important topic the coverage should be much more extensive.</div>
<div>Finally, some visual impressions.</div>
<div>Good-bye SF</div>
<div>Dierk Koenig</div>
<p><a href="http://www.canoo.com/blog/wp-content/uploads/2011/10/j1-01.jpg"><img class="alignnone size-medium wp-image-2292" title="j1-01" src="http://www.canoo.com/blog/wp-content/uploads/2011/10/j1-01-225x300.jpg" alt="" width="225" height="300" /></a><a href="http://www.canoo.com/blog/wp-content/uploads/2011/10/j1-02.jpg"><img class="alignnone size-medium wp-image-2293" title="j1-02" src="http://www.canoo.com/blog/wp-content/uploads/2011/10/j1-02-300x225.jpg" alt="" width="300" height="225" /></a><a href="http://www.canoo.com/blog/wp-content/uploads/2011/10/j1-03.jpg"><img class="alignnone size-medium wp-image-2294" title="j1-03" src="http://www.canoo.com/blog/wp-content/uploads/2011/10/j1-03-300x225.jpg" alt="" width="300" height="225" /></a><a href="http://www.canoo.com/blog/wp-content/uploads/2011/10/j1-04.jpg"><img class="alignnone size-medium wp-image-2295" title="j1-04" src="http://www.canoo.com/blog/wp-content/uploads/2011/10/j1-04-225x300.jpg" alt="" width="225" height="300" /></a><a href="http://www.canoo.com/blog/wp-content/uploads/2011/10/j1-17.jpg"><img class="alignnone size-medium wp-image-2296" title="j1-17" src="http://www.canoo.com/blog/wp-content/uploads/2011/10/j1-17-300x225.jpg" alt="" width="300" height="225" /></a><a href="http://www.canoo.com/blog/wp-content/uploads/2011/10/j1-25.jpg"><img class="alignnone size-medium wp-image-2297" title="j1-25" src="http://www.canoo.com/blog/wp-content/uploads/2011/10/j1-25-300x225.jpg" alt="" width="300" height="225" /></a><a href="http://www.canoo.com/blog/wp-content/uploads/2011/10/j1-27.jpg"><img class="alignnone size-medium wp-image-2298" title="j1-27" src="http://www.canoo.com/blog/wp-content/uploads/2011/10/j1-27-300x225.jpg" alt="" width="300" height="225" /></a></p>
<script>var dzone_style="2";</script><script language="javascript" src="http://widgets.dzone.com/widgets/zoneit.js"></script>]]></content:encoded>
			<wfw:commentRss>http://www.canoo.com/blog/2011/10/07/javaone-2011-thursday-and-wrap-up/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>JavaOne 2011 Wednesday</title>
		<link>http://www.canoo.com/blog/2011/10/06/javaone-2011-wednesday/</link>
		<comments>http://www.canoo.com/blog/2011/10/06/javaone-2011-wednesday/#comments</comments>
		<pubDate>Thu, 06 Oct 2011 17:11:44 +0000</pubDate>
		<dc:creator>Dierk</dc:creator>
				<category><![CDATA[Grails]]></category>
		<category><![CDATA[Groovy]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[JavaOne]]></category>
		<category><![CDATA[Swing]]></category>
		<category><![CDATA[Dierk König]]></category>

		<guid isPermaLink="false">http://www.canoo.com/blog/?p=2286</guid>
		<description><![CDATA[<script type="text/javascript">dzone_url = "http://www.canoo.com/blog/2011/10/06/javaone-2011-wednesday/";</script>Opinions expressed in this post are totally my own and not necessarily that of my employer. Wednesday started with the infamous &#8220;scriptbowl&#8221;, a competition between various scripting languages. This year the contenters were JRuby, Groovy, Scala, and Clojure. I wondered whether Scala considers itself a scripting language but obviously they either do or just seek [...]]]></description>
			<content:encoded><![CDATA[<script type="text/javascript">dzone_url = "http://www.canoo.com/blog/2011/10/06/javaone-2011-wednesday/";</script><p><em>Opinions expressed in this post are totally my own and not necessarily that of my employer.</em></p>
<p>Wednesday started with the infamous &#8220;scriptbowl&#8221;, a competition between various scripting languages. This year the contenters were JRuby, Groovy, Scala, and Clojure. I wondered whether Scala considers itself a scripting language but obviously they either do or just seek the opportunity to be on stage.</p>
<p>To keep a long story short: <strong>Groovy has won this event for the third time in a row</strong>! This year the race was tied with Scala. Guillaume presented Groovy in the typical Groovy-idomatic style and explained every single line of his concurrent visual analyzer for Google+ postings. Dick Wall presented only non-idomatic Scala code. I interpret this as: to make Scala appealing you have to make it look like Groovy. Furthermore, he presented Kojo, which is a great interactive learning environment written in Play/Scala. In contrast to all other presentations, this was not specifically created for the scriptbowl, nor was it written by the presenter, nor was it clear how much effort went into it, nor did the audience see a single line the implementation code. How much this skewed the comparison, I leave to everybody&#8217;s judgement. The show was good, though.</p>
<p>I felt a bit sorry for Clojure. It is a great language and deserves a presentation that is more visually appealing to convince the crowd.</p>
<p>Afterwards, I attended a hands-on lab for &#8220;rapid enterprise development with netbeans&#8221;, which was essentially creating a Swing app for database CRUD actions. If I remember correctly, I did the exact same task 1997 with JBuilder. It left me with the feeling of &#8220;Yes, it works&#8221; but it is not less complex than it was 13 years ago.</p>
<p>Early afternoon Gerrit Grunwald (better known as @hansolo_) presented his work on simplified custom components for Swing. Given that he speaks about an activity that is both utterly important and highly underadvertised he would really deserve speaking at the center stage.</p>
<p>Graeme Rocher&#8217;s great session about Grails, polyglot datastores (hibernate, jpa, redis, mongodb, &#8230;), and the cloud was overshadowed by the news that Steve Jobs has died. Accidentally, the demo application was about showing a BBC News stream, which displayed this information live on stage. Both the presenter and the audience were equally touched.</p>
<p>The day officially ended with a big event at treasure island. I decided to not go there, though, and meet the former Canooey Denis Antonioli in Berkely where we had a great evening.</p>
<p>Dierk Koenig</p>
<script>var dzone_style="2";</script><script language="javascript" src="http://widgets.dzone.com/widgets/zoneit.js"></script>]]></content:encoded>
			<wfw:commentRss>http://www.canoo.com/blog/2011/10/06/javaone-2011-wednesday/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

