<?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>The Kaptain on ... stuff &#187; Ivy</title>
	<atom:link href="http://www.kellyrob99.com/blog/tag/ivy/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.kellyrob99.com/blog</link>
	<description>Tales of development, life and the folly that goes along with both</description>
	<lastBuildDate>Sun, 04 Dec 2011 21:51:34 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
		<item>
		<title>I am a Procedural Programmer</title>
		<link>http://www.kellyrob99.com/blog/2009/07/22/i-am-a-procedural-programmer/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=i-am-a-procedural-programmer</link>
		<comments>http://www.kellyrob99.com/blog/2009/07/22/i-am-a-procedural-programmer/#comments</comments>
		<pubDate>Thu, 23 Jul 2009 08:34:41 +0000</pubDate>
		<dc:creator>TheKaptain</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Apache Ant]]></category>
		<category><![CDATA[Apache Maven]]></category>
		<category><![CDATA[Closure]]></category>
		<category><![CDATA[Functional programming]]></category>
		<category><![CDATA[Grape]]></category>
		<category><![CDATA[Groovy]]></category>
		<category><![CDATA[Guice]]></category>
		<category><![CDATA[Integrated development environment]]></category>
		<category><![CDATA[Ivy]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Lisp]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Programming language]]></category>
		<category><![CDATA[Unit testing]]></category>

		<guid isPermaLink="false">http://www.kellyrob99.com/blog/?p=538</guid>
		<description><![CDATA[I had occasion today to reflect on what I&#8217;ve learned in the last few years developing software and it occured to me, not much has really changed since I first struggled with Lisp and Scheme in university. I still don&#8217;t completely &#8220;get&#8221; functional programming! Wrapping my head around all those brackets in any derivative of [...]
Related posts:<ol>
<li><a href='http://www.kellyrob99.com/blog/2009/04/14/groovy-and-bash-can-scripting-get-much-easier/' rel='bookmark' title='Groovy and Bash &#8211; can scripting get much easier?'>Groovy and Bash &#8211; can scripting get much easier?</a></li>
<li><a href='http://www.kellyrob99.com/blog/2009/04/19/groovy-and-glazed-lists-with-grape/' rel='bookmark' title='Groovy and Glazed Lists with Grape'>Groovy and Glazed Lists with Grape</a></li>
<li><a href='http://www.kellyrob99.com/blog/2009/08/14/griffon-support-in-latest-intellij-eap/' rel='bookmark' title='Griffon support in latest Intellij EAP'>Griffon support in latest Intellij EAP</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>I had occasion today to reflect on what I&#8217;ve learned in the last few years developing software and it occured to me, not much has really changed since I first struggled with <a href="http://en.wikipedia.org/wiki/Lisp_%28programming_language%29">Lisp</a> and Scheme in university. I still don&#8217;t completely &#8220;get&#8221; functional programming! Wrapping my head around all those brackets in any derivative of Lisp felt like torture, but maybe that was just academia trying to punish me for my eventual release into a world of programming languages concieved AFTER 1979. Not that Iam in any position to be critical of such seminal ideas &#8211; which after all are at the root of the Groovy Closure I know and love. I do &#8220;get&#8221; Closures, fortunately.</p>
<p> <img src='http://www.kellyrob99.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>In the last few years I&#8217;ve been exposed to a huge variety of different tools and frameworks, and have followed the transition of <a class="zem_slink" href="http://java.sun.com" title="Java (software platform)" rel="homepage">Java</a> from 1.4 to 1.6(and beyond!) Past time to take a look at just what has changed, and perhaps why it doesn&#8217;t matter so much.</p>
<p></p>
<h1>Build tools and dependency management &#8211; <a class="zem_slink" href="http://ant.apache.org/">Ant</a>, <a class="zem_slink" href="http://maven.apache.org" title="Apache Maven" rel="homepage">Maven</a>, <a class="zem_slink" href="http://ant.apache.org/ivy/">Ivy</a>, <a class="zem_slink" href="http://groovy.codehaus.org/Grape">Grape</a></h1>
<p>I started off in my programming career with lots of&nbsp; build.xml files and eventually made the (at times rough) transition from there to pom.xml. The best part of this: never having to hand-code a classpath again. Worth it right there. Maven adds enough dependency management magic to the build process to make it a nice alternative, and when you factor in the great IDE support available(I&#8217;m looking at you <a class="zem_slink" href="http://www.jetbrains.com/idea/" title="IntelliJ IDEA" rel="homepage">IntelliJ</a>) it&#8217;s almost a no brainer. When you need to switch from one project to another, as has been pretty common in my career at least, being able to open a project at first sight and have your IDE correctly load up and run out of the box is a big plus.</p>
<p>Of late I&#8217;ve been getting more experience with Grape and Ivy. These dependency management tools bring some really elegant simplicity to the table, especially Grape; good-bye to complicated command line &#8220;java -cp &#8230;&#8221; calls when all you want to do is run a little snippet locally and import a jar. Now of course, this journey takes us all the way back to ant, since it is such a close(and apparently integral) part of Ivy. Which is all right in my book &#8211; ant has really stepped up to the challenge in recent history, in no small part due to the community. The Groovy AntBuilder and Gant enable many of the iterative style features so hard to express in xml mostly trivial, greatly simplifying usage of the powerful ant capabilities and making them easier to bring to bear. Now of course, the ability to run both Groovy and ant from with Maven kind of make it a moot point &#8211; if you really want to make your life easy, it pays to get to know all of these technologies and fit them into your build in the most effective way possible.</p>
<p></p>
<h1>Dependency Injection &#8211; <a class="zem_slink" href="http://www.springsource.org/">Spring</a>, Maven, <a href="http://www.seamframework.org">Seam</a>, <a href="http://code.google.com/p/google-guice/">Guice</a></h1>
<p>First time I saw dependency injection in action was with Spring. The IOC principle has since then become central to how I look at software. I mean, if you want to unit test effectively, it&#8217;s pretty much compulsory. And it encourages you away from &#8216;bad&#8217; design patterns &#8211; static method only classes, shared instantiated utility classes, lack of interface abstraction, etc.</p>
<p>Maven and the <a class="zem_slink" href="http://plexus.codehaus.org/">Plexus</a> container makes writing Maven plugins a breeze. Baking functionality into a maven build is really pretty trivial and I have had a lot of success with GMaven plugins for applying static analysis to a build: verifying that all properties in a resource bundle are actually referenced in a web application for instance. It&#8217;s an added bonus that you can easily test your plugin for Maven&#8230; with Maven.</p>
<p>The Seam framework also provides a very nice IOC container and it has been a real pleasure to leverage that power in a real-world application. It certainly facillitates testing &#8211; my preferred stack is TestNG with Unitils to add easy annotation support. It&#8217;s the simple things like @TestedObject to clearly specify intent and @InjectInto to mock out dependencies that make testing outside of the container as painless as possible. Not only does it ease testing, it encourages good modularization of functionality.</p>
<p>Guice is comparatively the new kid on the block, and the dependency injection framework I have the least experience with, but again the idea is sound, and having another implementation that can take advantage of history is a good thing. Webbeans aims to take the paradigm to the next level, and it will be interesting to see how that implementation evolves. Anyway you want to cut it, the picture is pretty clear &#8211; don&#8217;t hardcode your dependencies &#8211; inject them!</p>
<p></p>
<h1>I am a&#8230; Functional Programmer?</h1>
<p>Somehow, since I started writing code &#8211; I started to get it! Closures now make sense to me, currying does not sound like a cooking technique and I realized that however you code certain fundamentals apply.</p>
<ul>
<li>write the code</li>
<li>test the hell out of the code</li>
<li>make sure the code gets USED, because this is the only way you&#8217;re going to find the bugs you didn&#8217;t think of in your tests(*see one line above). And no, you didn&#8217;t think of everything one line above.</li>
</ul>
<p>The real point here is don&#8217;t discriminate &#8211; use the right tools for the job and get the most out of them you can, whether it&#8217;s functional VS procedural, Ant VS Maven, etc ad infinitum. Each tool brings a slightly different skillset to the table and if you want to make your programming life easier, it does pay to know which to use when (and how much). Beyond that, taking the time to pry and prod at the tools you use challenges your assumptions and gives you a greater appreciation of just exactly what is &#8216;going on&#8217; when you hit the Big Green Go button on your build.<br />
Not to mention that all of the tools/frameworks I&#8217;ve described here have LOTS of daily users AND represent some of the most executed(and IMO best written) code out there in the Java+ community. As a developer, you can&#8217;t help but benefit from digging into such code.<br />
Whatever you do, don&#8217;t stay stuck in the past. It just doesn&#8217;t make a whole lot of sense when what you&#8217;re really after is to make your job as easy and painless as possible to do.</p>
<div class="zemanta-pixie"><a class="zemanta-pixie-a" href="http://reblog.zemanta.com/zemified/79a1ab53-0c8b-4d37-8a2e-dc7ae208bb0a/" title="Reblog this post [with Zemanta]"><img class="zemanta-pixie-img" src="http://img.zemanta.com/reblog_c.png?x-id=79a1ab53-0c8b-4d37-8a2e-dc7ae208bb0a" alt="Reblog this post [with Zemanta]" /></a><span class="zem-script more-related pretty-attribution"><script type="text/javascript" src="http://static.zemanta.com/readside/loader.js" defer="defer"></script></span></div>
<!-- AdSense Now! V1.95 -->
<!-- Post[count: 2] -->
<div class="adsense adsense-leadout" style="float:right;margin: 12px;"><script type="text/javascript"><!--
google_ad_client = "pub-6955914197200080";
/* 728x90, created 8/3/09 */
google_ad_slot = "4051815125";
google_ad_width = 728;
google_ad_height = 90;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div><p>Related posts:<ol>
<li><a href='http://www.kellyrob99.com/blog/2009/04/14/groovy-and-bash-can-scripting-get-much-easier/' rel='bookmark' title='Groovy and Bash &#8211; can scripting get much easier?'>Groovy and Bash &#8211; can scripting get much easier?</a></li>
<li><a href='http://www.kellyrob99.com/blog/2009/04/19/groovy-and-glazed-lists-with-grape/' rel='bookmark' title='Groovy and Glazed Lists with Grape'>Groovy and Glazed Lists with Grape</a></li>
<li><a href='http://www.kellyrob99.com/blog/2009/08/14/griffon-support-in-latest-intellij-eap/' rel='bookmark' title='Griffon support in latest Intellij EAP'>Griffon support in latest Intellij EAP</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.kellyrob99.com/blog/2009/07/22/i-am-a-procedural-programmer/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Groovy and Bash &#8211; can scripting get much easier?</title>
		<link>http://www.kellyrob99.com/blog/2009/04/14/groovy-and-bash-can-scripting-get-much-easier/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=groovy-and-bash-can-scripting-get-much-easier</link>
		<comments>http://www.kellyrob99.com/blog/2009/04/14/groovy-and-bash-can-scripting-get-much-easier/#comments</comments>
		<pubDate>Wed, 15 Apr 2009 03:25:02 +0000</pubDate>
		<dc:creator>TheKaptain</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Apache Camel]]></category>
		<category><![CDATA[Bash]]></category>
		<category><![CDATA[dependency management]]></category>
		<category><![CDATA[Groovy]]></category>
		<category><![CDATA[Hibernate]]></category>
		<category><![CDATA[Ivy]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[maven]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Scripting language]]></category>

		<guid isPermaLink="false">http://www.kellyrob99.com/blog/?p=292</guid>
		<description><![CDATA[The ability to execute pretty much any bash statement embedded in a Groovy script is great, don&#8217;t get me wrong, but with the advent of Grape &#8211; and provided that you&#8217;re an Ivy/Maven user &#8211; adding the abilities of just about any Java library to your scripting language is easy. So what does Groovy add [...]
Related posts:<ol>
<li><a href='http://www.kellyrob99.com/blog/2009/04/03/griffon-bash-completion/' rel='bookmark' title='Griffon bash completion&#8230;'>Griffon bash completion&#8230;</a></li>
<li><a href='http://www.kellyrob99.com/blog/2009/08/09/using-the-testng-dataprovider-with-groovy/' rel='bookmark' title='Using the TestNG DataProvider with Groovy'>Using the TestNG DataProvider with Groovy</a></li>
<li><a href='http://www.kellyrob99.com/blog/2010/04/17/groovy-and-hibernate-validator-for-dynamic-constraints/' rel='bookmark' title='Groovy and Hibernate Validator for Dynamic Constraints'>Groovy and Hibernate Validator for Dynamic Constraints</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>The ability to execute pretty much any bash statement embedded in a Groovy script is great, don&#8217;t get me wrong, but with the advent of <a href="http://groovy.codehaus.org/Grape">Grape</a> &#8211; and provided that you&#8217;re an <a href="http://ant.apache.org/ivy/">Ivy</a>/Maven user &#8211; adding the abilities of just about any Java library to your scripting language is easy.</p>
<p>So what does <a href="http://groovy.codehaus.org">Groovy</a> add to the mix to make it an attractive option on top of(or instead of) bash on its own? Dependency management, lean distribution and testability all jump to mind.</p>
<h3 style="text-align: center;">Dependency Management</h3>
<p>Grape gives you the same stability that Maven provides. Any script can load any Java library is wants to utilize into the classpath at runtime using your existing repository or an available internet connection.</p>
<h3 style="text-align: center;">Lean Distribution</h3>
<p>Because Grape utilizes a central repository, all dependencies are shared across the entire system. Scripts with extremely small footprints can do some pretty big things. Recently I&#8217;ve seen examples of <a href="http://www.infoq.com/articles/groovy-1-6">parsing html using TagSoup</a>(I swear I originally saw that example somewhere else but for the life of me can&#8217;t find it now), <a href="http://mrhaki.blogspot.com/2009/04/poll-for-e-mail-with-groovy-and-apache.html">Apache Camel integration</a>(<a href="http://java.dzone.com/news/groovy-example-activemq-broker?mz=7893-progress">and again</a>) and even spawning a local HSQL database, <a href="http://groovy.codehaus.org/Using+Hibernate+with+Groovy">complete with Hibernate</a>. Within a very sparse number of lines, you can do more than you could ever imagine with plain Java, and I&#8217;m more than willing to admit that I wouldn&#8217;t know where to start with bash to do any of the stuff I just mentioned.</p>
<h3 style="text-align: center;">Testability</h3>
<p>The only thing that separates a stand-alone Groovy script from a Groovy class on the command line is the #!. If you&#8217;re willing to launch the script on the command line explicitly using the &#8216;groovy&#8217; executable you can abandon that. So now the difference becomes &#8216;./groovyScript&#8217; versus &#8216;groovy groovyScript&#8217;. But&#8230;. that same script is now ripe and ready to be included in the test framework you use everyday for regular project development. You can easily compose it into unit-testable methods and treat it like any other part of a large and rapidly evolving software project &#8211; things that I&#8217;ve always found inherently difficult with a command line script. Mostly I find that the truly useful scripts and snippets &#8211; the ones that are used regularly by developers on a day to day basis &#8211; are the ones that also never end up under source control, and don&#8217;t get the benefit of evolutionary change that most code gets.</p>
<p>Building upon the example included in the <a href="http://www.infoq.com/articles/groovy-1-6">InfoQ Groovy 1.6 launch notice</a>, here&#8217;s the quick and dirty addition of a JXTable component for showing the results of parsing all links from an html page with TagSoup. A text field is used to bind the url and a click of the button starts it off.  It&#8217;s not pretty, but it did take less than 10 minutes to do so judge for yourself. Run this script from the command line using the groovy command (V1.6+).</p>
<pre class="brush: groovy; smart-tabs: true; title: ; notranslate">
import org.jdesktop.swingx.JXTable
import javax.swing.*

@Grab(group='org.swinglabs', module='swingx', version='0.9.3')
@Grab(group='org.ccil.cowan.tagsoup', module='tagsoup', version='0.9.7')
def getHtml(url) {
       def parser = new XmlParser(new org.ccil.cowan.tagsoup.Parser())
       parser.parse(url)
}
def data = [ ]

def my = groovy.swing.SwingBuilder.build {
       frame = frame(title:'Groovy Grab Test', size:[800,500], show:true, pack:true, defaultCloseOperation: WindowConstants.DISPOSE_ON_CLOSE) {
       actions(){
             action(name:'Fetch', id:'fetchAction')
             {
                   data.clear
                   getHtml(urlField.text).body.'**'.a.@href.each{ data &lt;&lt; [url:it] }
                   frame.repaint()
             }
       }
       boxLayout(axis: BoxLayout.Y_AXIS)
       scrollPane() {
             myTable = table(new JXTable(columnControlVisible:true)){
                   tableModel(list:data){
                   propertyColumn(header: 'URL', propertyName: 'url')
             }
       }
 }
       textField(id:'urlField')
       button(fetchAction)
 }
}
</pre>
<p>Since I work for an organization that uses maven extensively for dependency management, most of the libraries that come to mind as handy bash replacements are already available in my local repository. Apache commons, Google collections, and most importantly &#8211; any libraries that are specifically dealing with your own products &#8211; all are at your fingertips! Even better, since most of the tasks that commonly fall to scripting are pretty low level (moving files around, etc), there are easy alternatives.</p>
<p>AntBuilder, for instance, is baked into Groovy, and provides a great abstraction around most of the desired functionality you want in a scripting environment. Moving files, doing text replacement,tarring files, sending mail &#8211; anything that Apache Ant can do, AntBuilder can do. But without all of that infuriating and frustating xml. An example(complete with exception handling!) courtesy of <a href="http://thediscoblog.com/">Andrew Glover</a>, <a href="http://www.ibm.com/developerworks/library/j-pg12144.html">in this article</a>.</p>
<pre class="brush: groovy; title: ; notranslate">
ant = new AntBuilder()
ant.mkdir(dir:&quot;/dev/projects/ighr/binaries/&quot;)

try{
       ant.javac(srcdir:&quot;/dev/projects/ighr/src&quot;,
       destdir:&quot;/dev/projects/ighr/binaries/&quot; )

}catch(Throwable thr){
       ant.mail(mailhost:&quot;mail.anywhere.com&quot;, subject:&quot;build failure&quot;){
             from(address:&quot;buildmaster@anywhere.com&quot;, name:&quot;buildmaster&quot;)
             to(address:&quot;dev-team@anywhere.com&quot;, name:&quot;Development Team&quot;)
             message(&quot;Unable to compile ighr's source.&quot;)
       }
}
</pre>
<p>Where you REALLY need it, you of course are still able to call on any and all of the *nix powertools you might like in a Groovy script. Personally, more and more I find that building and testing the script in my chosen IDE, and using the libraries I&#8217;m most comfortable with to do it, is a much more productive and enjoyable experience.</p>
<p>P.S. Gotta apologize about the code formatting &#8211; if anyone knows a wordpress syntax highlighting plugin that DOESN&#8217;T blow away your formatting or randomly replace the text with html entities, gimme a shout please!</p>
<p>Related posts:<ol>
<li><a href='http://www.kellyrob99.com/blog/2009/04/03/griffon-bash-completion/' rel='bookmark' title='Griffon bash completion&#8230;'>Griffon bash completion&#8230;</a></li>
<li><a href='http://www.kellyrob99.com/blog/2009/08/09/using-the-testng-dataprovider-with-groovy/' rel='bookmark' title='Using the TestNG DataProvider with Groovy'>Using the TestNG DataProvider with Groovy</a></li>
<li><a href='http://www.kellyrob99.com/blog/2010/04/17/groovy-and-hibernate-validator-for-dynamic-constraints/' rel='bookmark' title='Groovy and Hibernate Validator for Dynamic Constraints'>Groovy and Hibernate Validator for Dynamic Constraints</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.kellyrob99.com/blog/2009/04/14/groovy-and-bash-can-scripting-get-much-easier/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

