<?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>Whirliwig's Weblog &#187; Java for Sceptics</title>
	<atom:link href="http://whirliwig.wordpress.com/category/java-for-sceptics/feed/" rel="self" type="application/rss+xml" />
	<link>http://whirliwig.wordpress.com</link>
	<description>Just another WordPress.com weblog</description>
	<lastBuildDate>Tue, 22 Sep 2009 22:49:06 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<cloud domain='whirliwig.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://www.gravatar.com/blavatar/6c2ef262bd209987d44f8c0cc268ebd0?s=96&#038;d=http://s.wordpress.com/i/buttonw-com.png</url>
		<title>Whirliwig's Weblog &#187; Java for Sceptics</title>
		<link>http://whirliwig.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://whirliwig.wordpress.com/osd.xml" title="Whirliwig&#8217;s Weblog" />
		<item>
		<title>Patterns Facilitated by Java: IOC</title>
		<link>http://whirliwig.wordpress.com/2008/05/10/patterns-facilitated-by-java-ioc/</link>
		<comments>http://whirliwig.wordpress.com/2008/05/10/patterns-facilitated-by-java-ioc/#comments</comments>
		<pubDate>Sat, 10 May 2008 19:03:45 +0000</pubDate>
		<dc:creator>whirliwig</dc:creator>
				<category><![CDATA[Java for Sceptics]]></category>

		<guid isPermaLink="false">http://whirliwig.wordpress.com/?p=27</guid>
		<description><![CDATA[Bin thinkin bout Inversion of Control:

BEFORE: &#8220;Containerless&#8221; &#8212; (not IOC), &#8220;Main&#8221; code kicked off, initialises objects, invokes first methods, off you go! Other objects create new objects, and create relationships between themselves&#8230;
Configuration is read by objects, and is &#8216;passive&#8217; (used-by).
AFTER: IOC: Configuration is used by &#8216;application environment&#8217; to &#8216;plumb&#8217; a system together, instantiating objects and [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=whirliwig.wordpress.com&blog=2864336&post=27&subd=whirliwig&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Bin thinkin bout Inversion of Control:</p>
<p><a href="http://www.flickr.com/photos/26453751@N02/2481240442" title="View 'InversionOfControl' on Flickr.com"><img src="http://farm3.static.flickr.com/2083/2481240442_ab7c871959.jpg" alt="InversionOfControl" border="0" width="500" height="265" /></a></p>
<p><strong>BEFORE</strong>: &#8220;Containerless&#8221; &#8212; (not IOC), &#8220;Main&#8221; code kicked off, initialises objects, invokes first methods, off you go! Other objects create new objects, and create relationships between themselves&#8230;</p>
<p>Configuration is read by objects, and is &#8216;passive&#8217; (used-by).</p>
<p><strong>AFTER</strong>: IOC: Configuration is used by &#8216;application environment&#8217; to &#8216;plumb&#8217; a system together, instantiating objects and creating dependencies between them, invoking methods as described in the configuration.</p>
<p>In a sense, Configuration is &#8216;active&#8217;, and drives the system.</p>
<p>Of course, a text file is not active itself, but the &#8216;container&#8217; or &#8216;application server&#8217; uses it.</p>
<p><em>The configuration is declarative, not procedural</em></p>
<p>That is, instead of everything starting by normal imperative programming instructions, creating objects, and invoking methods in sequence, a 4GL (e.g.written in an XML language) <i>describes what the system looks like</i> and <i>the dependencies between object creation, destruction and method invokation</i> the application server sets it up, and &#8216;works it&#8217; as described, ensuring all dependencies between components are resolved in the correct order.</p>
<p>Here&#8217;s an IOC:</p>
<ul>
<li>I want a system which has a KeyboardListener, a DisplayDriver, a GUI and a StartupAndShutdownController
<li>Start up the StartupAndShutdownController as soon as possible. Use &#8216;Start&#8217; method.
<li>Register KeyboardListener to be notified by StartupAndShutdownController when Startup has begun by invoking it&#8217;s &#8216;StartListening&#8217; event.
<li>Start up the DisplayDriver, and as soon as possible. Use &#8216;Start&#8217; method.
<li>Register GUI to be notified by DisplayDriver&#8217;s ReadyForUse event, and KeyboardListener&#8217;s KeyPressed events
<li>When GUI starts, &#8230;
</ul>
<p>Oh, for goodness sake, why didn&#8217;t I choose an easier example! Ahem. The rest is left as an exercise.</p>
<p>Note, however, that the description is a bullet-list, rather than a numbered list. The dependencies are described, and the order of clauses does not matter.</p>
<p>For an application server to go from configuration files/data to an instantiated set of objects, the application server needs to be able to create objects based on an external description, that the compiler does not know about at compile time, and may change without re-compilation (for example, depending on a class name stored in a text file)</p>
<p>Here is the point Java naturally overtakes C++: it is dynamic enough to act like an <i>interpreted</i> (as opposed to compiled) language when in needs to be, and has class loaders which can take a string at run-time, and create an instantiation of the relevant class name.</p>
<p>C++ Programmers can already see ways around this, but also know it may be tricky to make this ultimately flexible, and will sigh with jealousy at the ease of Java in this respect.</p>
<p><a href="http://code.google.com/p/pococapsule/">Help is at hand though</a>!</p>
<p>Why bother?</p>
<p>To add IOC to the systems-programming mix is an art.</p>
<p>It doesn&#8217;t solve anything in itself.</p>
<p>It is another spin on Component Based Development (CBD)&#8230; ever heard of vendors trying to flog graphical systems for assembling systems from &#8216;business components&#8217;, for use by business-people? Well, that will not happen for many reasons, some of them psychological, some of them practical (basically, it takes all kinds to make a world).</p>
<p>However, CBD can bring the technologists, ops-people and business-people to almost a common language, and can partition a solution implementation into bits the business want to know about, and bits they&#8217;d prefer not to know about&#8230;and that is at a much higher <i>declarative</i> level than a non-IOC world.</p>
<p>However, selecting which bits to &#8216;componentise&#8217;, and what configuration and methods to expose to an IOC world is an art, and requires business input.</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/whirliwig.wordpress.com/27/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/whirliwig.wordpress.com/27/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/whirliwig.wordpress.com/27/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/whirliwig.wordpress.com/27/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/whirliwig.wordpress.com/27/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/whirliwig.wordpress.com/27/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/whirliwig.wordpress.com/27/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/whirliwig.wordpress.com/27/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/whirliwig.wordpress.com/27/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/whirliwig.wordpress.com/27/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/whirliwig.wordpress.com/27/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/whirliwig.wordpress.com/27/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=whirliwig.wordpress.com&blog=2864336&post=27&subd=whirliwig&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://whirliwig.wordpress.com/2008/05/10/patterns-facilitated-by-java-ioc/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/5d264195e56020ade73069ec742f2a03?s=96&#38;d=identicon" medium="image">
			<media:title type="html">whirliwig</media:title>
		</media:content>

		<media:content url="http://farm3.static.flickr.com/2083/2481240442_ab7c871959.jpg" medium="image">
			<media:title type="html">InversionOfControl</media:title>
		</media:content>
	</item>
	</channel>
</rss>