<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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:series="http://unfoldingneurons.com/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>itmusings</title>
	
	<link>http://itmusings.com</link>
	<description>a ramble alongside code, design, architecture and software development</description>
	<lastBuildDate>Fri, 04 Nov 2011 17:39:09 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/RajasRambles" /><feedburner:info uri="rajasrambles" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>Stevey Can Rant.. I Cant</title>
		<link>http://feedproxy.google.com/~r/RajasRambles/~3/VLgyJuRwNOM/stevey-can-rant-i-cant</link>
		<comments>http://itmusings.com/management/stevey-can-rant-i-cant#comments</comments>
		<pubDate>Tue, 01 Nov 2011 13:08:39 +0000</pubDate>
		<dc:creator>raja shankar kolluru</dc:creator>
				<category><![CDATA[Featured]]></category>
		<category><![CDATA[management]]></category>
		<category><![CDATA[technology]]></category>

		<guid isPermaLink="false">http://itmusings.com/?p=806</guid>
		<description><![CDATA[Stevey&#8217;s Rant has been making the blogging rounds recently. Everyone and their aged and ailing mothers are talking about it including yours truly of course &#8211; not my mom though &#8211; with this post.  I like the rant of course along with the multitude. Who can resist reading contemptuous digs on Jeff Bezos or for [...]


No related posts.]]></description>
			<content:encoded><![CDATA[<p><a title="Stevey's Rant in Google +" href="https://plus.google.com/112678702228711889851/posts/eVeouesvaVX">Stevey&#8217;s Rant</a> has been making the blogging rounds recently. Everyone and their aged and ailing mothers are talking about it including yours truly of course &#8211; not my mom though &#8211; with this post.  I like the rant of course along with the multitude. Who can resist reading contemptuous digs on Jeff Bezos or for that matter on Google or Microsoft? Not me.. Like most wanna be billionaires who has to be content with the measly dole that gets meted out to enterprise architects, I have always looked askance at these &#8220;rags to riches&#8221; guys with their perceived pomposity and apparent disdain for the people who work for them. At least it makes me feel good to contemplate possible nicks in their spiritual armor. Honestly,  I personally know too little about them to take a stand one way or the other. But isn&#8217;t it remarkable that most technical heads of companies have been accused of the same thing i.e. they just cant seem to let go of the finer details. I guess that is the problem. It seems techies can&#8217;t delegate well. And when you have strong opinions backed by an insatiable penchant to count the pixels it is harder.</p>
<p>One thing that particularly jived well with me is that it is pretty funny despite the fact that it is liberally sprayed with technical insights.  One would have thought that technology is almost an antipathy to anything in the nature of humor. But this rant proves one wrong.</p>
<p>Another reflection is that it is pretty &#8220;forthright&#8221; &#8211; if I can be excused for using an understatement. Many a time I get tempted to take a scalpel in hand and tear down the management of one or the other of the companies that I worked for but could never muster the courage nor the bank balance to make up for such an outright assault. So all in all it gives me some amount of sadistic pleasure to see another passionate guy giving vent and in the process possibly taking another step towards his &#8220;google&#8221;ian grave if that is the word I want.</p>
<p>Which brings me to another comment that I am seeing a lot about this rant. People were profuse in their praise for Google for condescending to leave the post on in Google+. But I maintain that it would seem incredibly bad form to remove it just because someone did not resound with the views of the powers that be. The lone voice of discord may well take your company out of the trouble that sometimes you are prone to get into as you flex your muscles and start to grow.</p>
<p>All in all I would heartily recommend a read.</p>
<p>&nbsp;</p>
<p>&nbsp;</p>


<p>No related posts.</p><img src="http://feeds.feedburner.com/~r/RajasRambles/~4/VLgyJuRwNOM" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://itmusings.com/management/stevey-can-rant-i-cant/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://itmusings.com/management/stevey-can-rant-i-cant</feedburner:origLink></item>
		<item>
		<title>Ecommerce &amp; Java</title>
		<link>http://feedproxy.google.com/~r/RajasRambles/~3/7IzB2cOuCXo/ecommerce-java</link>
		<comments>http://itmusings.com/java/ecommerce-java#comments</comments>
		<pubDate>Wed, 24 Aug 2011 19:29:30 +0000</pubDate>
		<dc:creator>raja shankar kolluru</dc:creator>
				<category><![CDATA[Featured]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[atg]]></category>
		<category><![CDATA[e-commerce]]></category>
		<category><![CDATA[ecommerce]]></category>
		<category><![CDATA[hybris]]></category>
		<category><![CDATA[websphere commerce server]]></category>

		<guid isPermaLink="false">http://itmusings.com/?p=767</guid>
		<description><![CDATA[I recently spoke at a Java conference in Bangalore where we discussed Java and E-commerce. This is becoming important with the advent of major e-commerce re-platforming efforts in some significantly large organizations. I am enclosing the deck that I had used in the meeting here. Ecommerce &#038; Java Take a look! Related posts:IOC, AOP &#8211; [...]


Related posts:<ol><li><a href='http://itmusings.com/architecture/ioc-aop-101' rel='bookmark' title='IOC, AOP &#8211; 101'>IOC, AOP &#8211; 101</a></li>
<li><a href='http://itmusings.com/java/java-performance' rel='bookmark' title='Java &amp; Performance'>Java &#038; Performance</a></li>
<li><a href='http://itmusings.com/java/multi-column-sorting-in-java' rel='bookmark' title='Multi Column Sorting in Java'>Multi Column Sorting in Java</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>I recently spoke at a Java conference in Bangalore where we discussed Java and E-commerce. This is becoming important with the advent of major e-commerce re-platforming efforts in some significantly large organizations.</p>
<p>I am enclosing the deck that I had used in the meeting here.<br />
<a href='http://itmusings.com/wp-content/uploads/2011/08/Ecommerce-Java.pdf'>Ecommerce &#038; Java</a></p>
<p>Take a look! </p>


<p>Related posts:<ol><li><a href='http://itmusings.com/architecture/ioc-aop-101' rel='bookmark' title='IOC, AOP &#8211; 101'>IOC, AOP &#8211; 101</a></li>
<li><a href='http://itmusings.com/java/java-performance' rel='bookmark' title='Java &amp; Performance'>Java &#038; Performance</a></li>
<li><a href='http://itmusings.com/java/multi-column-sorting-in-java' rel='bookmark' title='Multi Column Sorting in Java'>Multi Column Sorting in Java</a></li>
</ol></p><img src="http://feeds.feedburner.com/~r/RajasRambles/~4/7IzB2cOuCXo" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://itmusings.com/java/ecommerce-java/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://itmusings.com/java/ecommerce-java</feedburner:origLink></item>
		<item>
		<title>On Digesting XML</title>
		<link>http://feedproxy.google.com/~r/RajasRambles/~3/itBKoMs8SfA/on-digesting-xml</link>
		<comments>http://itmusings.com/java/on-digesting-xml#comments</comments>
		<pubDate>Tue, 26 Jul 2011 02:37:13 +0000</pubDate>
		<dc:creator>raja shankar kolluru</dc:creator>
				<category><![CDATA[code snippets]]></category>
		<category><![CDATA[Featured]]></category>
		<category><![CDATA[java]]></category>

		<guid isPermaLink="false">http://itmusings.com/?p=714</guid>
		<description><![CDATA[One of the earliest uses of XML was for the purpose of storing configuration. It was soon realized that XML constructs are more amenable for specifying nested configurations rather than properties or INI files that were hitherto used for the same purpose. Since I am a confessed frame-workaholic (a term I just coined to denote [...]


No related posts.]]></description>
			<content:encoded><![CDATA[<p>One of the earliest uses of XML was for the purpose of storing configuration. It was soon realized that XML constructs are more amenable for specifying nested configurations rather than properties or INI files that were hitherto used for the same purpose. Since I am a confessed frame-workaholic (a term I just coined to denote a person who has a penchant for writing frameworks at the drop of a hat) , I have always been using XML forever to specify configuration for my frameworks.</p>
<p><a href="http://itmusings.com/wp-content/uploads/2011/07/stomach.jpg"><img class="alignleft size-full wp-image-777" title="stomach" src="http://itmusings.com/wp-content/uploads/2011/07/stomach.jpg" alt="" width="229" height="220" /></a></p>
<p>But how do I go thru this morass of XML configuration and make sense of it? We need a parser that is flexible and lends itself to this kind of thing. That is when I discovered the commons digester.</p>
<p><span id="more-714"></span><a title="Goto Commons Digester in a separate page" href="http://commons.apache.org/digester/" target="_blank">Apache Commons digester</a> is an offshoot of the earliest Struts project. It was chiefly used to parse the struts.xml file at that time but was found to be more generic and hence a new project was created within the apache realm to publish the framework in its own right.</p>
<p>The first thing that strikes us as we navigate the framework is the fact that it uses a stack. Coming to think of it, an xml itself is a perfect example of a LIFO construction &#8211; the last tag inserted is the first one that is closed followed by the tag that precedes it and so on. Hence it is most amenable to be stored as a stack structure. This small but brilliant observation motivated the creation of a framework that replicates the stack to store various configuration elements. I typically use a value object which I call a descriptor to store various configurations from the XML. Let us illustrate this with an example:</p>
<p>Consider the following XML from the <a href="http://itmusings.com/stm">state transition machine (STM)</a> :</p>
<div class="dean_ch" style="white-space: wrap;">
<ol>
<li class="li1">
<div class="de1"><span class="sc3"><span class="re1">&lt;?xml</span> <span class="re0">version</span>=<span class="st0">&quot;1.0&quot;</span> <span class="re0">encoding</span>=<span class="st0">&quot;UTF-8&quot;</span><span class="re2">?&gt;</span></span></div>
</li>
<li class="li1">
<div class="de1"><span class="sc3"><span class="re1">&lt;flows<span class="re2">&gt;</span></span></span></div>
</li>
<li class="li1">
<div class="de1"><span class="sc3"><span class="re1">&lt;flow</span> <span class="re0">id</span>=<span class="st0">&#8216;orderApproval&#8217;</span> <span class="re0">defaultFlow</span>=<span class="st0">&#8216;true&#8217;</span><span class="re2">&gt;</span></span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li2">
<div class="de2"><span class="sc3"><span class="re1">&lt;state</span> <span class="re0">id</span>=<span class="st0">&#8216;pendingApproval&#8217;</span><span class="re2">&gt;</span></span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp;<span class="sc3"><span class="re1">&lt;on</span> <span class="re0">eventId</span>=<span class="st0">&#8216;approved&#8217;</span> <span class="re0">newStateId</span>=<span class="st0">&#8216;fulfilled&#8217;</span><span class="re2">/&gt;</span></span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp;<span class="sc3"><span class="re1">&lt;on</span> <span class="re0">eventId</span>=<span class="st0">&#8216;rejected&#8217;</span><span class="re0">newStateId</span>=<span class="st0">&#8216;discarded&#8217;</span><span class="re2">/&gt;</span></span></div>
</li>
<li class="li1">
<div class="de1"><span class="sc3"><span class="re1">&lt;/state<span class="re2">&gt;</span></span></span></div>
</li>
<li class="li1">
<div class="de1"><span class="sc3"><span class="re1">&lt;/flow<span class="re2">&gt;</span></span></span></div>
</li>
<li class="li2">
<div class="de2"><span class="sc3"><span class="re1">&lt;/flows<span class="re2">&gt;</span></span></span></div>
</li>
</ol>
</div>
<p>Without going too much into the detail of the framework itself, the objective is to parse this xml and  keep information about each flow. We can quickly invent a &#8220;FlowDescriptor&#8221;, &#8220;StateDescriptor&#8221; and TransitionDescriptor  value objects  that contains information from various levels of granularity. Here are the quick Java definitions.</p>
<div class="dean_ch" style="white-space: wrap;">
<ol>
<li class="li1">
<div class="de1"><span class="coMULTI">/**</span></div>
</li>
<li class="li1">
<div class="de1"><span class="coMULTI">Stores information from the &quot;on&quot; tag</span></div>
</li>
<li class="li1">
<div class="de1"><span class="coMULTI">*/</span></div>
</li>
<li class="li1">
<div class="de1"><span class="kw2">public</span> <span class="kw2">class</span> TransitionDescriptor <span class="br0">&#123;</span>  </div>
</li>
<li class="li2">
<div class="de2"><span class="kw2">private</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AString+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span class="kw3">String</span></a> eventId;  </div>
</li>
<li class="li1">
<div class="de1"><span class="kw2">private</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AString+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span class="kw3">String</span></a> newStateId;</div>
</li>
<li class="li1">
<div class="de1"><span class="co1">// getters and setters</span></div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="coMULTI">/**</span></div>
</li>
<li class="li2">
<div class="de2"><span class="coMULTI">Stores information about states</span></div>
</li>
<li class="li1">
<div class="de1"><span class="coMULTI">*/</span></div>
</li>
<li class="li1">
<div class="de1"><span class="kw2">public</span> <span class="kw2">class</span> StateDescriptor<span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">   <span class="kw2">private</span> List&lt;TransitionDescriptor&gt; transitions = <span class="kw2">new</span> ArrayList&lt;TransitionDescriptor&gt;<span class="br0">&#40;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">   <span class="kw2">public</span> <span class="kw4">void</span> addTransition<span class="br0">&#40;</span>TransitionDescriptor td<span class="br0">&#41;</span> <span class="br0">&#123;</span></div>
</li>
<li class="li2">
<div class="de2">       transitions.<span class="me1">add</span><span class="br0">&#40;</span>td<span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#125;</span><span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="coMULTI">/*</span></div>
</li>
<li class="li1">
<div class="de1"><span class="coMULTI">&nbsp;Stores information about one flow.</span></div>
</li>
<li class="li1">
<div class="de1"><span class="coMULTI">*/</span></div>
</li>
<li class="li2">
<div class="de2"><span class="kw2">public</span> <span class="kw2">class</span> FlowDescriptor <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;<span class="kw2">private</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AString+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span class="kw3">String</span></a> id;</div>
</li>
<li class="li1">
<div class="de1">&nbsp;<span class="kw2">private</span> <span class="kw4">boolean</span> defaultFlow = <span class="kw2">false</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp;<span class="co1">// getters and setters.</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;<span class="kw2">private</span> List&lt;StateDescriptor&gt; states = <span class="kw2">new</span> ArrayList&lt;StateDescriptor&gt;<span class="br0">&#40;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li2">
<div class="de2">&nbsp;<span class="kw2">public</span> <span class="kw4">void</span> addState<span class="br0">&#40;</span>StateDescriptor sd<span class="br0">&#41;</span><span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">   states.<span class="me1">add</span><span class="br0">&#40;</span>sd<span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#125;</span> </div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="coMULTI">/**</span></div>
</li>
<li class="li2">
<div class="de2"><span class="coMULTI">Acts as a container for flow objects</span></div>
</li>
<li class="li1">
<div class="de1"><span class="coMULTI">*/</span></div>
</li>
<li class="li1">
<div class="de1"><span class="kw2">public</span> <span class="kw2">class</span> FlowsContainer <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="kw2">private</span> List&lt;FlowDescriptor&gt; flows = <span class="kw2">new</span> ArrayList&lt;FlowDescriptor&gt;<span class="br0">&#40;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw2">public</span> <span class="kw4">void</span> addFlow<span class="br0">&#40;</span>FlowDescriptor fd<span class="br0">&#41;</span> <span class="br0">&#123;</span></div>
</li>
<li class="li2">
<div class="de2">flows.<span class="me1">add</span><span class="br0">&#40;</span>fd<span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#125;</span><span class="br0">&#125;</span></div>
</li>
</ol>
</div>
<h1 lang="java">Parsing the XML</h1>
<p>The XML above can be parsed through the digester by passing a stream that contains this XML through the digester. But before that we need to ensure that the digester is set up correctly.</p>
<p>The whole idea is to set up the digester stack and add elements to it as we navigate thru the XML so that the correct value objects are created and added. Let us talk about the plan in detail.</p>
<p>The plan is to first add a FlowsContainer object to the top of the stack before we even begin to parse the XML. Then as we encounter individual flow tags we should create new FlowDescriptor objects and add them to the FlowContainer object. Then we need to do the same for the StateDescriptor and TransitionDescriptor objects. Here is a snippet of code that accomplishes this:</p>
<div class="dean_ch" style="white-space: wrap;">
<ol>
<li class="li1">
<div class="de1"><span class="coMULTI">/*</span></div>
</li>
<li class="li1">
<div class="de1"><span class="coMULTI">Sets up the digester. Make sure that you import Commons digester.</span></div>
</li>
<li class="li1">
<div class="de1"><span class="coMULTI">*/</span></div>
</li>
<li class="li1">
<div class="de1">Digester digester = <span class="kw2">new</span> Digester<span class="br0">&#40;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li2">
<div class="de2"><span class="co1">// push the flows container in the stack.</span></div>
</li>
<li class="li1">
<div class="de1">FlowsContainer flowsContainer = <span class="kw2">new</span> FlowsContainer<span class="br0">&#40;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">digester.<span class="me1">push</span><span class="br0">&#40;</span>flowsContainer<span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1"><span class="co1">// add rule to create a flow descriptor as and when a flow element is encountered in the XML.</span></div>
</li>
<li class="li1">
<div class="de1">digester.<span class="me1">addObjectCreate</span><span class="br0">&#40;</span><span class="st0">&quot;flows/flow&quot;</span>, FlowDescriptor.<span class="kw2">class</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li2">
<div class="de2"><span class="co1">//the above snippet of code uses the &quot;built in&quot; object creation rule to create a FlowDescriptor object</span></div>
</li>
<li class="li1">
<div class="de1"><span class="co1">// as and when a flow tag is encountered. The newly created flow descriptor instance is inserted also</span></div>
</li>
<li class="li1">
<div class="de1"><span class="co1">// by this rule into the stack. The stack contains FlowContainer-&gt;FlowDescriptor (for the current flow tag)</span></div>
</li>
<li class="li1">
<div class="de1"><span class="co1">// at this point in time.</span></div>
</li>
<li class="li1">
<div class="de1"><span class="co1">// Now we need to populate the defaultFlow and id attributes of the FlowDescriptor object</span></div>
</li>
<li class="li2">
<div class="de2">digester.<span class="me1">addSetProperties</span><span class="br0">&#40;</span><span class="st0">&quot;flows/flow&quot;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1"><span class="co1">// the Set Properties rule populates the properties of the last object in the stack (the flow descriptor object</span></div>
</li>
<li class="li1">
<div class="de1"><span class="co1">// in this case) with the attributes of the flow tag. Type conversions are made from string to boolean in case</span></div>
</li>
<li class="li1">
<div class="de1"><span class="co1">// of the defaultFlow attribute.</span></div>
</li>
<li class="li1">
<div class="de1"><span class="co1">// proceed along the same lines for the state descriptor object and the transition descriptor objects</span></div>
</li>
<li class="li2">
<div class="de2">digester.<span class="me1">addObjectCreate</span><span class="br0">&#40;</span><span class="st0">&quot;flows/flow/state&quot;</span>, StateDescriptor.<span class="kw2">class</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">digester.<span class="me1">addSetProperties</span><span class="br0">&#40;</span><span class="st0">&quot;flows/flow/state&quot;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">digester.<span class="me1">addObjectCreate</span><span class="br0">&#40;</span><span class="st0">&quot;flows/flow/state/on&quot;</span>, TransitionDescriptor.<span class="kw2">class</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">digester.<span class="me1">addSetProperties</span><span class="br0">&#40;</span><span class="st0">&quot;flows/flow/state/on&quot;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1"><span class="co1">// As we approach the on tag the stack contains objects as follows: (from bottom to top)</span></div>
</li>
<li class="li2">
<div class="de2"><span class="co1">// FlowsContainer-&gt;FlowDescriptor-&gt;StateDescriptor-&gt;TransitionDescriptor</span></div>
</li>
<li class="li1">
<div class="de1"><span class="co1">// all the properties of the descriptors would have been populated from the corresponding attributes in the</span></div>
</li>
<li class="li1">
<div class="de1"><span class="co1">// corresponding XML tags</span></div>
</li>
<li class="li1">
<div class="de1"><span class="co1">// Now we need to unwind the stack as the XML unwinds and put the objects back into the object</span></div>
</li>
<li class="li1">
<div class="de1">digester.<span class="me1">addSetNext</span><span class="br0">&#40;</span><span class="st0">&quot;flows/flow/state/on&quot;</span>,<span class="st0">&quot;addTransition&quot;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li2">
<div class="de2"><span class="co1">// the SetNext rule takes the first element of the stack and puts it into the second element.</span></div>
</li>
<li class="li1">
<div class="de1"><span class="co1">// In this case it takes the TransitionDescriptor object and calls the addTransition method of the</span></div>
</li>
<li class="li1">
<div class="de1"><span class="co1">// second element (in this case the StateDescriptor)</span></div>
</li>
<li class="li1">
<div class="de1">digester.<span class="me1">addSetNext</span><span class="br0">&#40;</span><span class="st0">&quot;flows/flow/state&quot;</span>,<span class="st0">&quot;addState&quot;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">digester.<span class="me1">addSetNext</span><span class="br0">&#40;</span><span class="st0">&quot;flows/flow&quot;</span>,<span class="st0">&quot;addFlow&quot;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li2">
<div class="de2"><span class="co1">// similar stuff above.</span></div>
</li>
</ol>
</div>
<p>As we see, the built in rules of the digester make XML parsing trivial. The stack based parsing and processing makes the entire process trivial and keeps it encapsulated well.</p>
<h1>Digester Extensions</h1>
<p>It is possible to add our own rules to the digester to achieve very specific behavior. We just need to extend the Rule base class.</p>


<p>No related posts.</p><img src="http://feeds.feedburner.com/~r/RajasRambles/~4/itBKoMs8SfA" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://itmusings.com/java/on-digesting-xml/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://itmusings.com/java/on-digesting-xml</feedburner:origLink></item>
		<item>
		<title>EDA and Incremental ETL</title>
		<link>http://feedproxy.google.com/~r/RajasRambles/~3/TR8j9MznvQM/eda-and-incremental-etl</link>
		<comments>http://itmusings.com/architecture/eda-and-incremental-etl#comments</comments>
		<pubDate>Sun, 17 Jul 2011 18:00:47 +0000</pubDate>
		<dc:creator>raja shankar kolluru</dc:creator>
				<category><![CDATA[architecture]]></category>
		<category><![CDATA[design]]></category>
		<category><![CDATA[Featured]]></category>

		<guid isPermaLink="false">http://itmusings.com/?p=612</guid>
		<description><![CDATA[Event Driven Architecture (EDA) is a paradigm that I became familiar with when I was coding the earliest GUI components. The user interaction with a GUI application is modeled as a series of events that the application responds to.  There is an &#8220;infinite loop&#8221; of events which can potentially be engendered by user interactions with [...]


Related posts:<ol><li><a href='http://itmusings.com/architecture/the-n1-selects-problem' rel='bookmark' title='The n+1 selects problem..'>The n+1 selects problem..</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Event Driven Architecture (EDA) is a paradigm that I became familiar with when I was coding the earliest GUI components. The user interaction with a GUI application is modeled as a series of events that the application responds to.  There is an &#8220;infinite loop&#8221; of events which can potentially be engendered by user interactions with a graphical application. The user responds to an application by potentially typing on the keyboard, clicking on certain segments of a GUI (such as a button for instance) with his mouse, hovering over certain regions etc. Individual GUI components respond to these events as they deem fit and perform various actions.  Each c0mponent took charge of maintaining its own events and was able to invoke common services in response to them.</p>
<p><span id="more-612"></span></p>
<p>A Segue &#8211; Enterprise Architecture &amp; Systems of Records</p>
<p>Let us consider a different problem. Let us think about an enterprise with a large number of applications.</p>
<p>As the enterprise started fanning out to envelope multiple enterprise applications, it becomes imperative to reckon with a large number of different databases of information often called as systems of records.</p>
<p>For instance, let us take the example of a large enterprise that has thousands of employees.</p>
<p>There would be an employee system of record that stores details about the employees. There would be multiple applications that the enterprise might have to use to discharge its day to day activities. These applications might all require access to the employee database for both validation and other purposes. Ex: The accounting application might want to add an employee as an &#8220;owner&#8221; to each account.</p>
<h1>SOA &amp; The Enterprise</h1>
<p>How do these applications access employee information? One option is to use SOA and hide the employees data behind a service. The Employee Service is responsible for maintaining employees and facilitating updates to the central Employee System of Record. This approach is great but can have a few drawbacks:</p>
<ul>
<li>If there is a batch process (such as a scheduled job) that iterates over multiple records in the database and for each record needs to obtain employee information, then this might suffer from the (n+1) selects problem that is mentioned elsewhere in this blog.</li>
<li>It is hard to enforce reference integrity constraints between an entity in a local database and an employee since the employee information is only available via SOA. Ex: How do we ensure that all accounts owners are valid employees?</li>
</ul>
<div>These limitations force architects to lead to a &#8220;replicated data&#8221; mechanism to complement the SOA strategy.</div>
<h1>Replicated Data &amp; ETL</h1>
<div>The chief limitation of Replicated data is the potential for it to get out of synch with the system of record.  The system of record always trumps over replicated data elsewhere. Hence all changes need to be made to the System of Record first and percolated from there. If there is a change in the employee data, then the Employee System of Record needs to have the new data. The replicated data elsewhere would get the requisite feeds from the System of Record.</div>
<div>Extract, Transform and Load  (ETL) process is used to ensure that the replicated data is periodically percolated from the System of record to the replicated system.  The ETL process can be pretty elaborate and might extract modified data selectively (as opposed to extracting the entire data)  for merging into the replicated systems. The latency might become prohibitive for certain enterprises. It is possible that replicated data might stay out of synch for a long time thereby engendering other data integrity issues.  Hence it makes sense to expedite the ETL process and make it as light weight as possible.</div>
<div>This gives raise to the Real time Incremental ETL strategy. ETL is used to percolate the changes as they occur in the real time thereby making the latency involved minimal. Event Driven Architecture (EDA) provides a great scalable solution for accomplishing this real time incremental ETL.</div>
<h1>EDA &amp; Real time Incremental ETL</h1>
<div>Event Driven Architecture strategies publish &#8220;events&#8221; when significant things happen in the enterprise. There might be a distinct Event to signify the fact that a user has modified his profile for instance. These events are published using some mechanism and are &#8220;listened&#8221; to by interested observers. These observers use these events to accomplish various things.</div>
<div>So as and when data changes in any system of record, it is possible to trigger a new event. This event is processed by observers who percolate these changes to other systems that replicated the data. Hence the ETL is accomplished during real time as and when the event of interest happens.</div>
<div>With the advent of the pub-sub (publish &#8211; subscribe) paradigm in various technologies such as JMS, it is possible to use these technologies to do incremental ETL. For ex: there might be a JMS &#8220;topic&#8221; that might receive the UserProfileChanged event. This would be subscribed to by a prospective subscriber which uses the information to update its own replicated database.</div>


<p>Related posts:<ol><li><a href='http://itmusings.com/architecture/the-n1-selects-problem' rel='bookmark' title='The n+1 selects problem..'>The n+1 selects problem..</a></li>
</ol></p><img src="http://feeds.feedburner.com/~r/RajasRambles/~4/TR8j9MznvQM" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://itmusings.com/architecture/eda-and-incremental-etl/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://itmusings.com/architecture/eda-and-incremental-etl</feedburner:origLink></item>
		<item>
		<title>On Project Ramp ups</title>
		<link>http://feedproxy.google.com/~r/RajasRambles/~3/XJsc6xPi7nc/on-project-ramp-ups</link>
		<comments>http://itmusings.com/management/on-project-ramp-ups#comments</comments>
		<pubDate>Tue, 12 Jul 2011 04:59:18 +0000</pubDate>
		<dc:creator>raja shankar kolluru</dc:creator>
				<category><![CDATA[architecture]]></category>
		<category><![CDATA[Featured]]></category>
		<category><![CDATA[management]]></category>
		<category><![CDATA[process]]></category>

		<guid isPermaLink="false">http://itmusings.com/?p=762</guid>
		<description><![CDATA[As I think back about all the failed projects that I had seen, I recognize one unifying feature about them. They all took too long to ramp up! I am not saying that they did not spend enough time on design or architecture. On the other hand, many of these failed projects spent an inordinate [...]


Related posts:<ol><li><a href='http://itmusings.com/management/process/project-automation' rel='bookmark' title='Project Automation'>Project Automation</a></li>
<li><a href='http://itmusings.com/management/process/bug-driven-development' rel='bookmark' title='Bug Driven Development'>Bug Driven Development</a></li>
<li><a href='http://itmusings.com/management/process/sepg' rel='bookmark' title='SEPG'>SEPG</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>As I think back about all the failed projects that I had seen, I recognize one unifying feature about them. They all took too long to ramp up! I am not saying that they did not spend enough time on design or architecture. On the other hand, many of these failed projects spent an inordinate time weighing on alternatives, designing, documenting, estimating the effort and the like. But they failed to recognize one little truth. All the effort expended here is fruitless without code! It is just, as one of my colleagues puts it, &#8220;intellectual masturbation&#8221; at this point in time.</p>
<p>Code, like good wine, takes time to mature. The earlier you write the code, the more opportunity it gets to evolve. The same arguments apply for a development team. A development team has no sense of belonging to the project in the absence of code. They sit nonplussed by the surfeit of documentation that surrounds them. Give them an IDE, a proper module structure and some code to write and voila! watch the difference.They start getting involved in the project.</p>
<p>As human beings, I think, we need the ability to mentally slot things. We cannot work with intimidating wholes. We need to break them down into their constituent parts. That is only possible if we are given the slots to put the parts into. A module structure gives the developers just that ability. It tells them that the problem at hand needs to be broken down into smaller consumable units which can then be pigeon holed into individual modules. As the modules have been set up in the IDE, the developers are able to translate the requirements into stuff that they can relate to.</p>
<p>This makes all the difference to a project. As the developers and their code start &#8220;soaking in&#8221; , the project gets more mature. In a month or so, the developers become adept at the code and the environment. The code starts becoming more stable as it starts getting exposed to more testing very early. The inception stage in a project is a tension free time. ( as indicated in the diagram below) . Hence extra effort expended at this point is sustainable. As the release deadline approaches, the tension starts to mount. But if the team has been ramped up adequately, the stability of the code reinforces confidence to the team about the feasibility of meeting the project release deadline. </p>
<p>IMO, the diagram below represents a good recipe for a project. The initial &#8220;tension free zone&#8221; needs to be utilized to ramp up both the team and the source code. The source code must have been modularized and set up in individual developers&#8217; IDE by the time the actual coding phase begins. By that time, the team should have got ramped up and must be performing at its optimal effort level as indicated by the purple portion of the diagram. There would be a spurt in effort required as the current release approaches culmination. However, that effort spurt is minimal and is not even close to the spurt that was originally expended during ramp up.  We all know that tension and high effort levels lead to quick project fatigue resulting in considerable productivity loss.  Hence it is imperative that we ensure that the team is comfortable as we approach the release date. </p>
<p>Also, observe that even the spurts do not take the effort level anywhere close to the saturation point. </p>
<p><a href="http://itmusings.com/wp-content/uploads/2011/07/project-effort1.png"><img class="alignleft size-full wp-image-764" title="project effort" src="http://itmusings.com/wp-content/uploads/2011/07/project-effort1.png" alt="" width="690" height="436" /></a></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>It is important that we ensure sustainability for the team by keeping their effort as much possible at the optimal level. Sub optimal level effort is wastage of resources. Spurts over the optimal effort level are necessary but cannot be protracted over a long period of time.</p>
<p>All failed projects were characterized by super demands on effort level during the period preceding the project release. This lead to a considerable loss of productivity and increased the risk of attrition.</p>
<p>In my projects, I tend to encourage a &#8220;war room&#8221; kind of atmosphere during inception so that the team quickly gets off the mark! </p>


<p>Related posts:<ol><li><a href='http://itmusings.com/management/process/project-automation' rel='bookmark' title='Project Automation'>Project Automation</a></li>
<li><a href='http://itmusings.com/management/process/bug-driven-development' rel='bookmark' title='Bug Driven Development'>Bug Driven Development</a></li>
<li><a href='http://itmusings.com/management/process/sepg' rel='bookmark' title='SEPG'>SEPG</a></li>
</ol></p><img src="http://feeds.feedburner.com/~r/RajasRambles/~4/XJsc6xPi7nc" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://itmusings.com/management/on-project-ramp-ups/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://itmusings.com/management/on-project-ramp-ups</feedburner:origLink></item>
		<item>
		<title>On Estimation &amp; Agility</title>
		<link>http://feedproxy.google.com/~r/RajasRambles/~3/8j6oyKg-vvc/on-estimation-agility</link>
		<comments>http://itmusings.com/management/on-estimation-agility#comments</comments>
		<pubDate>Mon, 04 Jul 2011 07:39:50 +0000</pubDate>
		<dc:creator>raja shankar kolluru</dc:creator>
				<category><![CDATA[architecture]]></category>
		<category><![CDATA[Featured]]></category>
		<category><![CDATA[management]]></category>
		<category><![CDATA[process]]></category>

		<guid isPermaLink="false">http://itmusings.com/?p=757</guid>
		<description><![CDATA[I was doing an estimation review recently. At first blush, I am instinctively uncomfortable about anything that requires a high degree of predictability in software development since that is going to be violated if you are ever intending to produce software that could be deemed useful by the ultimate consumers! It is exactly like doing the interiors of [...]


Related posts:<ol><li><a href='http://itmusings.com/management/process/sepg' rel='bookmark' title='SEPG'>SEPG</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>I was doing an estimation review recently.</p>
<p>At first blush, I am instinctively uncomfortable about anything that requires a high degree of predictability in software development since that is going to be violated if you are ever intending to produce software that could be deemed useful by the ultimate consumers!</p>
<p>It is exactly like doing the interiors of a house which is an activity that I was partaking of recently. I was engaging some interiors contractors to do the work. Their estimation and invoice depended on a simplification. They merely told me that it would cost me a certain amount based on the fact that I am finishing a wall that is &#8220;y&#8221; sq.ft in area. The cost of one sq.ft is x. Hence the total cost is x*y of course exclusive of applicable taxes, surcharges and all the rest of the appurtenances and caveats you would find in an estimate. Now it is possible that I might decide to finish the whole wall or just a small fraction of it. But the estimate (and in this case the ultimate invoice as well) does not change. At the end of the day I felt that the dice was loaded against me since I had to pay for the whole wall irrespective of what parts of it, I decide to furnish.</p>
<p>But I realized that this is the only way an estimate ever works even in software development. I decide on the unit cost based on previous experience. I just estimate the &#8220;approximate sq feet&#8221; I need to build and multiply it by the unit cost to arrive at the total cost. However, if I were to take a more agile approach, I would exactly pay for the amount of materials I use, the labour charges etc. which would be more accurate. It might or might not work out cheaper. But at least, I know that I get what I paid for and that no one gets &#8220;shafted&#8221; in the process. Both the parties get a fair deal.</p>
<p>The trouble with software is that there is no raw material to build on. Sure you need application servers, package solutions, products to enhance,languages, operating systems etc. But these are not raw material for the software. These are more like edifices on which the software development rests.  So it is all labour charges so to speak. Hence estimation (and ultimately the cost) tends to be time based and the cost is determined by the total time and the unit cost per time for the &#8220;labourers&#8221;. In short, the numberof people is directly proportional to the cost of the project. This simplification is essential for estimation but is at variance with experience. I don&#8217;t get the exact same kind of people. They don&#8217;t cost the same.  More importantly, the quality of the artifacts that they produce is not the same.</p>
<p>On the one hand you are comfortable with the certitude that comes with knowing what is the exact cost upfront.  On the other hand, you want the flexibility of a dynamic solution that is geared towards changing business needs. It is hard to reconcile these two inherently conflicting forces.  Hence, all estimates are approximate at best.  At worst,they lead to law suits, high attrition and all kinds of unpleasant things bordering on eternal perdition.</p>
<p>This harks back to a comment by Robert Martin in his great treatise titled &#8220;<a title="Link to the book in amazon" href="http://www.amazon.com/Software-Development-Principles-Patterns-Practices/dp/0135974445">Agile Software Development &#8211; Principles, Patterns and Practices&#8221;</a> which is a book I heartily recommend. You can find a quick and unhelpful review of mine in the Amazon web site <a href="http://www.amazon.com/review/R37SYCKQ91FCOK/ref=cm_cr_rdp_perm">here</a>.</p>
<p>Robert Martin says that people are not &#8220;plug compatible programming units&#8221;. Most estimation processes assume that people are exactly that. They assume that people can be shoved into a software building assembly line and over a period of time &#8211; the software comes out the other side! Hence, IMO, the estimation process is at loggerheads with agility.</p>
<p>That is why most great softwares are not produced by SOWs. Software development needs trust. It needs a certain relationshipto be built over time among the participants. It requires passion. Most importantly, it requires excitement from the individuals which can only be obtained if they perceive career growth. Treating them insouciantly as &#8220;plug and play resources&#8221; devalues them and makes them feel sub-optimally used.</p>
<p>It is not for nothing that Alistair Cockburn opined that:</p>
<blockquote><p>Process and technology are a second order effect on the outcome of a project. The first order effect is the people.</p>
</blockquote>


<p>Related posts:<ol><li><a href='http://itmusings.com/management/process/sepg' rel='bookmark' title='SEPG'>SEPG</a></li>
</ol></p><img src="http://feeds.feedburner.com/~r/RajasRambles/~4/8j6oyKg-vvc" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://itmusings.com/management/on-estimation-agility/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://itmusings.com/management/on-estimation-agility</feedburner:origLink></item>
		<item>
		<title>On IoC containers &amp; Stateful components</title>
		<link>http://feedproxy.google.com/~r/RajasRambles/~3/XpoReFUSGuM/stateful-components-in-ioc</link>
		<comments>http://itmusings.com/architecture/stateful-components-in-ioc#comments</comments>
		<pubDate>Wed, 16 Mar 2011 02:32:46 +0000</pubDate>
		<dc:creator>raja shankar kolluru</dc:creator>
				<category><![CDATA[architecture]]></category>
		<category><![CDATA[Featured]]></category>
		<category><![CDATA[optimization]]></category>

		<guid isPermaLink="false">http://itmusings.com/?p=700</guid>
		<description><![CDATA[If we elevate ourselves enough to sit on a figurative perch in the programming world and look down at the applications that are being developed, we realize that Inversion of Control (IoC) containers have most definitely come here to stay. You see more people than ever before proclaiming expertise in programming  &#8221;Java with Springs&#8221; &#8211; [...]


Related posts:<ol><li><a href='http://itmusings.com/architecture/kpi-key-performance-indicators' rel='bookmark' title='KPI &#8211; Key Performance Indicators'>KPI &#8211; Key Performance Indicators</a></li>
<li><a href='http://itmusings.com/architecture/identity-crisis' rel='bookmark' title='Identity Crisis'>Identity Crisis</a></li>
<li><a href='http://itmusings.com/architecture/lod' rel='bookmark' title='The Law Of Demeter'>The Law Of Demeter</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>If we elevate ourselves enough to sit on a figurative perch in the programming world and look down at the applications that are being developed, we realize that Inversion of Control (IoC) containers have most definitely come here to stay. You see more people than ever before proclaiming expertise in programming  &#8221;Java with Springs&#8221; &#8211; alluding no doubt to the Spring lightweight container that has now become the de-facto choice to develop most modern J2EE applications.   Now it is easier than ever to create components as &#8220;Stateless Singletons&#8221; and injecting other stateless singletons into them. The whole dependency tree gets materialized during start up. Given this background, I was somewhat surprised and  fascinated by two independent problems that were recently brought to my attention.</p>
<p><span id="more-700"></span></p>
<p>The problems involved different IoC containers &#8211; one of them being Spring and the other being ATG Nucleus. Both stated the same thing namely that the application is taking too long to look up components from the IoC containers. Ex: In Spring, the <a title="java doc" href="http://static.springsource.org/spring/docs/2.5.6/api/org/springframework/beans/factory/BeanFactory.html#getBean(java.lang.String)" target="_blank">SpringBeanFactory.getBean(String name) call</a> was taking too long. Now, if you were an application doctor who got commissioned to solve this case, your natural temptation is to prescribe the following:</p>
<blockquote><p>Thou shalt not useth an IoC container to look up components. Use it instead to inject one component into the other during start up.</p></blockquote>
<p>But before you scribble these words of profound wisdom  with an illegible hand, as doctors are wont to do, you would do well to take a small pause and consider the situation more holistically.  Why is a component forced to &#8220;look up&#8221; other components from an IoC container? In other words, what are the situations that would warrant one component being forced to look up another component? Components need to look up other components if they cannot benefit from injection. The only reason that such a thing happens is if the two components are in different scopes. In the case of a Spring application, one component might be a singleton whilst its dependency maybe a &#8220;prototype&#8221;. Hence the singleton component has to &#8220;look up&#8221; the  prototype component. It can do so either by either using BeanFactoryAware interfaces or method injection. (Please see <a title="Spring Bean Scope description" href="http://static.springsource.org/spring/docs/2.5.x/reference/beans.html#beans-factory-method-injection" target="_blank">here</a> for a detailed description for both these artifices in Spring)</p>
<p>But the point I am making is to figure out &#8220;why&#8221; we need to have components in different scopes. In general, I would look askance at any attempt to use a component as a non singleton.  My reasoning is as follows: If you use a component as a non singleton, then it implies that you are storing some kind of state in that component.  This state may be instance specific , request specific, session specific etc. This means that the component is no more stateless. This design violates my <a href="http://itmusings.com/design/class-dichotomy">favorite class dichotomy doctrine as advocated here.</a> So why do we need to store state in a component?  I think that the following use cases warrant them:</p>
<ul>
<li>We may be using a framework that requires stateful components. Ex: All actions in Struts 2 are considered stateful since the framework injects request specific parameters (stuff that got submitted by the user) into the component.</li>
<li>We maybe using value objects to store components. Consider a situation where a value object contains a method that invokes a strategy to act on it. Ex: We may have an XmlRenderer component that renders other objects to XML. A value object may have a render() method that invokes this renderer to render itself to XML.</li>
</ul>
<p>In the above situations, the class in question acts as both a carrier of state as well as something that accomplishes some work. This kind of mixup of responsibilities leads to a situation where a more ephemeral object (ex: the value object or the struts 2 action) needs to look up a singleton component that is naturally contained in an IoC container. A ton of post processors (using the Spring parlance) come into play in this lookup which can lead to a substantial slowness of this call.</p>
<p>Note that in the above discussion, we did not discuss another candidate use case that requires a component lookup from an IoC container. This happens in writing frameworks. Let us say that we write a framework that requires a component to be created by the client of the framework. (such as for instance an MVC framework such as Struts) This component might require us to look up actions that are best created by  an IoC container. In this case, we need to look up the component when the request to be serviced by the component arrives. (in Struts case, the request hits a URL that is mapped to a struts action). At that point in time, we can either look up the component from the IoC container or instead use a cached reference to the object that was created during application start up. The latter approach is preferred since it does not incur the penalty of the look up with each request.</p>
<p>These kind of problems are best avoided by the judicious separation of data containers from the strategies in an application. I am well aware that this may tilt the design excessively towards an anemic domain model <a title="a link to martin fowler's critique on anemic domain model" href="http://martinfowler.com/bliki/AnemicDomainModel.html">which is frowned upon by the purists of object design</a>. My point is that the term Anemic Data Model has itself been coined with prejudice. You can always have strategies that leverage inheritance rather than becoming <a title="a link to fowler's article on transaction scripts" href="http://martinfowler.com/eaaCatalog/transactionScript.html">transaction scripts.</a></p>
<p>Just my point of view!</p>


<p>Related posts:<ol><li><a href='http://itmusings.com/architecture/kpi-key-performance-indicators' rel='bookmark' title='KPI &#8211; Key Performance Indicators'>KPI &#8211; Key Performance Indicators</a></li>
<li><a href='http://itmusings.com/architecture/identity-crisis' rel='bookmark' title='Identity Crisis'>Identity Crisis</a></li>
<li><a href='http://itmusings.com/architecture/lod' rel='bookmark' title='The Law Of Demeter'>The Law Of Demeter</a></li>
</ol></p><img src="http://feeds.feedburner.com/~r/RajasRambles/~4/XpoReFUSGuM" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://itmusings.com/architecture/stateful-components-in-ioc/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<series:name><![CDATA[optimization]]></series:name>
	<feedburner:origLink>http://itmusings.com/architecture/stateful-components-in-ioc</feedburner:origLink></item>
		<item>
		<title>State Transition Machine</title>
		<link>http://feedproxy.google.com/~r/RajasRambles/~3/X5ZYj3Djzjg/st</link>
		<comments>http://itmusings.com/architecture/st#comments</comments>
		<pubDate>Thu, 03 Mar 2011 03:28:04 +0000</pubDate>
		<dc:creator>raja shankar kolluru</dc:creator>
				<category><![CDATA[architecture]]></category>
		<category><![CDATA[Featured]]></category>
		<category><![CDATA[java]]></category>

		<guid isPermaLink="false">http://itmusings.com/?p=728</guid>
		<description><![CDATA[I know I haven&#8217;t been posting too much and that has been breaking a few hearts. So to heal the breach and reward the faithful for waiting this long, I have published a new open source framework called STM which is a representation of the State Transition Machine. Please check it out in the following [...]


Related posts:<ol><li><a href='http://itmusings.com/java/j2ee/value-object-wizard-vow' rel='bookmark' title='Value Object Wizard (VOW)'>Value Object Wizard (VOW)</a></li>
<li><a href='http://itmusings.com/management/process/project-automation' rel='bookmark' title='Project Automation'>Project Automation</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p><a href="http://itmusings.com/wp-content/uploads/2011/03/STM-logo.png"><img class="alignleft size-full wp-image-746" title="STM-logo" src="http://itmusings.com/wp-content/uploads/2011/03/STM-logo.png" alt="" width="150" height="75" /></a></p>
<p>I know I haven&#8217;t been posting too much and that has been breaking a few hearts. So to heal the breach and reward the faithful for waiting this long, I have published a new open source framework called STM which is a representation of the State Transition Machine. Please check it out in the following pages and let me know what you think.</p>
<p>1. <a href="http://itmusings.com/fstm">Maven web site</a></p>
<p>2. <a href="http://itmusings.com/stm">Main page that describes the project. </a></p>
<p>3.<a href="https://sourceforge.net/projects/fstm/develop"> Sourceforge site</a> (contains SVN code, jars etc )</p>
<p>&nbsp;</p>


<p>Related posts:<ol><li><a href='http://itmusings.com/java/j2ee/value-object-wizard-vow' rel='bookmark' title='Value Object Wizard (VOW)'>Value Object Wizard (VOW)</a></li>
<li><a href='http://itmusings.com/management/process/project-automation' rel='bookmark' title='Project Automation'>Project Automation</a></li>
</ol></p><img src="http://feeds.feedburner.com/~r/RajasRambles/~4/X5ZYj3Djzjg" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://itmusings.com/architecture/st/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://itmusings.com/architecture/st</feedburner:origLink></item>
		<item>
		<title>Calculating percentiles in MYSQL</title>
		<link>http://feedproxy.google.com/~r/RajasRambles/~3/0wFAbXMYo9M/calculating-percentiles-in-mysql</link>
		<comments>http://itmusings.com/featured/calculating-percentiles-in-mysql#comments</comments>
		<pubDate>Sun, 10 Oct 2010 03:53:31 +0000</pubDate>
		<dc:creator>raja shankar kolluru</dc:creator>
				<category><![CDATA[code snippets]]></category>
		<category><![CDATA[Featured]]></category>

		<guid isPermaLink="false">http://itmusings.com/?p=710</guid>
		<description><![CDATA[I was doing some interesting analysis on percentiles. In the process, I had to put some results in MYSQL and use it for calculating them. I am somewhat fanatical about the usage of select statements without recourse to stored procedures for doing anything in the database. So I was hunting for a &#8220;pure select&#8221; way [...]


Related posts:<ol><li><a href='http://itmusings.com/management/process/bug-trends-and-self-joins' rel='bookmark' title='Bug Trends and some interesting SQL stuff'>Bug Trends and some interesting SQL stuff</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>I was doing some interesting analysis on percentiles. In the process, I had to put some results in MYSQL and use it for calculating them. I am somewhat fanatical about the usage of select statements without recourse to stored procedures for doing anything in the database. So I was hunting for a &#8220;pure select&#8221; way of accomplishing this.  It turns out that MYSQL does support stored procedure variables without mandating the use of the &#8220;create procedure&#8221; directive. This, to me, represented the best of both worlds. I wanted to avoid the admittedly dubious pain (that springs out of my personal prejudices about writing an SP) of writing a stored procedure and instead accomplish the objective with a plain vanilla select.  So off I went in that direction and this blog post is the result.</p>
<p><span id="more-710"></span></p>
<p>Let us say we have a table called rank1 that stores two columns &#8211; an Id and a value. The ID is non-unique in that an ID can have multiple values. I want to compute the average and the 90th percentile of the values for each ID. Example: Consider the following data:</p>
<table border="1" cellpadding="15">
<tbody>
<tr>
<th>ID</th>
<th>Value</th>
</tr>
<tr>
<td>1</td>
<td>1</td>
</tr>
<tr>
<td>1</td>
<td>2</td>
</tr>
<tr>
<td>1</td>
<td>3</td>
</tr>
<tr>
<td>1</td>
<td>4</td>
</tr>
<tr>
<td>1</td>
<td>5</td>
</tr>
<tr>
<td>1</td>
<td>6</td>
</tr>
<tr>
<td>1</td>
<td>7</td>
</tr>
<tr>
<td>1</td>
<td>8</td>
</tr>
<tr>
<td>1</td>
<td>9</td>
</tr>
<tr>
<td>1</td>
<td>10</td>
</tr>
<tr>
<td>2</td>
<td>5</td>
</tr>
<tr>
<td>2</td>
<td>10</td>
</tr>
<tr>
<td>2</td>
<td>15</td>
</tr>
<tr>
<td>2</td>
<td>20</td>
</tr>
<tr>
<td>2</td>
<td>25</td>
</tr>
<tr>
<td>2</td>
<td>30</td>
</tr>
<tr>
<td>2</td>
<td>35</td>
</tr>
<tr>
<td>2</td>
<td>40</td>
</tr>
<tr>
<td>2</td>
<td>45</td>
</tr>
<tr>
<td>2</td>
<td>50</td>
</tr>
</tbody>
</table>
<p>What I want is the following:</p>
<table border="1" cellpadding="15">
<tbody>
<tr>
<th>ID</th>
<th>90th percentile</th>
<th>Average</th>
<th>Count</th>
</tr>
<tr>
<td>1</td>
<td>9</td>
<td>5.5</td>
<td>10</td>
</tr>
<tr>
<td>2</td>
<td>45</td>
<td>27.5</td>
<td>10</td>
</tr>
</tbody>
</table>
<p>Here is a sql that accomplishes this:</p>
<div class="dean_ch" style="white-space: wrap;">
<ol>
<li class="li1">
<div class="de1"><span class="kw1">SELECT</span></div>
</li>
<li class="li1">
<div class="de1">id,</div>
</li>
<li class="li1">
<div class="de1">value <span class="kw1">AS</span> percentile,</div>
</li>
<li class="li1">
<div class="de1">count_col,average <span class="kw1">FROM</span> <span class="br0">&#40;</span></div>
</li>
<li class="li2">
<div class="de2"><span class="kw1">SELECT</span> @row := <span class="kw1">IF</span><span class="br0">&#40;</span>@id = rank2.id, @row + <span class="nu0">1</span>, <span class="nu0">1</span><span class="br0">&#41;</span> <span class="kw1">AS</span> row,rank2.ID id ,rank2.VALUE value ,COUNT_TABLE.COUNT_COL, percentile_rownum, average</div>
</li>
<li class="li1">
<div class="de1">, @id := rank2.id <span class="kw1">AS</span> dummy <span class="kw1">FROM</span> RANK1 <span class="kw1">AS</span> RANK2,</div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#40;</span><span class="kw1">SELECT</span> COUNT<span class="br0">&#40;</span>*<span class="br0">&#41;</span> COUNT_COL, rank1.id, round<span class="br0">&#40;</span><span class="nu0">0.90</span>*count<span class="br0">&#40;</span>*<span class="br0">&#41;</span><span class="br0">&#41;</span> percentile_rownum, avg<span class="br0">&#40;</span>rank1.value<span class="br0">&#41;</span> <span class="kw1">AS</span> average <span class="kw1">FROM</span> RANK1 <span class="kw1">GROUP</span> <span class="kw1">BY</span> RANK1.ID<span class="br0">&#41;</span> <span class="kw1">AS</span> COUNT_TABLE</div>
</li>
<li class="li1">
<div class="de1"><span class="kw1">WHERE</span></div>
</li>
<li class="li1">
<div class="de1">count_table.id = rank2.id</div>
</li>
<li class="li2">
<div class="de2"><span class="kw1">ORDER</span> <span class="kw1">BY</span> rank2.id, VALUE</div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#41;</span> <span class="kw1">AS</span></div>
</li>
<li class="li1">
<div class="de1">allrows <span class="kw1">WHERE</span></div>
</li>
<li class="li1">
<div class="de1">row = percentile_rownum</div>
</li>
</ol>
</div>
<p>The gist is as follows. We first compute the average, count and the number at which the percentile figure occurs in the inner most select.<br />
We use this information to join back all the Ids and values along with the grouped information in the intermediary select. This intermediate SQL also computes the rownumber IDs and groups them.<br />
The if clause in the @row computation works to group the row numbers by ID. The @id is required to achieve this since it is a variable that monitors the change in ID from 1 to 2.</p>
<p>The percentile is computed by finding the row number that corresponds to the number that was computed in the inner most select.<br />
Shoot me a question if you are having trouble following the logic.</p>


<p>Related posts:<ol><li><a href='http://itmusings.com/management/process/bug-trends-and-self-joins' rel='bookmark' title='Bug Trends and some interesting SQL stuff'>Bug Trends and some interesting SQL stuff</a></li>
</ol></p><img src="http://feeds.feedburner.com/~r/RajasRambles/~4/0wFAbXMYo9M" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://itmusings.com/featured/calculating-percentiles-in-mysql/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://itmusings.com/featured/calculating-percentiles-in-mysql</feedburner:origLink></item>
		<item>
		<title>IOC, AOP – 101</title>
		<link>http://feedproxy.google.com/~r/RajasRambles/~3/IZ0E6MFAHp8/ioc-aop-101</link>
		<comments>http://itmusings.com/architecture/ioc-aop-101#comments</comments>
		<pubDate>Fri, 27 Aug 2010 01:11:11 +0000</pubDate>
		<dc:creator>raja shankar kolluru</dc:creator>
				<category><![CDATA[architecture]]></category>
		<category><![CDATA[design]]></category>
		<category><![CDATA[Featured]]></category>

		<guid isPermaLink="false">http://itmusings.com/?p=695</guid>
		<description><![CDATA[I had given a keynote in a conference sometime ago, about the Spring framework. It constituted a presentation on the patterns that necessitated the creation of  Spring in the first place. I am attaching a slide deck on this. I would add some more material here as we go to elaborate on the content of [...]


Related posts:<ol><li><a href='http://itmusings.com/java/ecommerce-java' rel='bookmark' title='Ecommerce &amp; Java'>Ecommerce &#038; Java</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<div>
<p>I had given a keynote in a conference sometime ago, about the Spring framework. It constituted a presentation on the patterns that necessitated the creation of  Spring in the first place. I am attaching a slide deck on this. I would add some more material here as we go to elaborate on the content of the deck.</p>
<p>Here is the deck.<a href="http://itmusings.com/wp-content/uploads/2010/08/DIAOP.ppt">DIAOP</a></p>
<p> </p>
</div>


<p>Related posts:<ol><li><a href='http://itmusings.com/java/ecommerce-java' rel='bookmark' title='Ecommerce &amp; Java'>Ecommerce &#038; Java</a></li>
</ol></p><img src="http://feeds.feedburner.com/~r/RajasRambles/~4/IZ0E6MFAHp8" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://itmusings.com/architecture/ioc-aop-101/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://itmusings.com/architecture/ioc-aop-101</feedburner:origLink></item>
	</channel>
</rss><!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk: basic
Page Caching using disk: enhanced
Database Caching 20/120 queries in 0.144 seconds using disk: basic

Served from: itmusings.com @ 2012-02-23 03:44:26 -->

