<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Fabio Kung</title>
	<atom:link href="http://fabiokung.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://fabiokung.com</link>
	<description>Deleting code. Better than writing good code.</description>
	<lastBuildDate>Tue, 27 Dec 2011 02:37:22 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='fabiokung.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://0.gravatar.com/blavatar/4774c20e8f8313df1d4528a77be5a951?s=96&#038;d=http%3A%2F%2Fs2.wp.com%2Fi%2Fbuttonw-com.png</url>
		<title>Fabio Kung</title>
		<link>http://fabiokung.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://fabiokung.com/osd.xml" title="Fabio Kung" />
	<atom:link rel='hub' href='http://fabiokung.com/?pushpress=hub'/>
		<item>
		<title>Running Java Web Applications on Heroku Cedar Stack</title>
		<link>http://fabiokung.com/2011/08/06/running-java-web-applications-on-heroku-cedar-stack/</link>
		<comments>http://fabiokung.com/2011/08/06/running-java-web-applications-on-heroku-cedar-stack/#comments</comments>
		<pubDate>Sat, 06 Aug 2011 11:33:25 +0000</pubDate>
		<dc:creator>Fabio Kung</dc:creator>
				<category><![CDATA[cloud]]></category>
		<category><![CDATA[heroku]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[jetty]]></category>
		<category><![CDATA[spring]]></category>
		<category><![CDATA[vraptor]]></category>
		<category><![CDATA[web]]></category>
		<category><![CDATA[clojure]]></category>
		<category><![CDATA[deploy]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[paas]]></category>
		<category><![CDATA[platform]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://fabiokung.com/?p=317</guid>
		<description><![CDATA[Update: Heroku now does support Java. Heroku does not officially support Java applications yet (yes, it does). However, the most recently launched stack comes with support for Clojure. Well, if Heroku does run Clojure code, it is certainly running a JVM. Then why can we not deploy regular Java code on top of it? I was [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=fabiokung.com&amp;blog=3424388&amp;post=317&amp;subd=fabiokung&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><strong>Update:</strong> Heroku now <a href="http://blog.heroku.com/archives/2011/08/25/java/">does support Java</a>.</p>
<p><a href="http://heroku.com">Heroku</a> <del datetime="2011-09-20T21:57:27+00:00">does not officially support Java applications yet</del> (yes, <a href="http://blog.heroku.com/archives/2011/08/25/java/">it does</a>). However, the most recently launched <a href="http://devcenter.heroku.com/articles/cedar">stack</a> comes with support for Clojure. Well, if Heroku does run Clojure code, it is certainly running a JVM. Then why can we not deploy regular Java code on top of it?</p>
<p>I was playing with it today and found a way to do that. I admit, so far it is just a hack, but it is working fine. The best (?) part is that it should allow any maven-based Java Web Application to be deployed fairly easy. So, if your project can be built with maven, i.e. <code>mvn package</code> generates a WAR package for you, then you are ready to run on the fantastic Heroku Platform as a Service.</p>
<p>Wait. There is more. In these polyglot times, we all know that being able to run Java code means that we are able to run basically anything on top of the JVM. I&#8217;ve got a <a title="Lift Example" href="http://falling-winter-971.herokuapp.com/" target="_blank">simple Scala (Lift) Web Application</a> running on Heroku, for example.</p>
<p>There are also examples of simple <a title="spring-roo example" href="http://fierce-night-373.herokuapp.com/" target="_blank">spring-roo</a> and <a title="VRaptor on Heroku example" href="http://warm-winter-370.herokuapp.com/" target="_blank">VRaptor</a> web applications. I had a lot of fun coding on that stuff, which finally gave me an opportunity to put my hands on Clojure. There are even two new Leiningen plugins: <a href="https://github.com/fabiokung/lein-mvn">lein-mvn</a> and <a href="https://github.com/fabiokung/lein-herokujetty">lein-herokujetty</a>. <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<h2>VRaptor on Heroku</h2>
<p>Let me show you what I did with an example. Here is a step-by-step to deploy a VRaptor application on Heroku Celadon Cedar:</p>
<ol>
<li>Go to <a href="http://heroku.com">Heroku</a> and create an account if you still do not have.</li>
<li>We are going to need some tools. First Heroku gems:<br />
<pre class="brush: bash; light: true;">
$ gem install heroku
$ gem install foreman
</pre></li>
<li>Then <a href="https://github.com/technomancy/leiningen">Leiningen</a>, the clojure project automation tool. On my Mac, I installed it with <code>brew</code>:<br />
<pre class="brush: bash; light: true;">
$ brew update
$ brew install leiningen
</pre></li>
<li>The vraptor-scaffold gem, to help us bootstrap a new project:<br />
<pre class="brush: bash; light: true;">
$ gem install vraptor
</pre></li>
</ol>
<p>That is it for the preparation. We may now start dealing with the project.</p>
<ol>
<li>First, we need to create the project skeleton:<br />
<pre class="brush: bash; light: true;">
$ vraptor new &lt;project-name&gt; -b mvn
$ lein new &lt;project-name&gt;
$ cd &lt;project-name&gt;
</pre></p>
<p>The <code>lein</code> command is not strictly necessary, but it helps with .gitignore and other minor stuff.</li>
<li>Now, <a href="https://gist.github.com/1129069">the secret sauce</a>. This is the ugly code that actually tries to be smart and tricks Heroku to do additional <em>build/compilation</em> steps:<br />
<pre class="brush: bash; light: true;">
$ wget https://gist.github.com/raw/1129069/f7ffcda9c42a3004fa8d3c496d4f13887c11ebf4/heroku_autobuild.clj -P src
</pre></p>
<p>Or if you do not have <code>wget</code> installed:<br />
<pre class="brush: bash; light: true;">
$ curl -L https://gist.github.com/raw/1129069/f7ffcda9c42a3004fa8d3c496d4f13887c11ebf4/heroku_autobuild.clj &gt; src/heroku_autobuild.clj
</pre></li>
<li>You also need to tweak the Leiningen project definition &#8211; <code>project.clj</code>. The template is <a href="https://gist.github.com/1129081">here</a>. Please remember to adjust your project name. It must be the same that you are using in the <code>pom.xml</code>. Or you may download it directly if you prefer:<br />
<pre class="brush: bash; light: true;">
$ curl -L https://gist.github.com/raw/1129081/5790e173307d28a8df256e0aaa5a9fe7757e922f/project.clj &gt; project.clj
</pre></li>
<li>Unfortunately, Leiningen comes bundled with an old version of the Maven/Ant integration. The embedded maven is currently at version <strong>2.0.8</strong>, which is old. The versions of some plugins configured in the default pom.xml from vraptor-scaffold are incompatible with this old version of maven.
<p>The best way to solve it for now is to remove all <code>&lt;version&gt;</code> tags from items inside the <code>&lt;plugins&gt;</code> section of your pom.xml. This is specific to VRaptor and other frameworks may need different modifications. See below for spring-roo and Lift instructions.</p>
<p>If even after removing versions from all plugins, you still get <code>ClassNotFoundException: org.apache.maven.toolchain.ToolchainManager</code> errors, try cleaning your local maven repository (the default location is <code>$HOME/.m2/repository</code>). The <code>pom.xml</code> that I used is <a href="https://gist.github.com/1129255">here</a>.</li>
<li>Now, try the same command that Heroku uses during its slug compilation phase. It should download all dependencies and package your application in a WAR file inside the target directory.<br />
<pre class="brush: bash; light: true;">
$ lein deps
</pre></p>
<p>Confirm that the WAR was built into <code>target/</code>. It must have the same name as defined in your <code>project.clj</code>.</li>
<li>Create your Heroku/Foreman Procfile containing the web process definition:<br />
<pre class="brush: bash; light: true;">
web: lein herokujetty
</pre></p>
<p>And test with:</p>
<p><pre class="brush: bash; light: true;">
$ foreman start
</pre></p>
<p>A Jetty server should start and listen on a random port defined by <code>foreman</code>. Heroku does the same.</li>
<li>Time to push your application to Heroku. Start editing your <code>.gitignore</code>: add <code>target/</code> and <code>tmp/</code>, and please <strong>remove</strong> <code>pom.xml</code>. <strong>Important</strong>: The <code>pom.xml</code> must not be ignored.</li>
<li>You may also remove some unused files (created by leiningen):<br />
<pre class="brush: bash; light: true;">
$ rm -rf src/&lt;project-name&gt;
# do not remove src/main src/test and src/heroku_autobuild.clj!
</pre></li>
<li>Create a git repository:<br />
<pre class="brush: bash; light: true;">
$ git init
$ git add .
$ git commit -m &quot;initial import&quot;
</pre></li>
<li>Push everything to Heroku and (hopefully) watch it get built there!<br />
<pre class="brush: bash; light: true;">
$ heroku create --stack cedar
$ git push -u heroku master
</pre></li>
<li>When it ends, open another terminal on the project directory, to follow logs:<br />
<pre class="brush: bash; light: true;">
$ heroku logs -t
</pre></li>
<li>Open the URL that heroku creates and test the application. You may also spawn more instances and use everything Heroku has to offer:<br />
<pre class="brush: bash; light: true;">
$ heroku ps:scale web=2
$ heroku ps:scale web=4
$ heroku ps:scale web=0
</pre></li>
<li>Quick tip: you do not have SSH access directly to Dynos, but this little trick is very useful to troubleshoot issues and to see how slugs were compiled:<br />
<pre class="brush: bash; light: true;">
$ heroku run bash
</pre></li>
</ol>
<h2>spring-roo on Heroku</h2>
<p>Once you understand the process for a VRaptor application, it should be easy for others as well. Just follow the simple step-by-step <a href="http://www.springsource.org/roo/start">here</a>, to create a simple spring-roo maven application.</p>
<p>Then, before running <code>lein deps</code> or <code>foreman start</code>, you must adjust your <code>pom.xml</code>, to remove plugins incompatible with the older mvn that is bundled in Leiningen. <a href="https://gist.github.com/1129220">Here</a> is the <code>pom.xml</code> that I am using (with some of the plugins downgraded).</p>
<p>You can see my spring-roo application running on Heroku <a href="http://fierce-night-373.herokuapp.com/" title="spring-roo running on heroku">here</a>. </p>
<h2>Scala/Lift on Heroku</h2>
<p>The same for Scala/Lift: follow <a href="http://www.assembla.com/spaces/liftweb/wiki/Using_Maven">the instructions</a> to bootstrap an application with maven. One simple change to the <code>pom.xml</code> is required. My version is <a href="https://gist.github.com/1129219">here</a>.</p>
<p>You also need to turn off the <code>AUTO_SERVER</code> feature of H2 DB. It makes H2 automatically starts a server process, which binds on a tcp port. Heroku only allows one port bound per process/dyno, and for the web process, it must be the jetty port.</p>
<p>To turn it off, change the database URL inside <code>src/main/scala/bootstrap/liftweb/Boot.scala</code>. I changed mine to a in-memory database. The URL must be something similar to <code>jdbc:h2:mem:&lt;project&gt;.db</code>.</p>
<p>My Lift application is running on Heroku <a href="http://falling-winter-971.herokuapp.com/" title="Scala/Lift web application on Heroku">here</a>.</li>
<p>I hope it helps. Official support for Java must be in Heroku&#8217;s plans, but even without it yet, we&#8217;ve got a lot of possibilities.</p>
<br />Filed under: <a href='http://fabiokung.com/category/cloud/'>cloud</a>, <a href='http://fabiokung.com/category/heroku/'>heroku</a>, <a href='http://fabiokung.com/category/java/'>java</a>, <a href='http://fabiokung.com/category/jetty/'>jetty</a>, <a href='http://fabiokung.com/category/spring/'>spring</a>, <a href='http://fabiokung.com/category/vraptor/'>vraptor</a>, <a href='http://fabiokung.com/category/web/'>web</a> Tagged: <a href='http://fabiokung.com/tag/clojure/'>clojure</a>, <a href='http://fabiokung.com/tag/cloud/'>cloud</a>, <a href='http://fabiokung.com/tag/deploy/'>deploy</a>, <a href='http://fabiokung.com/tag/development/'>development</a>, <a href='http://fabiokung.com/tag/heroku/'>heroku</a>, <a href='http://fabiokung.com/tag/java/'>java</a>, <a href='http://fabiokung.com/tag/paas/'>paas</a>, <a href='http://fabiokung.com/tag/platform/'>platform</a>, <a href='http://fabiokung.com/tag/ruby/'>ruby</a>, <a href='http://fabiokung.com/tag/web/'>web</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/fabiokung.wordpress.com/317/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/fabiokung.wordpress.com/317/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/fabiokung.wordpress.com/317/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/fabiokung.wordpress.com/317/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/fabiokung.wordpress.com/317/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/fabiokung.wordpress.com/317/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/fabiokung.wordpress.com/317/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/fabiokung.wordpress.com/317/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/fabiokung.wordpress.com/317/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/fabiokung.wordpress.com/317/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/fabiokung.wordpress.com/317/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/fabiokung.wordpress.com/317/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/fabiokung.wordpress.com/317/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/fabiokung.wordpress.com/317/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=fabiokung.com&amp;blog=3424388&amp;post=317&amp;subd=fabiokung&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://fabiokung.com/2011/08/06/running-java-web-applications-on-heroku-cedar-stack/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/251c190c5a8277a3bc6197491f32da51?s=96&#38;d=wavatar&#38;r=PG" medium="image">
			<media:title type="html">Fabio Kung</media:title>
		</media:content>
	</item>
		<item>
		<title>DSLs: one interface, multiple implementations</title>
		<link>http://fabiokung.com/2010/10/16/dsls-one-interface-multiple-implementations/</link>
		<comments>http://fabiokung.com/2010/10/16/dsls-one-interface-multiple-implementations/#comments</comments>
		<pubDate>Sat, 16 Oct 2010 22:33:09 +0000</pubDate>
		<dc:creator>Fabio Kung</dc:creator>
				<category><![CDATA[design]]></category>
		<category><![CDATA[dsl]]></category>
		<category><![CDATA[oo]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[interface]]></category>

		<guid isPermaLink="false">http://fabiokung.com/?p=288</guid>
		<description><![CDATA[One interface, multiple implementations is one of these design concepts I like most. It&#8217;s basically polymorphism in its pure form! Coding a little bit a while ago, I realized how DSLs could reinforce this idea. My example here is a simple implementation for queue consumers, as a simple Ruby internal DSL: And to enqueue a [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=fabiokung.com&amp;blog=3424388&amp;post=288&amp;subd=fabiokung&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><em><strong>One interface, multiple implementations</strong></em> is one of these design concepts I like most. It&#8217;s basically polymorphism in its pure form!</p>
<p>Coding a little bit a while ago, I realized how DSLs could reinforce this idea. My example here is a simple implementation for queue consumers, as a simple Ruby <a href="http://martinfowler.com/bliki/InternalDslStyle.html">internal DSL</a>:</p>
<p><pre class="brush: ruby; light: true;">
class GitRepositoryCloner &lt; Consumer
  queue &quot;RepositoriesToBeCloned&quot;
  exclusive true

  handle do |message|
    # git clone repository!
    # I'm pretty sure github has something alike
  end
end
</pre></p>
<p>And to enqueue a message, we could do:</p>
<p><pre class="brush: ruby; light: true;">
GitRepositoryCloner.publish(&quot;rails&quot;)
</pre></p>
<p><code>GitRepositoryCloner</code> is a simple consumer of the queue named <code>RepositoriesToBeCloned</code>. One of the times I did something similar to this, I needed support for <em><a href="http://activemq.apache.org/exclusive-consumer.html">exclusive consumers</a></em>. Then, my choices were <a href="http://activemq.apache.org/">ActiveMQ</a> as the messaging middleware together with the <a href="http://activemq.apache.org/stomp.html">Stomp protocol</a>.</p>
<p>Using them as an example, let&#8217;s take a look on a possible implementation for the <code>Consumer</code> class, using the <a href="http://github.com/js/stomp">stomp gem</a>:</p>
<p><pre class="brush: ruby; light: true;">
module ActiveMQ
  class Consumer

    def self.queue(name)
      @queue_name = name
    end

    def self.exclusive(bool)
      @exclusive = bool
    end

    def self.handle(&amp;blk)
      @callback = blk
    end

    def self.listen
      broker = Stomp::Client.new(Config[:broker])
      broker.subscribe(@queue_name, 
          :'activemq.exclusive' =&gt; @exclusive) do |message|
        @callback.call(message)
        broker.acknowledge(message)
      end
    end

    def self.publish(message)
      broker = Stomp::Client.new(Config[:broker])
      broker.publish(@queue_name, message, :persistent =&gt; true)
    end

  end
end

Consumer = ActiveMQ::Consumer
</pre></p>
<p>The last line is where we choose the ActiveMQ::Consumer as the default implementation.</p>
<p>The beautiful aspect of this little internal DSL, composed only of three methods (<code>queue</code>, <code>exclusive</code> and <code>handle</code>), is that it defines an interface. Here, I have seen a common misconception from many developers coming from Java, C# and similar languages which have the <code>interface</code> construct. An interface in Object Orientation is composed of all accessible methods of an object. In other words, the interface is the object&#8217;s face to the rest of the world. We are not necessarily talking about a Java or C# <code>interface</code> construct.</p>
<p>In this sense, these three methods (<code>queue</code>, <code>exclusive</code> and <code>handle</code>) are the interface of the <code>Consumer</code> internal DSL (or class object, as you wish).</p>
<p>Let&#8217;s say for some reason, we would like to switch our messaging infrastructure to something else, like <a href="http://github.com/defunkt/resque">Resque</a>, which Github uses and is awesome. <a href="http://github.com/defunkt/resque">Resque&#8217;s documentation</a> says that things are a little bit different for Resque consumers. They must define a <code>@queue</code> class attribute and must have a <code>perform</code> class method.</p>
<p>As we would do with regular Java/C# interfaces, let&#8217;s make another implementation respecting the previous contract:</p>
<p><pre class="brush: ruby; light: true;">
module Resque
  class Consumer

    def self.queue(name)
      @queue = name
    end

    def self.exclusive(bool)
      self.extend(Resque::Plugins::LockTimeout) if bool
    end

    def self.handle(&amp;blk)
      self.send(:define_method, :perform, &amp;@blk)
    end

    def self.listen
      raise &quot;Not ready yet&quot; unless self.respond_to?(:perform)
    end

    def self.publish(message)
      Resque.enqueue(self, message)
    end

  end
end
</pre></p>
<p>There you can see how the implementations differ. The <em>exclusive consumer</em> feature is provided by the <a href="http://github.com/lantins/resque-lock-timeout">LockTimeout plugin</a>. In this case, instead of passing the <code>activemq.exclusive</code> parameter to the connection, we must use the <code>Resque::Plugins::LockTimeout</code> module, as the <a href="http://github.com/lantins/resque-lock-timeout">documentation says</a>. Another key difference is in the message handling process. Instead of passing a handler block to the <code>subscribe</code> method, Resque consumers are required to define a <code>perform</code> method, which we are dynamically creating with some metaprogramming: <code>Class#define_method(name)</code>.</p>
<p>Finally, here is how we switch our messaging backend to Resque, without any changes to the consumer classes (<code>GitRepositoryCloner</code> in this example):</p>
<p><pre class="brush: ruby; light: true;">
Consumer = Resque::Consumer
</pre></p>
<p>That&#8217;s it: <em>one interface, two (multiple) implementations</em>.</p>
<br />Filed under: <a href='http://fabiokung.com/category/design/'>design</a>, <a href='http://fabiokung.com/category/dsl/'>dsl</a>, <a href='http://fabiokung.com/category/oo/'>oo</a>, <a href='http://fabiokung.com/category/ruby/'>ruby</a> Tagged: <a href='http://fabiokung.com/tag/design/'>design</a>, <a href='http://fabiokung.com/tag/interface/'>interface</a>, <a href='http://fabiokung.com/tag/oo/'>oo</a>, <a href='http://fabiokung.com/tag/ruby/'>ruby</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/fabiokung.wordpress.com/288/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/fabiokung.wordpress.com/288/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/fabiokung.wordpress.com/288/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/fabiokung.wordpress.com/288/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/fabiokung.wordpress.com/288/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/fabiokung.wordpress.com/288/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/fabiokung.wordpress.com/288/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/fabiokung.wordpress.com/288/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/fabiokung.wordpress.com/288/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/fabiokung.wordpress.com/288/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/fabiokung.wordpress.com/288/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/fabiokung.wordpress.com/288/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/fabiokung.wordpress.com/288/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/fabiokung.wordpress.com/288/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=fabiokung.com&amp;blog=3424388&amp;post=288&amp;subd=fabiokung&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://fabiokung.com/2010/10/16/dsls-one-interface-multiple-implementations/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/251c190c5a8277a3bc6197491f32da51?s=96&#38;d=wavatar&#38;r=PG" medium="image">
			<media:title type="html">Fabio Kung</media:title>
		</media:content>
	</item>
		<item>
		<title>Ruby and dependency injection in a dynamic world</title>
		<link>http://fabiokung.com/2010/05/06/ruby-and-dependency-injection-in-a-dynamic-world/</link>
		<comments>http://fabiokung.com/2010/05/06/ruby-and-dependency-injection-in-a-dynamic-world/#comments</comments>
		<pubDate>Thu, 06 May 2010 07:48:10 +0000</pubDate>
		<dc:creator>Fabio Kung</dc:creator>
				<category><![CDATA[design]]></category>
		<category><![CDATA[di]]></category>
		<category><![CDATA[ioc]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[language]]></category>
		<category><![CDATA[oo]]></category>
		<category><![CDATA[refactor]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://fabiokung.com/?p=255</guid>
		<description><![CDATA[It&#8217;s been many years I&#8217;ve been teaching Java and advocating dependency injection. It makes me design more loosely coupled modules/classes and generally leads to more extensible code. But, while programming in Ruby and other dynamic languages, the different mindset always intrigued me. Why the reasons that made me love dependency injection in Java and C# [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=fabiokung.com&amp;blog=3424388&amp;post=255&amp;subd=fabiokung&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s been many years I&#8217;ve been teaching Java and advocating dependency injection. It makes me design more loosely coupled modules/classes and generally leads to more extensible code.</p>
<p>But, while programming in Ruby and other dynamic languages, the different mindset always intrigued me. Why the reasons that made me love dependency injection in Java and C# don&#8217;t seem to apply to dynamic languages? Why am I not using DI frameworks (or writing simple wiring code as I did many times before) in my Ruby projects?</p>
<p>I&#8217;ve been thinking about it for a long time and <a href="http://weblog.jamisbuck.org/2008/11/9/legos-play-doh-and-programming">I don&#8217;t believe I&#8217;m alone</a>.</p>
<blockquote><p><strong>DI frameworks are unnecessary</strong>. In more rigid environments, they have value. In agile environments like Ruby, not so much. The patterns themselves may still be applicable, but beware of falling into the trap of thinking you need a special tool for everything. Ruby is Play-Doh, remember! Let’s keep it that way.</p>
<p align="right">&#8211; Jamis Buck</p>
</blockquote>
<p>Even being a huge fan of DI frameworks in the Java/C# world (particularly the lightweights), I completely agree with Jamis Buck (read <a href="http://weblog.jamisbuck.org/2008/11/9/legos-play-doh-and-programming">his post</a>, it&#8217;s very good!). This is a recurrent subject in talks with really smart programmers I know and I&#8217;ve tried to explain my point many times. I guess it&#8217;s time to write it down.</p>
<p>The whole point about <em>Dependency Injection</em> is that it is one of the best ways to achieve <em>Inversion of Control</em> for object dependencies. Take the <code>Carpenter</code> <em>object</em>: his <em>responsibility</em> is to make and repair wooden structures.</p>
<p><pre class="brush: java; light: true;">
class Carpenter {
    public void repair(WoodenStructure structure) {
        // ...
    }
    public WoodenStructure make(Specification spec) {
        // ...
    }
}
</pre></p>
<p>Because of his woodwork, the carpenter often needs a saw (<em>dependency</em>). Everytime the carpenter needs the saw, he may go after it (<em>objects who take care of their dependencies on their own</em>). </p>
<p><pre class="brush: java; light: true;">
class Carpenter {
    public void repair(WoodenStructure structure) {
        PowerSource powerSource = findPowerSourceInsideRoom(this.myRoom);
        Saw saw = new ElectricalSaw(powerSource);

        // ok, now I can *finally* do my real job...
    }
}
</pre></p>
<p>The problem is that saws could be complicated to get, to assemble, or even to build. The saw itself may have some dependencies (<code>PowerSource</code>), which in turn may also have some dependencies&#8230; Everyone who needs a saw must know where to find it, and potencially how to assemble it. What if saw technology changes and some would rather to use hydraulic saws? Every object who needs saws must then be changed.</p>
<p>When some change requires you to mess with code everywhere, clearly <strong>it&#8217;s a smell</strong>.</p>
<p>Have you also noticed that the carpenter has spent a lot of time doing stuff which isn&#8217;t his actual job? Finding power sources and assembling saws aren&#8217;t his responsibilities. His job is to repair wooden structures! (<em>Separation of Concerns</em>)</p>
<p>One of the possible solutions is the <em>Inversion of Control</em> principle. Instead of going after their dependencies, objects <strong>receive them</strong> somehow. Dependency Injection is the most common way:</p>
<p><pre class="brush: java; light: true;">
class Carpenter {
    private Saw saw;
    public Carpenter(Saw saw) {
        this.saw = saw;
    }
    public void repair(WoodenStructure structure) {
        // I can focus on my job!
    }
}
</pre></p>
<p>Now, the code is more testable. In unit tests where you don&#8217;t care about testing saws, but only about testing the carpenter, a mock of the saw can be provided (injected in) to the carpenter.</p>
<p>In the application code, you can also centralize and isolate code which decides what saw implementation to use. In other words, you now may be able to give the responsibility to do wiring to someone else (and only to him), so that objects can focus on their actual responsibilities (again <em>Separation of Concerns</em>). DI framework configuration is a good example of wiring centralized somewhere. If the saw implementation changes somehow you have just one place to modify (Factories help but don&#8217;t actually solve the problem &#8211; I&#8217;ll leave this discussion for another post).</p>
<p><pre class="brush: java; light: true;">
class GuyWithResponsibilityToDoWiring {
    public Saw wireSaw() {
        PowerSource powerSource = getPowerSource();
        return new Saw(powerSource);
    }
    public PowerSource getPowerSource() { ... }
}
</pre></p>
<p>Ok. <em>Plain Old Java Dependency Injection</em> so far. But what about Ruby?</p>
<p>Sure you might do dependency injection in Ruby (and its dynamic friends) exactly the same way as we did in Java. But, it took some time for me to realize that there are other ways of doing Inversion of Control in Ruby. That&#8217;s why I never needed a DI framework.</p>
<p>First, let&#8217;s use a more realistic example: repositories that need database connections:</p>
<p><pre class="brush: java; light: true;">
class Repository {
    private Connection connection;
    public Repository(Connection connection) {
        this.connection = connection;
    }
    public Something find(Integer id) {
        return this.connection.execute(&quot;SELECT ...&quot;);
    }
}
</pre></p>
<p>Our problem is that many places need a database connection. Then, we inject the database connection as a dependency in everywhere it is needed. This way, we avoid replicating database-connection-retrieval code in such places and we may keep the wiring code centralized somewhere.</p>
<p>In Ruby, there is another way to isolate and centralize common behavior which is needed in many other places. <strong>Modules</strong>!</p>
<p><pre class="brush: ruby; light: true;">
module ConnectionProvider
  def connection
    # open a database connection and return it
  end
end
</pre></p>
<p>This module can now be mixed, or injected in other classes, providing them its functionality (<em>wiring</em>). The &#8220;module injection&#8221; process is to some degree similar to what we did with dependency injection, because when a dependency is injected, it is providing some functionality to the class too.</p>
<p>Together with Ruby open classes, we may be able to centralize/isolate the injection of this module (perhaps even in the same file it is defined):</p>
<p><pre class="brush: ruby; light: true;">
# connection_provider.rb

module ConnectionProvider
  def connection
    # open a database connection and return it
  end
end

# reopening the class to mix the module in
class Repository
  include ConnectionProvider
end
</pre></p>
<p>The effect inside the <code>Repository</code> class is very similar to what we did with dependency injection before. Repositories are able to simply use database connections without worrying about how to get or to build them.</p>
<p>Now, the method that provides database connections exists because the <code>ConnectionProvider</code> module was mixed in this class. This is the same as if the dependency was injected (compare with the Java code for this Repository class):</p>
<p><pre class="brush: ruby; light: true;">
# repository.rb

class Repository
  def find(id)
    connection.execute(&quot;SELECT ...&quot;)
  end
end
</pre></p>
<p>The code is also very testable. This is due to the fact that Ruby is a dynamic language and the connection method of Repository objects can be overridden anywhere. Particularly inside tests or specs, the connection method can be easily overridden to return a mock of the database connection. </p>
<p>I see it as a different way of doing Inversion of Control. Of course it has its pros and cons. I can tell that it&#8217;s simpler (modules are a feature of the Ruby language), but it may give you headaches if you have a multithreaded application and must use different implementations of database connections in different places/threads, i.e. to inject different implementations of the dependency, depending on where and when it&#8217;s being injected.</p>
<p>Opening classes and including modules inside them is a global operation and isn&#8217;t thread safe (think of many threads trying to include different versions of the module inside the class). I&#8217;m not seeing this issue out there because most of Ruby applications aren&#8217;t multithreaded and run on many processes instead; mainly because of Rails.</p>
<p>Regular dependency injection still might have its place in Ruby for these cases where plain modules aren&#8217;t enough.</p>
<p>IMO, it&#8217;s just much harder to justify. In my experience modules and metaprogramming are usually just enough.</p>
<br />Filed under: <a href='http://fabiokung.com/category/design/'>design</a>, <a href='http://fabiokung.com/category/di/'>di</a>, <a href='http://fabiokung.com/category/ioc/'>ioc</a>, <a href='http://fabiokung.com/category/java/'>java</a>, <a href='http://fabiokung.com/category/language/'>language</a>, <a href='http://fabiokung.com/category/oo/'>oo</a>, <a href='http://fabiokung.com/category/refactor/'>refactor</a>, <a href='http://fabiokung.com/category/ruby/'>ruby</a> Tagged: <a href='http://fabiokung.com/tag/di/'>di</a>, <a href='http://fabiokung.com/tag/ioc/'>ioc</a>, <a href='http://fabiokung.com/tag/java/'>java</a>, <a href='http://fabiokung.com/tag/ruby/'>ruby</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/fabiokung.wordpress.com/255/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/fabiokung.wordpress.com/255/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/fabiokung.wordpress.com/255/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/fabiokung.wordpress.com/255/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/fabiokung.wordpress.com/255/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/fabiokung.wordpress.com/255/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/fabiokung.wordpress.com/255/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/fabiokung.wordpress.com/255/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/fabiokung.wordpress.com/255/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/fabiokung.wordpress.com/255/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/fabiokung.wordpress.com/255/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/fabiokung.wordpress.com/255/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/fabiokung.wordpress.com/255/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/fabiokung.wordpress.com/255/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=fabiokung.com&amp;blog=3424388&amp;post=255&amp;subd=fabiokung&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://fabiokung.com/2010/05/06/ruby-and-dependency-injection-in-a-dynamic-world/feed/</wfw:commentRss>
		<slash:comments>20</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/251c190c5a8277a3bc6197491f32da51?s=96&#38;d=wavatar&#38;r=PG" medium="image">
			<media:title type="html">Fabio Kung</media:title>
		</media:content>
	</item>
		<item>
		<title>Ruby indentation for access modifiers and their sections</title>
		<link>http://fabiokung.com/2010/04/05/ruby-indentation-for-access-modifiers-and-their-sections/</link>
		<comments>http://fabiokung.com/2010/04/05/ruby-indentation-for-access-modifiers-and-their-sections/#comments</comments>
		<pubDate>Tue, 06 Apr 2010 02:51:52 +0000</pubDate>
		<dc:creator>Fabio Kung</dc:creator>
				<category><![CDATA[editor]]></category>
		<category><![CDATA[language]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[identation]]></category>
		<category><![CDATA[style]]></category>

		<guid isPermaLink="false">http://fabiokung.com/?p=223</guid>
		<description><![CDATA[Ruby programmers are very flexible (and permissive) when talking about Ruby code indentation. Most of rubyists I know prefer to indent with two spaces instead of tabs (soft tabs in some editors). There are even some style guides and code conventions published for the language, but none of them is official and they talk too [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=fabiokung.com&amp;blog=3424388&amp;post=223&amp;subd=fabiokung&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Ruby programmers are very flexible (and permissive) when talking about Ruby code indentation. Most of rubyists I know prefer to <a href="http://www.rubyinside.com/ruby-style-guides-and-tools-how-to-write-good-looking-ruby-1272.html">indent with two spaces</a> instead of tabs (soft tabs in some editors). There are even <a href="http://github.com/chneukirchen/styleguide/blob/master/RUBY-STYLE">some</a> <a href="http://www.google.com/search?q=ruby+style+guide">style guides</a> and <a href="http://www.google.com/search?q=ruby+code+conventions">code conventions</a> published for the language, but none of them is official and they talk too little about code indentation practices.</p>
<p>Things go even worse when we have to choose how to indent <em>private</em>, <em>protected</em> and <em>public</em> sections of classes. Programmers and projects I&#8217;ve seen so far seem to adopt different styles. I&#8217;ll try to summarize them here:</p>
<h2>1. Indent as a new block</h2>
<p>This is the most common pattern I see out there. Some programmers prefer to treat sections created by access modifiers as new blocks and indent them:</p>
<p><pre class="brush: ruby;">
class MyClass

  def the_public_method
    # ...
  end

  private

    def first_private_method
      # ...
    end

    def second_private_method
      # ...
    end

  protected

    def the_protected_method
      # ...
    end

end
</pre></p>
<h3>Pros:</h3>
<ul>
<li><strong>Visibility</strong>: easy to see if a method has a non-standard access modifier (non-public in most cases).</li>
<li>Produces a very readable code.</li>
<li>Used in the rails codebase (mainly older code).</li>
</ul>
<h3>Cons:</h3>
<ul>
<li><strong>Semantically wrong</strong>: access modifiers do not create new scopes. They are simple method calls. Deeper explanation in the next item.</li>
<li>Methods inside the same scope with different indentation levels.</li>
<li>(opinion) One more level of indentation. When you have classes inside modules it starts being a problem: <em>&#8220;indentation hell&#8221;</em> <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> . Your code ends up using its 80 columns very fast and you start having to break lines more often.</li>
</ul>
<h2>2. No indentation</h2>
<p>Ruby access modifiers are simple method calls. The <a href="http://ruby-doc.org/core/classes/Module.html">Module</a> class (from which Ruby classes inherit) has the <a href="http://ruby-doc.org/core/classes/Module.html#M001641">private</a>, <a href="http://ruby-doc.org/core/classes/Module.html#M001640">protected</a> and <a href="http://ruby-doc.org/core/classes/Module.html#M001639">public</a> methods, that when called with no arguments, simply change the visibility of subsequent defined methods. You may confirm this by testing that the following code works:</p>
<p><pre class="brush: ruby;">
class MyClass

  self.send(:private)

  def the_private_method
    # ...
  end

  def another_private_method
    # ...
  end

end
</pre></p>
<p>Try to call any of these methods in an instance of the <code>MyClass</code> class and you will confirm they are private.</p>
<p>Because access modifiers are simple method calls, they <strong>don&#8217;t create a new scope</strong>. Semantically speaking, they shouldn&#8217;t create another level of indentation. This is even advocated <a href="http://www.pathf.com/blogs/ruby-and-rails-style-guide/#indentation_of_access_modifiers">by one of the most important Ruby style guides</a>.</p>
<p><pre class="brush: ruby;">
class MyClass

  def the_public_method
    # ...
  end

  private

  def first_private_method
    # ...
  end

  def second_private_method
    # ...
  end

  protected

  def the_protected_method
    # ...
  end

end
</pre></p>
<p>Because of its correctness, this was my preferred style until recently, when I found the next ones.</p>
<h3>Pros:</h3>
<ul>
<li><strong>It is semantically correct</strong>: method calls don&#8217;t create new scopes, then method calls shouldn&#8217;t increase indentation levels.</li>
<li>(opinion) this style makes access modifiers look like python decorators, Java annotations and C# attributes. IMO, it&#8217;s one of the nice things about Ruby: its ability to reproduce most of other languages features, without requiring new syntax or fancy constructs. It&#8217;s a simple method call.</li>
</ul>
<h3>Cons:</h3>
<ul>
<li>Hard to see if a method has any non-standard access modifier. In classes with many methods (code smell!) you must constantly scroll to see what access modifier is applied.</li>
<li>Some would argue that this could be solved with proper syntax highlighting or visual method decoration. But it requires editor/IDE support, then I&#8217;m considering it as a disadvantage.</li>
</ul>
<h2>3. if-else style</h2>
<p>We have a similar case in Ruby: the <code>if</code> keyword creates a new block and has associated <code>else</code> and <code>elsif</code> statements, which are also new blocks. The convention suggests the following indentation (note that <code>if</code>, <code>elsif</code> and <code>else</code> are in the same indentation level):</p>
<p><pre class="brush: ruby;">
if something?
  2.times { play }
  jump(2.meters)
elsif other?
  sing and dance
else
  cry
  walk
end
</pre></p>
<p>Some of the <a href="http://github.com/rails/rails/blob/master/railties/lib/rails/application.rb">code recently pushed to Rails 3.0</a> use the same indentation style for classes with access modifiers. I liked it:</p>
<p><pre class="brush: ruby;">
class MyClass

  def the_public_method
    # ...
  end

private

  def first_private_method
    # ...
  end

  def second_private_method
    # ...
  end

protected

  def the_protected_method
    # ...
  end

end
</pre></p>
<h3>Pros:</h3>
<ul>
<li>Easy to see access modifiers inside classes. With a fast look it is easy to identify sections of private, public and protected methods. They look like blocks.</li>
<li>Readable code. Similar to other Ruby constructs.</li>
<li>Used in the rails codebase (mainly newer code).</li>
</ul>
<h3>Cons:</h3>
<ul>
<li>Still semantically wrong. Access modifiers are inside the scope created by the <code>class</code> keyword. They should be indented.</li>
<li><code>if</code>, <code>elsif</code> and <code>else</code> are keywords and have special meaning. Access modifiers aren&#8217;t and should follow the same convention of other method calls.</li>
</ul>
<h2>4. Indentation with one space</h2>
<p>C++ also splits private, protected and public methods in sections. The construct is very similar to Ruby:</p>
<p><pre class="brush: cpp;">
class MyClass {
 public:
  MyClass();
  void ThePublicMethod(int n);
  void Print(ostream &amp;output) const;

 private:
  int *Items;
  bool FirstPrivateMethod();
  int SecondPrivateMethod();
};
</pre></p>
<p>While reading Google&#8217;s style guide for C++ code, their <a href="http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml#Class_Format">recommendation for public, private and protected sections</a> indentation caught my attention. They suggest that you indent the <code>private</code>, <code>protected</code> and <code>public</code> keywords with <strong>only one space</strong>.</p>
<p>It seemed a bit awkward in the beginning. But soon, I started liking it because it makes sections easy to identify, access modifiers remain indented inside classes and methods stay all in the same indentation level, as they are all in the same scope.</p>
<p><pre class="brush: ruby;">
class MyClass

  def the_public_method
    # ...
  end

 private

  def first_private_method
    # ...
  end

  def second_private_method
    # ...
  end

 protected

  def the_protected_method
    # ...
  end

end
</pre></p>
<h3>Pros:</h3>
<ul>
<li>Easy to see access modifiers and sections inside classes.</li>
<li>Semantically correct.</li>
<li>All methods remain in the same indentation level.</li>
<li>Google style guide.</li>
</ul>
<h3>Cons:</h3>
<ul>
<li>People are always fighting for 2 spaces vs 4 spaces vs tabs indentation. One space? <strong>Very uncommon</strong>.</li>
<li>Special treatment for regular method calls. Statements inside the same scope with different indentation levels</li>
</ul>
<h2>My choice</h2>
<p>Currently, I tend to like the 3rd (new Rails style) and 4th (Google) styles more. I somehow feel they give the best deal, considering their advantages and disadvantages. Being able to easily identify sections and access modifiers inside classes is very important to me.</p>
<p>In my current project, the team adopted the Google style. I&#8217;m happy with it, but you must be flexible in the beginning to adopt one-space-indentation. I won&#8217;t lie, it feels strange until you get used. Another issue I have is that my TextMate indent Ruby code with two spaces and treat them as one &#8220;step&#8221; when navigating with keyboard cursors. Then, I have to type a few more keystrokes to indent access modifiers the way I want. It&#8217;s hard to explain, you will have to try it yourself.</p>
<p>And you, what&#8217;s your opinion?<br />
How do you indent access modifiers and their sections inside classes?</p>
<br />Filed under: <a href='http://fabiokung.com/category/editor/'>editor</a>, <a href='http://fabiokung.com/category/language/'>language</a>, <a href='http://fabiokung.com/category/ruby/'>ruby</a> Tagged: <a href='http://fabiokung.com/tag/code/'>code</a>, <a href='http://fabiokung.com/tag/identation/'>identation</a>, <a href='http://fabiokung.com/tag/ruby/'>ruby</a>, <a href='http://fabiokung.com/tag/style/'>style</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/fabiokung.wordpress.com/223/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/fabiokung.wordpress.com/223/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/fabiokung.wordpress.com/223/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/fabiokung.wordpress.com/223/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/fabiokung.wordpress.com/223/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/fabiokung.wordpress.com/223/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/fabiokung.wordpress.com/223/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/fabiokung.wordpress.com/223/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/fabiokung.wordpress.com/223/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/fabiokung.wordpress.com/223/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/fabiokung.wordpress.com/223/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/fabiokung.wordpress.com/223/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/fabiokung.wordpress.com/223/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/fabiokung.wordpress.com/223/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=fabiokung.com&amp;blog=3424388&amp;post=223&amp;subd=fabiokung&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://fabiokung.com/2010/04/05/ruby-indentation-for-access-modifiers-and-their-sections/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/251c190c5a8277a3bc6197491f32da51?s=96&#38;d=wavatar&#38;r=PG" medium="image">
			<media:title type="html">Fabio Kung</media:title>
		</media:content>
	</item>
		<item>
		<title>Soda is cheaper than Water</title>
		<link>http://fabiokung.com/2009/10/24/soda-is-cheaper-than-water/</link>
		<comments>http://fabiokung.com/2009/10/24/soda-is-cheaper-than-water/#comments</comments>
		<pubDate>Sat, 24 Oct 2009 16:57:59 +0000</pubDate>
		<dc:creator>Fabio Kung</dc:creator>
				<category><![CDATA[brazil]]></category>
		<category><![CDATA[decision]]></category>
		<category><![CDATA[design]]></category>
		<category><![CDATA[benefit]]></category>
		<category><![CDATA[cost]]></category>
		<category><![CDATA[options]]></category>
		<category><![CDATA[strategy]]></category>

		<guid isPermaLink="false">http://fabiokung.com/?p=208</guid>
		<description><![CDATA[(at least here in Brazil) These prices were taken from http://www.paodeacucar.com.br, Sao Paulo, in the date of this post. Compare them: Soda (Brazilian Guarana): Versus standard natural Water: The soda has approximately a R$ 0,92 price/liter ratio, versus R$ 1,25 price/liter of the natural water bottle. Some years ago, I would never imagine soda being [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=fabiokung.com&amp;blog=3424388&amp;post=208&amp;subd=fabiokung&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p style="font-size:.8em;"><em>(at least here in Brazil)</em></p>
<p>These prices were taken from <a href="http://www.paodeacucar.com.br">http://www.paodeacucar.com.br</a>, Sao Paulo, in the date of this post. Compare them:</p>
<p><strong>Soda (<a href="http://en.wikipedia.org/wiki/Guarana">Brazilian Guarana</a>)</strong>:</p>
<p><img src="http://fabiokung.files.wordpress.com/2009/10/picture-1.png?w=490" alt="Guarana Tai" title="Guarana Tai"   class="aligncenter size-full wp-image-213" /></p>
<p>Versus <strong>standard natural Water</strong>:</p>
<p><img src="http://fabiokung.files.wordpress.com/2009/10/picture-2.png?w=490" alt="Agua Indaia sem gas" title="Agua Indaia sem gas"   class="aligncenter size-full wp-image-214" /></p>
<p>The soda has approximately a <strong>R$ 0,92 price/liter</strong> ratio, versus <strong>R$ 1,25 price/liter</strong> of the natural water bottle. Some years ago, I would never imagine soda being so much cheaper than water. This just show us how the world is really turning fast.</p>
<p>Even being more expensive, I have no doubt that water is simpler than soda, and more healthy too. Hey, they <strong>use water</strong> in soda production process!</p>
<p>My message:</p>
<blockquote><p>Even when the <strong>flavored</strong> (more complicated) solution seems to be <strong>cheaper</strong> and more attractive, many times the <strong>simpler </strong> solution is <strong>more healthy</strong>.</p></blockquote>
<p>Think about it when making your next decision about technology and software design. Please.</p>
<br />Posted in brazil, decision, design Tagged: benefit, cost, decision, design, options, strategy <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/fabiokung.wordpress.com/208/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/fabiokung.wordpress.com/208/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/fabiokung.wordpress.com/208/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/fabiokung.wordpress.com/208/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/fabiokung.wordpress.com/208/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/fabiokung.wordpress.com/208/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/fabiokung.wordpress.com/208/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/fabiokung.wordpress.com/208/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/fabiokung.wordpress.com/208/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/fabiokung.wordpress.com/208/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/fabiokung.wordpress.com/208/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/fabiokung.wordpress.com/208/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/fabiokung.wordpress.com/208/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/fabiokung.wordpress.com/208/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=fabiokung.com&amp;blog=3424388&amp;post=208&amp;subd=fabiokung&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://fabiokung.com/2009/10/24/soda-is-cheaper-than-water/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/251c190c5a8277a3bc6197491f32da51?s=96&#38;d=wavatar&#38;r=PG" medium="image">
			<media:title type="html">Fabio Kung</media:title>
		</media:content>

		<media:content url="http://fabiokung.files.wordpress.com/2009/10/picture-1.png" medium="image">
			<media:title type="html">Guarana Tai</media:title>
		</media:content>

		<media:content url="http://fabiokung.files.wordpress.com/2009/10/picture-2.png" medium="image">
			<media:title type="html">Agua Indaia sem gas</media:title>
		</media:content>
	</item>
		<item>
		<title>Status report: new job, new life</title>
		<link>http://fabiokung.com/2009/07/27/status-report-new-job-new-life/</link>
		<comments>http://fabiokung.com/2009/07/27/status-report-new-job-new-life/#comments</comments>
		<pubDate>Tue, 28 Jul 2009 02:38:32 +0000</pubDate>
		<dc:creator>Fabio Kung</dc:creator>
				<category><![CDATA[caelum]]></category>
		<category><![CDATA[career]]></category>
		<category><![CDATA[job]]></category>
		<category><![CDATA[locaweb]]></category>
		<category><![CDATA[cloud]]></category>
		<category><![CDATA[deployment]]></category>

		<guid isPermaLink="false">http://fabiokung.com/?p=182</guid>
		<description><![CDATA[I&#8217;m sorry my last post was about three months ago. But, I have a good excuse: I&#8217;m just married! (and I took a nice and fast honeymoon vacation) Besides that, after three happy years, full time at Caelum, here is the shocking news: I&#8217;m now part of the Locaweb team! This was (and is still [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=fabiokung.com&amp;blog=3424388&amp;post=182&amp;subd=fabiokung&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m sorry my last post was about three months ago. But, I have a good excuse: I&#8217;m just married!<br />
(and I took a nice and fast honeymoon vacation)</p>
<p>Besides that, after three happy years, full time at <a href="http://www.caelum.com.br/">Caelum</a>, here is the shocking news: I&#8217;m now part of the <a href="http://www.locaweb.com.br/">Locaweb</a> team!</p>
<p><a href="http://www.locaweb.com.br/"><img src="http://fabiokung.files.wordpress.com/2009/07/logo_lw_maior.gif?w=490" alt="Locaweb" title="Locaweb"   class="aligncenter size-full wp-image-201" /></a></p>
<p>This was (and is still being) a very hard decision. People close to me know, that I have a nice and strong relationship with <a href="http://www.caelum.com.br/">Caelum</a>. Man, I love the company!</p>
<p>I&#8217;m feeling very strange, because I&#8217;m sad I&#8217;m no more full time at <a href="http://www.caelum.com.br/">Caelum</a> and, at the same time, I&#8217;m extremely excited with the new challenges which are about to come. My decision to join <a href="http://www.locaweb.com.br/">Locaweb</a>, which is a really good place to work, just proves I&#8217;m very anxious to make a good job there. Other than that, I&#8217;m going to sit near very known people as my friend <a href="http://www.akitaonrails.com/">Fabio Akita</a> and <a href="http://agileandart.blogspot.com/">Daniel Cukier</a>, just to cite some.</p>
<p>I&#8217;m joining the talented <strong>Cloud Computing</strong> team and I hope I can help them to improve the <a href="http://www.locaweb.com.br/produtos/cloud-server.html">Cloud Server</a> product. An enormous responsibility!</p>
<p><a href="http://www.locaweb.com.br/produtos/cloud-server.html"><img src="http://fabiokung.files.wordpress.com/2009/07/banner_cloud_server.jpg?w=300&#038;h=46" alt="Cloud Server" title="Cloud Server" width="300" height="46" class="aligncenter size-medium wp-image-202" /></a></p>
<p><a href="http://www.locaweb.com.br/">Locaweb</a> is a huge company and I must admit I&#8217;m a little bit scared with the size of things there. They have many teams working on a big diversity of challenging products. They even have <a href="http://www.locaweb.com.br/produtos/servidores-dedicados/infra-estrutura.html">their own Datacenter</a>! Locaweb already embraced agile and people there are very open minded, because as a hosting provider, they have to deal with almost all kind of technology.</p>
<p>Because of my work prior to Locaweb, I know the expectations on me are  quite high. I like being honest and just to be clear, I&#8217;m not better than anyone. I&#8217;m relatively new to this area, so I still have too much to learn. Fortunately, I already know many people at Locaweb and I really believe they will help me start being productive. Additionally, there are areas I know I can give something. I&#8217;m joining <strong>to help</strong>, not to prove anything to anyone.</p>
<p>It&#8217;s also important to say, that I couldn&#8217;t fully leave Caelum. I&#8217;m still part of the team, <a href="http://www.caelum.com.br/instrutores/">as an instructor</a>, and I keep helping them in many areas, such as <a href="http://www.arquiteturajava.com.br/">the book</a>, courses, textbooks, internal discussions, events, talks and where else I can.</p>
<p><a href="http://www.arquiteturajava.com.br"><img src="http://fabiokung.files.wordpress.com/2009/07/img_livro.png?w=178&#038;h=300" alt="Arquitetura e Design de Software - Uma visão sobre a plataforma Java" title="Arquitetura e Design de Software - Uma visão sobre a plataforma Java" width="178" height="300" class="aligncenter size-medium wp-image-204" /></a></p>
<p>That&#8217;s it. Comments, questions and feature suggestions are, as always, welcome. As a cloud provider, I&#8217;m happy to hear what would you like to see in a cloud product and what can we do to help you scale and earn profit.</p>
<p>From now on, I stop referring to Locaweb as &#8220;they&#8221; and instead as &#8220;<strong>we</strong> at Locaweb &#8230;&#8221;.</p>
<br />Posted in caelum, career, job, locaweb Tagged: caelum, career, cloud, deployment, job, locaweb <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/fabiokung.wordpress.com/182/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/fabiokung.wordpress.com/182/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/fabiokung.wordpress.com/182/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/fabiokung.wordpress.com/182/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/fabiokung.wordpress.com/182/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/fabiokung.wordpress.com/182/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/fabiokung.wordpress.com/182/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/fabiokung.wordpress.com/182/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/fabiokung.wordpress.com/182/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/fabiokung.wordpress.com/182/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/fabiokung.wordpress.com/182/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/fabiokung.wordpress.com/182/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/fabiokung.wordpress.com/182/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/fabiokung.wordpress.com/182/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=fabiokung.com&amp;blog=3424388&amp;post=182&amp;subd=fabiokung&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://fabiokung.com/2009/07/27/status-report-new-job-new-life/feed/</wfw:commentRss>
		<slash:comments>38</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/251c190c5a8277a3bc6197491f32da51?s=96&#38;d=wavatar&#38;r=PG" medium="image">
			<media:title type="html">Fabio Kung</media:title>
		</media:content>

		<media:content url="http://fabiokung.files.wordpress.com/2009/07/logo_lw_maior.gif" medium="image">
			<media:title type="html">Locaweb</media:title>
		</media:content>

		<media:content url="http://fabiokung.files.wordpress.com/2009/07/banner_cloud_server.jpg?w=300" medium="image">
			<media:title type="html">Cloud Server</media:title>
		</media:content>

		<media:content url="http://fabiokung.files.wordpress.com/2009/07/img_livro.png?w=178" medium="image">
			<media:title type="html">Arquitetura e Design de Software - Uma visão sobre a plataforma Java</media:title>
		</media:content>
	</item>
		<item>
		<title>Spider Man&#8217;s professionalism at RailsConf 09</title>
		<link>http://fabiokung.com/2009/05/09/spider-mans-professionalism-at-railsconf-09/</link>
		<comments>http://fabiokung.com/2009/05/09/spider-mans-professionalism-at-railsconf-09/#comments</comments>
		<pubDate>Sat, 09 May 2009 16:58:32 +0000</pubDate>
		<dc:creator>Fabio Kung</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://fabiokung.com/?p=171</guid>
		<description><![CDATA[Professionalism definition from Uncle Bob in his recent talk at RailsConf 2009: &#8220;Discipline to wielding of power.&#8221; &#8211; Robert Martin (aka Uncle Bob) To me, it looks pretty much similar to the &#8220;Ruby&#8221; definition from Chad Fowler in the last Rails Summit Brasil: &#8220;Ruby is a dangerous tool.&#8221; &#8211; Chad Fowler Wich makes me remember [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=fabiokung.com&amp;blog=3424388&amp;post=171&amp;subd=fabiokung&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><strong>Professionalism</strong> definition from <a href="http://blog.objectmentor.com/">Uncle Bob</a> in his <a href="http://railsconf.blip.tv/file/2089545/">recent talk</a> at RailsConf 2009:</p>
<blockquote cite="http://railsconf.blip.tv/file/2089545/"><p>&#8220;Discipline to wielding of power.&#8221;</p>
<p align="right">&#8211; Robert Martin (aka Uncle Bob)</p>
</blockquote>
<p>To me, it looks pretty much similar to the &#8220;Ruby&#8221; definition from <a href="http://chadfowler.com/">Chad Fowler</a> in the last Rails Summit Brasil:</p>
<blockquote><p>&#8220;Ruby is a dangerous tool.&#8221;</p>
<p align="right">&#8211; Chad Fowler</p>
</blockquote>
<p>Wich makes me remember <a href="http://en.wikipedia.org/wiki/Uncle_Ben#.22With_great_power_comes_great_responsibility.22">Uncle Ben&#8217;s</a> advice to Spider Man:</p>
<blockquote><p>&#8220;With great power comes great responsibility.&#8221;</p>
<p align="right">&#8211; Uncle Ben</p>
</blockquote>
<p>Would be <em>Uncle Bob</em> inspired by <em>Uncle Ben</em>? What if they are <strong>the same person</strong>? <img src='http://s0.wp.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </p>
<br />Posted in Uncategorized  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/fabiokung.wordpress.com/171/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/fabiokung.wordpress.com/171/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/fabiokung.wordpress.com/171/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/fabiokung.wordpress.com/171/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/fabiokung.wordpress.com/171/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/fabiokung.wordpress.com/171/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/fabiokung.wordpress.com/171/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/fabiokung.wordpress.com/171/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/fabiokung.wordpress.com/171/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/fabiokung.wordpress.com/171/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/fabiokung.wordpress.com/171/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/fabiokung.wordpress.com/171/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/fabiokung.wordpress.com/171/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/fabiokung.wordpress.com/171/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=fabiokung.com&amp;blog=3424388&amp;post=171&amp;subd=fabiokung&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://fabiokung.com/2009/05/09/spider-mans-professionalism-at-railsconf-09/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/251c190c5a8277a3bc6197491f32da51?s=96&#38;d=wavatar&#38;r=PG" medium="image">
			<media:title type="html">Fabio Kung</media:title>
		</media:content>
	</item>
		<item>
		<title>VRaptor2 on Google App Engine</title>
		<link>http://fabiokung.com/2009/04/08/vraptor2-on-google-app-engine/</link>
		<comments>http://fabiokung.com/2009/04/08/vraptor2-on-google-app-engine/#comments</comments>
		<pubDate>Wed, 08 Apr 2009 07:37:12 +0000</pubDate>
		<dc:creator>Fabio Kung</dc:creator>
				<category><![CDATA[java]]></category>
		<category><![CDATA[vraptor]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://fabiokung.com/?p=163</guid>
		<description><![CDATA[With all the recent excitement about Google supporting Java for the App Engine platform, I&#8217;m proud to say that VRaptor2 just works, out-of-the-box! All you have to do is copy the required jars that come in the vraptor distribution, configure the VRaptorServlet (or VRaptorFilter) in web.xml and enable session support in the appengine-web.xml: Being able [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=fabiokung.com&amp;blog=3424388&amp;post=163&amp;subd=fabiokung&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>With all the recent excitement about Google supporting Java for the App Engine platform, I&#8217;m proud to say that <a href="http://vraptor.org">VRaptor2</a> just works, out-of-the-box!</p>
<p>All you have to do is copy the required jars that come in the vraptor distribution, configure the <code>VRaptorServlet</code> (or <code>VRaptorFilter</code>) in web.xml and enable session support in the appengine-web.xml:</p>
<p><pre class="brush: xml;">
&lt;appengine-web-app xmlns=&quot;http://appengine.google.com/ns/1.0&quot;&gt;
	&lt;application&gt;...&lt;/application&gt;
	&lt;version&gt;1&lt;/version&gt;
	&lt;sessions-enabled&gt;true&lt;/sessions-enabled&gt;

	&lt;!-- ... --&gt;
&lt;/appengine-web-app&gt;
</pre></p>
<p>Being able to use my favorite Java Web MVC framework, to develop and deploy applications to Google&#8217;s cloud infrastructure, is really nice.</p>
<br />Posted in java, vraptor, web  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/fabiokung.wordpress.com/163/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/fabiokung.wordpress.com/163/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/fabiokung.wordpress.com/163/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/fabiokung.wordpress.com/163/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/fabiokung.wordpress.com/163/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/fabiokung.wordpress.com/163/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/fabiokung.wordpress.com/163/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/fabiokung.wordpress.com/163/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/fabiokung.wordpress.com/163/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/fabiokung.wordpress.com/163/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/fabiokung.wordpress.com/163/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/fabiokung.wordpress.com/163/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/fabiokung.wordpress.com/163/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/fabiokung.wordpress.com/163/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=fabiokung.com&amp;blog=3424388&amp;post=163&amp;subd=fabiokung&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://fabiokung.com/2009/04/08/vraptor2-on-google-app-engine/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/251c190c5a8277a3bc6197491f32da51?s=96&#38;d=wavatar&#38;r=PG" medium="image">
			<media:title type="html">Fabio Kung</media:title>
		</media:content>
	</item>
		<item>
		<title>Ruby 1.9: why I don&#8217;t need SmallTalk anymore</title>
		<link>http://fabiokung.com/2009/03/04/ruby-19-why-i-dont-need-smalltalk-anymore/</link>
		<comments>http://fabiokung.com/2009/03/04/ruby-19-why-i-dont-need-smalltalk-anymore/#comments</comments>
		<pubDate>Wed, 04 Mar 2009 04:00:12 +0000</pubDate>
		<dc:creator>Fabio Kung</dc:creator>
				<category><![CDATA[dsl]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://fabiokung.com/?p=154</guid>
		<description><![CDATA[tip: Ruby 1.9 new literal Hash syntax. This shows Ruby improving even more, as a good host for internal DSLs. Posted in dsl, ruby<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=fabiokung.com&amp;blog=3424388&amp;post=154&amp;subd=fabiokung&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><pre class="brush: ruby;">
source = Account.first
destination = Account.last

transfer amount: 10, from: source, to: destination
</pre></p>
<p>tip: <a href="http://eigenclass.org/hiki.rb?Changes+in+Ruby+1.9#l6">Ruby 1.9 new literal Hash syntax</a>. </p>
<p>This shows Ruby improving even more, as a good host for internal DSLs.</p>
<br />Posted in dsl, ruby  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/fabiokung.wordpress.com/154/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/fabiokung.wordpress.com/154/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/fabiokung.wordpress.com/154/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/fabiokung.wordpress.com/154/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/fabiokung.wordpress.com/154/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/fabiokung.wordpress.com/154/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/fabiokung.wordpress.com/154/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/fabiokung.wordpress.com/154/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/fabiokung.wordpress.com/154/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/fabiokung.wordpress.com/154/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/fabiokung.wordpress.com/154/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/fabiokung.wordpress.com/154/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/fabiokung.wordpress.com/154/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/fabiokung.wordpress.com/154/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=fabiokung.com&amp;blog=3424388&amp;post=154&amp;subd=fabiokung&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://fabiokung.com/2009/03/04/ruby-19-why-i-dont-need-smalltalk-anymore/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/251c190c5a8277a3bc6197491f32da51?s=96&#38;d=wavatar&#38;r=PG" medium="image">
			<media:title type="html">Fabio Kung</media:title>
		</media:content>
	</item>
		<item>
		<title>Rfactor: Ruby Refactoring for your loved editor</title>
		<link>http://fabiokung.com/2009/02/04/rfactor-ruby-refactoring-for-your-loved-editor/</link>
		<comments>http://fabiokung.com/2009/02/04/rfactor-ruby-refactoring-for-your-loved-editor/#comments</comments>
		<pubDate>Wed, 04 Feb 2009 14:31:11 +0000</pubDate>
		<dc:creator>Fabio Kung</dc:creator>
				<category><![CDATA[bundle]]></category>
		<category><![CDATA[editor]]></category>
		<category><![CDATA[intellij]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[refactor]]></category>
		<category><![CDATA[refactoring]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[textmate]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[ast]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[coding]]></category>
		<category><![CDATA[emacs]]></category>
		<category><![CDATA[gedit]]></category>
		<category><![CDATA[parsetree]]></category>
		<category><![CDATA[ruby_parser]]></category>
		<category><![CDATA[vi]]></category>
		<category><![CDATA[vim]]></category>

		<guid isPermaLink="false">http://fabiokung.com/?p=128</guid>
		<description><![CDATA[I know we all love Ruby, and doesn&#8217;t care that much about not having auto completion/IntelliSense available. I don&#8217;t care that much about auto completion, when coding in Ruby, myself. What I really like in Java IDEs is their refactoring support. Eclipse and IntelliJ IDEA are simply awesome in this space for Java. We still [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=fabiokung.com&amp;blog=3424388&amp;post=128&amp;subd=fabiokung&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I know we all love Ruby, and doesn&#8217;t care that much about not having auto completion/IntelliSense available.</p>
<p>I don&#8217;t care that much about auto completion<del datetime="00">, when coding in Ruby,</del> myself. What I really like in Java IDEs is their refactoring support. <a href="http://eclipse.org">Eclipse</a> and <a href="http://www.jetbrains.com/idea/">IntelliJ IDEA</a> are simply awesome in this space for Java. We still have <a href="http://www.jetbrains.com/resharper/">ReSharper</a> for Visual Studio and others, targeting other languages. Ruby has <a href="http://netbeans.org">NetBeans</a>, <a href="http://aptana.com/radrails">Aptana RadRails</a>, <a href="http://www.jetbrains.com/ruby/index.html">RubyMine</a> and <a href="http://www.codegear.com/products/3rdrail">TurboRuby/3rdRail</a> doing a great job in this area.</p>
<p>But, I have this feeling that most of Ruby developers do not use IDEs (including myself). We are using good text editors, such as TextMate, Vim, Emacs and GEdit. They are good enough. Why would I need something else?</p>
<p>I have to admit. I really miss some refactorings while programming in Ruby. Particularly, the lack of <em>&#8220;Extract Method&#8221;</em> and <em>&#8220;Extract Variable&#8221;</em> bothers me. They aren&#8217;t even complicated, why hasn&#8217;t someone already implemented them?</p>
<p>So, I would like to introduce <a href="http://github.com/fabiokung/rfactor">Rfactor</a>. It is a Ruby gem, which aims to provide common and simple refactorings for Ruby code. RubyParser from Ryan Davis is being used to analyze and manipulate the source code <a href="http://en.wikipedia.org/wiki/Abstract_syntax_tree">AST</a>, in the form of <a href="http://en.wikipedia.org/wiki/Sexp">Sexps</a>.</p>
<span style="text-align:center; display: block;"><a href="http://fabiokung.com/2009/02/04/rfactor-ruby-refactoring-for-your-loved-editor/"><img src="http://img.youtube.com/vi/2tx0_mCk9IQ/2.jpg" alt="" /></a></span>
<p>In theory, we should be able to use <a href="http://github.com/fabiokung/rfactor">Rfactor</a> to power any editor, adding refactoring capabilities to it. I&#8217;m targeting TextMate, but I would love to see contributions for others. The TextMate Bundle is hosted on github:</p>
<p align="center">
<a href="http://github.com/fabiokung/rfactor-tmbundle/tree/master">Rfactor TextMate Bundle, with installation instructions</a></p>
<p>This very first release has support only for basic &#8220;Extract Method&#8221;: inside methods and without trying to guess the method parameters and return.</p>
<p>Stay in touch, there is much more coming!</p>
<br />Posted in bundle, editor, intellij, rails, refactor, refactoring, ruby, textmate, Uncategorized Tagged: ast, bundle, code, coding, editor, emacs, gedit, parsetree, rails, refactor, refactoring, ruby, ruby_parser, textmate, vi, vim <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/fabiokung.wordpress.com/128/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/fabiokung.wordpress.com/128/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/fabiokung.wordpress.com/128/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/fabiokung.wordpress.com/128/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/fabiokung.wordpress.com/128/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/fabiokung.wordpress.com/128/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/fabiokung.wordpress.com/128/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/fabiokung.wordpress.com/128/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/fabiokung.wordpress.com/128/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/fabiokung.wordpress.com/128/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/fabiokung.wordpress.com/128/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/fabiokung.wordpress.com/128/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/fabiokung.wordpress.com/128/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/fabiokung.wordpress.com/128/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=fabiokung.com&amp;blog=3424388&amp;post=128&amp;subd=fabiokung&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://fabiokung.com/2009/02/04/rfactor-ruby-refactoring-for-your-loved-editor/feed/</wfw:commentRss>
		<slash:comments>20</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/251c190c5a8277a3bc6197491f32da51?s=96&#38;d=wavatar&#38;r=PG" medium="image">
			<media:title type="html">Fabio Kung</media:title>
		</media:content>
	</item>
	</channel>
</rss>
