<?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/" version="2.0">

<channel>
	<title>Anuj Varma</title>
	
	<link>http://www.anujvarma.com</link>
	<description>Web Log of a techie, globetrotter, uber geek</description>
	<lastBuildDate>Sat, 05 May 2012 23:41:53 +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/AnujVarmaWeb" /><feedburner:info xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" uri="anujvarmaweb" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>On the Ether</title>
		<link>http://www.anujvarma.com/on-the-ether/</link>
		<comments>http://www.anujvarma.com/on-the-ether/#comments</comments>
		<pubDate>Sat, 05 May 2012 23:41:53 +0000</pubDate>
		<dc:creator>Anuj Varma</dc:creator>
				<category><![CDATA[Special Theory of Relativity]]></category>
		<category><![CDATA[aether]]></category>
		<category><![CDATA[constant speed of light]]></category>
		<category><![CDATA[ether]]></category>
		<category><![CDATA[light is like bullets]]></category>
		<category><![CDATA[light is like sound]]></category>
		<category><![CDATA[speed of light]]></category>
		<category><![CDATA[speed of light does not add]]></category>

		<guid isPermaLink="false">http://www.anujvarma.com/on-the-ether/</guid>
		<description><![CDATA[One of the things I never fully grasped in college was the ‘Michelson Morley’ experiment. I understood what it was for (proving the constancy of the speed of light) – and understood that it proved that very well – but &#8230; <a href="http://www.anujvarma.com/on-the-ether/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>One of the things I never fully grasped in college was the ‘Michelson Morley’ experiment. I understood what it was for (proving the constancy of the speed of light) – and understood that it proved that very well – but I never understood the concept of the ether or the ‘ether wind’ or what that had to do with the speed of light. To explain the ‘constancy of’ the speed of light, two separate theories were proposed. One was the ‘sound analogy’ (or the ‘ether theory’). The second theory proposed that light’s speed, though constant, should add and subtract from the speed of the emitter of light. So – light speed measured from a moving flashlight should be different from a stationary flashlight. This was called the ‘emitter’ theory or the ‘bullets analogy’ (the speed of bullets relative to the ground would depend on whether the gun was moving or not).</p>
<p>These two books (The Geometry of ) and ‘Asimov on Physics’, helped shed light on the issue.</p>
<h3>The first conjecture – Light is like sound – the constancy of its speed is due to the ‘medium’ a.k.a – The Ether Theory</h3>
<p>Consider sound waves. When you fire a gun, the wave travels through the air at a certain speed. This speed is independent of what the gun is doing – if the gun were moving straight ahead – the sound wave would still travel at the same speed. This is because the wave is dependent on a <em>medium –&nbsp; </em>and the medium is what limits its speed.</p>
<p>Now – people already knew that the speed of light was a constant – and it did not depend on whether a flashlight was moving or not . So – based on the reasoning above, it seemed logical to assume that it was similar to a sound wave – that light too, required a <em>medium. </em>This was a logical assumption. The only problem was that the speed was so high that the medium would need to be very dense. At the same time, the medium could not interact with any matter (since light traveled without any problem through space devoid of matter). How do you construct a super-dense medium that does not interact with matter?</p>
<p>Michelson and Morley decided to put the existence of such a ‘medium’ to the test. The ether was assumed to be a completely stationary, non-moving object.</p>
<p>If the earth is moving through this stationary ether, then the earth should experience an ether ‘wind’ – the same way that a man sitting atop a train experiences a moving wind. If we now shine a flashlight in the direction of earth’s motion (against the wind), that light should take longer to reach its destination. Remember – it is the ETHER that is assumed to be ‘carrying’ the light wave. That is why – going against the ether should take longer. Similarly, going in the same direction should take less time. To paraphrase a quote in <a href="http://galileo.phys.virginia.edu/classes/109N/lectures/michelson.html">this detailed article:</a></p>
<blockquote><p>The whole point of bringing in the aether was to give a picture for light resembling the one we understand for sound, compressional waves in a medium. </p>
</blockquote>
<p>They devised an experiment measuring the time it took light to go ‘against’ the ether wind – and then ‘with’ the ether wind. They found that there was no difference in the times. This meant that there was no ‘ether wind’. So – light was NOT like sound – it’s constancy of speed did not have to do with any medium. </p>
<h3>The Second Theory – Light&nbsp; is like bullets – it’s speed should add/subtract from the source (the emitter theory)</h3>
<p>Even though it was understood in Einstein’s day that the speed of light DID NOT in fact, add or subtract from the speed of the source, this could not be measured accurately in the days when Michelson Morley did their experiment. Recently, however, light emitted from moving pions (moving close to the speed of light) was measured&nbsp; &#8211; and found to always move at the speed ‘c’. Thus, the moving source had no effect on the speed of light.</p>
<h3>The actual experiment</h3>
<p>This <a href="http://galileo.phys.virginia.edu/classes/109N/lectures/michelson.html">post</a> discusses the experiment with great clarity. The analogy of the two swimmers in a moving river helps understand the experiment better. Two swimmers decide to have a race. A river is flowing at a speed of 3 m/s. Both swimmers swim at the same speed – 5 m/s. Swimmer A will try and swim directly across the river – and come back to the same point (he will obviously have to aim at a higher point on the opposite bank to be able to return to his original starting point). Swimmer B – will simply swim upstream (along the same bank that they both start at) – and then downstream to return to the starting point.</p>
<p>Who finishes first? </p>
<p>Note: They both swim the same distance (the width of the river is 50 m – swimmer A obviously swims 100 m, swimmer B will swim upstream 50 m and back again to complete his 100m).</p>
<p>Swimmer A’s effective speed will be 4 m/s (sqrt of 5 squared – 3 squared). So – A completes 100 m in 25 minutes. B covers the first 50 m (upstream) at a speed of 2 m/s (5 –3) = 25 minutes. He covers the second 50&nbsp; m (downstream) at a speed of 8&nbsp; m/s – in 50/8 = 5.2 minutes. Overall, A finishes in 25 minutes, B in 30.2 minutes. A wins. </p>
<p>Similarly, if two beams of light were to ‘race’ – one going diagonally across the ether (river) – and the other upstream and back, the one going across should return first. This would prove that there is such a thing as an ‘ether’ that carries the light wave. </p>
<p>It turns out no matter how precisely this experiment is carried out, both the light beams return at the same time. This proves that the river is not flowing (there is no ether).</p>
<h3>Summary</h3>
<p>It was thought that light was like sound. This led to the construction of an ether. The ether was experimentally proved to be fiction. It was also thought that light should behave like bullets from a moving gun – it’s speed should depend on the motion of the source. This was also disproved. So – light doesn’t behave like ordinary matter (bullets), it doesn’t behave like well-known waves (sound). Yet – it’s speed was always a constant&nbsp; &#8211; regardless of the motion of the source. How was this possible? </p>
<p>Einstein postulated that light did not just travel in space – it traveled in something called space time. If you think of spacetime as your ‘ether’, you may be closer to the original conception of the ether.&nbsp; </p>
]]></content:encoded>
			<wfw:commentRss>http://www.anujvarma.com/on-the-ether/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>C#, .NET Exception Handling Best Practices</title>
		<link>http://www.anujvarma.com/c-net-exception-handling-best-practices/</link>
		<comments>http://www.anujvarma.com/c-net-exception-handling-best-practices/#comments</comments>
		<pubDate>Fri, 27 Apr 2012 21:00:00 +0000</pubDate>
		<dc:creator>Anuj Varma</dc:creator>
				<category><![CDATA[C# - the language]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[.net exceptions best practices]]></category>
		<category><![CDATA[c# exception handling]]></category>
		<category><![CDATA[custom exception class c#]]></category>
		<category><![CDATA[n-tier exception handling]]></category>

		<guid isPermaLink="false">http://www.anujvarma.com/?p=1278</guid>
		<description><![CDATA[The Problem Statement 
You have just started working on an existing codebase – an n-Tier project &#8211; and noticed that the Exception Handling framework wasn’t as well defined as you would expect. Some specific things that bother you include:

Lack of &#8230; <a href="http://www.anujvarma.com/c-net-exception-handling-best-practices/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<h3>The Problem Statement </h3>
<p>You have just started working on an existing codebase – an n-Tier project &#8211; and noticed that the Exception Handling framework wasn’t as well defined as you would expect. Some specific things that bother you include:</p>
<ol>
<li>Lack of a Custom Exception Class
<li>No clearly defined single layer (of the n-Tiers) which was designated to handle all exceptions. All the tiers seemed to be handling one or more exceptions.
<li>Anytime an exception needed to be re-thrown (e.g. SqlExceptions and SOAPExceptions), it was through ‘<em>throw ex’ – </em>instead of just <em>throw.</em></li>
</ol>
<h3>The Solution</h3>
<p>Each of the&nbsp; issues listed above are discussed in this post. A sample solution that defines a custom exception class – along with a simple client showing its usage – is included. This can be used as a starting point for any Custom Exception handling module inside a .NET project.</p>
<h3>Custom Exception Class</h3>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:d8227244-55e6-4d37-bab8-cf80b9031d69" class="wlWriterSmartContent">
<div style="border-bottom: #000080 1px solid; border-left: #000080 1px solid; font-family: 'Courier New', courier, monospace; color: #000; font-size: 10pt; border-top: #000080 1px solid; border-right: #000080 1px solid">
<div style="padding-bottom: 2px; padding-left: 5px; padding-right: 5px; font-family: verdana, tahoma, arial, sans-serif; background: #000080; color: #fff; font-weight: bold; padding-top: 2px">Code Snippet</div>
<div style="background: #ddd; max-height: 300px; overflow: auto">
<ol style="padding-bottom: 0px; margin: 0px 0px 0px 2em; padding-left: 5px; padding-right: 0px; background: #ffffff; padding-top: 0px">
<li><span style="color: #008000">// This is the main piece of your custom exception class &#8211; MyAppException(string message, Exception innerException)</span>
<li style="background: #f3f3f3"><span style="color: #0000ff">public</span> MyAppException(<span style="color: #0000ff">string</span> message, <span style="color: #2b91af">Exception</span> innerException) : <span style="color: #0000ff">base</span>(message, innerException)
<li>{
<li style="background: #f3f3f3">&nbsp;&nbsp;&nbsp; <span style="color: #0000ff">if</span> (innerException != <span style="color: #0000ff">null</span>)
<li>&nbsp;&nbsp;&nbsp; {
<li style="background: #f3f3f3">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; message += innerException.ToString();
<li>&nbsp;&nbsp;&nbsp; }
<li style="background: #f3f3f3">} </li>
</ol>
</div>
</div>
</div>
<h3>n-Tier app &#8211; Exception handling</h3>
<p>Q) Which tier (layer) should you catch the exception in?</p>
<p>A) Always the business tier. Let the Data Access Layer and any other layers (e.g. the persistence/entity layer) rethrow the exception upwards. Then &#8211; in the business layer, wrap the caught exception in your custom exception (e.g. MyAppException) using the method shown above&nbsp; (which appends all the inner exceptions to the&nbsp; MyAppException). </p>
<p>Q) How and where should one display the exception message?</p>
<p>A) Certain exceptions have no business being displayed to the end user. Simply log these in an exception log – and do not rethrow these exceptions. However, a good set of exceptions do need to be displayed to the end user. The exception that we previously caught in our business layer – simply needs to be rethrown with a user-friendly message. This is then is caught in the presentation layer (webforms or winforms) &#8211; and the friendly exception message is displayed.</p>
<h3>Throw versus ThrowEx</h3>
<p>Most exception handling code that you see will look the code below:</p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:a352ca38-21f3-447c-a439-79c648b3fd68" class="wlWriterSmartContent">
<div style="border-bottom: #000080 1px solid; border-left: #000080 1px solid; font-family: 'Courier New', courier, monospace; color: #000; font-size: 10pt; border-top: #000080 1px solid; border-right: #000080 1px solid">
<div style="padding-bottom: 2px; padding-left: 5px; padding-right: 5px; font-family: verdana, tahoma, arial, sans-serif; background: #000080; color: #fff; font-weight: bold; padding-top: 2px">Code Snippet</div>
<div style="background: #ddd; max-height: 300px; overflow: auto">
<ol style="padding-bottom: 0px; margin: 0px 0px 0px 2em; padding-left: 5px; padding-right: 0px; background: #ffffff; padding-top: 0px">
<li><span style="color: #0000ff">try</span>
<li style="background: #f3f3f3">&nbsp;&nbsp; {
<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: #008000">// do some operation that can fail</span>
<li style="background: #f3f3f3">&nbsp;&nbsp; }
<li>&nbsp;&nbsp; <span style="color: #0000ff">catch</span> (<span style="color: #2b91af">Exception</span> ex)
<li style="background: #f3f3f3">&nbsp;&nbsp; {
<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: #008000">// do some local cleanup</span>
<li style="background: #f3f3f3">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: #0000ff">throw</span> ex;
<li>&nbsp;&nbsp; } </li>
</ol>
</div>
</div>
</div>
<p>With the code above (throw ex), the stack trace is truncated – and only offers information starting from the method that failed. The origin of the exception will always appear to be in application code. However, as we all know, this isn’t always true. Exceptions can originate in various external systems – and eventually get thrown as CLR exceptions. Some common examples include</p>
<ol>
<ol>
<li>SqlException &#8211; exceptions generated at the Database driver/Data Access Layer .
<li>SoapException – exceptions generated outside of the process boundary altogether – and passed into the CLR as a general SOAP exception </li>
</ol>
</ol>
<h3>So – what is the solution?</h3>
<p>The solution is to use throw instead of throw ex. Throw retains the entire stack trace.</p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:96f9ecd9-e44b-4774-83f5-bc7a5cdb7cc0" class="wlWriterSmartContent">
<div style="border-bottom: #000080 1px solid; border-left: #000080 1px solid; font-family: 'Courier New', courier, monospace; color: #000; font-size: 10pt; border-top: #000080 1px solid; border-right: #000080 1px solid">
<div style="padding-bottom: 2px; padding-left: 5px; padding-right: 5px; font-family: verdana, tahoma, arial, sans-serif; background: #000080; color: #fff; font-weight: bold; padding-top: 2px">Code Snippet</div>
<div style="background: #ddd; max-height: 300px; overflow: auto">
<ol style="padding-bottom: 0px; margin: 0px 0px 0px 2em; padding-left: 5px; padding-right: 0px; background: #ffffff; padding-top: 0px">
<li><span style="color: #0000ff">try</span>
<li style="background: #f3f3f3">&nbsp;&nbsp;&nbsp; {
<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: #008000">// do some operation that can fail</span>
<li style="background: #f3f3f3">&nbsp;&nbsp;&nbsp; }
<li>&nbsp;&nbsp;&nbsp; <span style="color: #0000ff">catch</span> (<span style="color: #2b91af">Exception</span> ex)
<li style="background: #f3f3f3">&nbsp;&nbsp;&nbsp; {
<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: #008000">// do some local cleanup</span>
<li style="background: #f3f3f3">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: #0000ff">throw</span>;
<li>&nbsp;&nbsp; } </li>
</ol>
</div>
</div>
</div>
<h3>On catching exceptions in database code (inside a database stored procedure) </h3>
<p>If you have part of your business logic in a stored procedure (there are good reasons why this provides the best data access layer performance), then chances are your stored procedure is doing its own exception handling. It may be throwing and catching its own database layer exceptions. This is a terrible idea – considering the number of possible different exceptions that can occur in a database. Everything from integrity constraints being violated to incorrect SQL syntaxes to what not. To even attempt to identify the root cause of such errors without the database specific debug information – is nightmarish. I was part of a project where developers routinely went through this nightmarish exercise.</p>
<p>The exercise is meaningless since it is trivial to simply rethrow the stored proc exception to the database driver (and hence up to the data access layer). This provides meaningful information to a developer who needs to identify the source of the error. This changes the entire troubleshooting sequence from a ‘trial and error’ investigation – to a ‘simply look at the detailed exception – e.g. integrity constraint violated’.</p>
<p>Once I made these changes to all the stored procedures (simply re-threw all exceptions in the catch blocks on the stored proc exception handling), life became a lot simpler for the development team on the project. There is no reason to let the database stay secretive about its exceptions. Just throw them up to the data access layer – to provide meaningful troubleshooting info.&nbsp;&nbsp; </p>
<p>An example of how to rethrow exceptions in PLSQL code is shown below (use the RAISE keyword)</p>
<pre>DECLARE
<a name="6610"></a>   pe_ratio NUMBER(3,1);
<a name="4309"></a>BEGIN
<a name="6611"></a>   SELECT price / earnings INTO pe_ratio FROM stocks
<a name="6834"></a>      WHERE symbol = 'XYZ';  -- might cause division-by-zero error
<a name="6613"></a>   INSERT INTO stats (symbol, ratio) VALUES ('XYZ', pe_ratio);
<a name="6614"></a>   COMMIT;
<a name="4313"></a>EXCEPTION  -- exception handlers begin
<a name="6615"></a>   WHEN ZERO_DIVIDE THEN  -- handles 'division by zero' error
<a name="6835"></a>      INSERT INTO stats (symbol, ratio) VALUES ('XYZ', NULL);
      COMMIT</pre>
<pre>&nbsp;&nbsp; WHEN INVALID_CURSOR THEN&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; dbms_output.put_line('invalid cursor');&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; RAISE;&nbsp;&nbsp; WHEN INVALID_NUMBER THEN&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; dbms_output.put_line('invalid number');&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; RAISE;&nbsp;&nbsp; WHEN ROWTYPE_MISMATCH THEN &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; dbms_output.put_line('rowtype mismatch');&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; RAISE;&nbsp;&nbsp; WHEN TOO_MANY_ROWS THEN&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; dbms_output.put_line('too many rows');&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; RAISE;&nbsp;&nbsp;&nbsp; WHEN CURSOR_ALREADY_OPEN THEN&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; dbms_output.put_line('cursor open');&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; RAISE;&nbsp;&nbsp; WHEN DUP_VAL_ON_INDEX THEN &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; dbms_output.put_line('duplicate value');&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; RAISE;&nbsp;&nbsp; WHEN OTHERS THEN&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; dbms_output.put_line('other exception');&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; RAISE;</pre>
<pre>END; -- exception handlers and block end here</pre>
<h3>Download Sample Solution</h3>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:fb3a1972-4489-4e52-abe7-25a00bb07fdf:86425dd5-a04e-4dfb-b01a-d0d828400d02" class="wlWriterEditableSmartContent">
<p>Custom Exception Handling <a href="http://www.anujvarma.com/wp-content/uploads/CustomExceptionHandling.zip" target="_blank">download</a></p>
</div>
<h3>About the Author</h3>
<p>Anuj Varma is a technical architect specializing in Microsoft Platforms. Along with high level design and overall architecture, he provides hands-on development, unit testing and other best practices on all the projects he works on. His troubleshooting extends to n-Tier applications, WCF and Azure based applications to advanced SQL Server performance issues. </p>
<p>His customer base includes DELL, Schlumberger, British Petroleum as well as several small to midsize companies across Texas. Anuj can be contacted via the contact form on his blog &#8211; <a href="http://www.anujvarma.com/">http://www.anujvarma.com/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.anujvarma.com/c-net-exception-handling-best-practices/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Automatically Expand Windows Explorer Navigation Pane (left pane)</title>
		<link>http://www.anujvarma.com/automatically-expand-windows-explorer-navigation-pane-left-pane/</link>
		<comments>http://www.anujvarma.com/automatically-expand-windows-explorer-navigation-pane-left-pane/#comments</comments>
		<pubDate>Tue, 24 Apr 2012 20:22:32 +0000</pubDate>
		<dc:creator>Anuj Varma</dc:creator>
				<category><![CDATA[Windows Quirks, Email, Internet Gotchas]]></category>
		<category><![CDATA[current folder windows 7]]></category>
		<category><![CDATA[left navigation pane]]></category>
		<category><![CDATA[windows 7 explorer]]></category>
		<category><![CDATA[windows 7 explorer navigation]]></category>

		<guid isPermaLink="false">http://www.anujvarma.com/automatically-expand-windows-explorer-navigation-pane-left-pane/</guid>
		<description><![CDATA[Of the many things I miss in the Classic Windows View – the Windows Explorer navigation is one of them. In Windows 7, the navigation pane (the leftmost pane), does not have the same folder as the rightmost pane (the &#8230; <a href="http://www.anujvarma.com/automatically-expand-windows-explorer-navigation-pane-left-pane/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Of the many things I miss in the Classic Windows View – the Windows Explorer navigation is one of them. In Windows 7, the navigation pane (the leftmost pane), does not have the same folder as the rightmost pane (the details pane). This causes me a lot of grief – as I like to do several things such as ‘Create New Folder’ etc. from the leftmost pane – and it is a pain to not have it in sync with the details pane.</p>
<p>To make this work the way it did in Classic Windows – all you have to do is select Folder Options (from the Tools Menu) – and then check ‘Automatically Expand to current folder’ in the <em>Navigation Pane </em>checkboxes.</p>
<p>Step 1</p>
<p><a href="http://www.anujvarma.com/wp-content/uploads/folder_options.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="folder_options" border="0" alt="folder_options" src="http://www.anujvarma.com/wp-content/uploads/folder_options_thumb.png" width="310" height="186"></a></p>
<p>Step 2</p>
<p><a href="http://www.anujvarma.com/wp-content/uploads/automatically_expand.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="automatically_expand" border="0" alt="automatically_expand" src="http://www.anujvarma.com/wp-content/uploads/automatically_expand_thumb.png" width="194" height="244"></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.anujvarma.com/automatically-expand-windows-explorer-navigation-pane-left-pane/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A flexible service oriented architecture that handles multiple platforms (multiple devices, multiple databases…)</title>
		<link>http://www.anujvarma.com/a-flexible-service-oriented-architecture-that-handles-multiple-platforms-multiple-devices-multiple-databases/</link>
		<comments>http://www.anujvarma.com/a-flexible-service-oriented-architecture-that-handles-multiple-platforms-multiple-devices-multiple-databases/#comments</comments>
		<pubDate>Tue, 24 Apr 2012 18:57:15 +0000</pubDate>
		<dc:creator>Anuj Varma</dc:creator>
				<category><![CDATA[My Favorite SOA Patterns]]></category>
		<category><![CDATA[OOP Lessons Learnt]]></category>
		<category><![CDATA[Extensible SOA architecture]]></category>
		<category><![CDATA[service oriented architecture]]></category>
		<category><![CDATA[SOA multiple platforms]]></category>
		<category><![CDATA[SOA platform independence]]></category>

		<guid isPermaLink="false">http://www.anujvarma.com/a-flexible-service-oriented-architecture-that-handles-multiple-platforms-multiple-devices-multiple-databases/</guid>
		<description><![CDATA[The Problem Statement
Imagine that you have just built a sophisticated application to work against a SQL Server database. You followed a best-practices approach and separated out your presentation, business logic and data access layer. Your application is service oriented – &#8230; <a href="http://www.anujvarma.com/a-flexible-service-oriented-architecture-that-handles-multiple-platforms-multiple-devices-multiple-databases/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<h3>The Problem Statement</h3>
<p>Imagine that you have just built a sophisticated application to work against a SQL Server database. You followed a best-practices approach and separated out your presentation, business logic and data access layer. Your application is service oriented – and exposes a set of services to the outside world. For e.g. – your application offers an <em>Account Service </em>and a <em>Security Service </em>for consumption by the outside world. </p>
<ol>
<li>Now – you are told that this application needs to work against not just SQL Server – but Oracle as well. </li>
<li>However, the services (AccountService, SecurityService) – will be somewhat different for the Oracle version.&nbsp; </li>
<li>While the services may be different, a lot of the functionality between the platforms will be similar. </li>
<li>In addition, your design must be <em>flexible (extensible). </em>If more database platforms were added down the road – or more services to go along with the AccountService and the SecurityServices, the design should accommodate these with minimal changes.</li>
</ol>
<p>This can be summarized as supporting <em>multiple services for multiple platforms </em>(these <em>platforms </em>do not have to be multiple databases – can be multiple OSes, multiple device platforms –e.g. Mobile and Desktop).&nbsp;&nbsp; One of the key issues that this design presents is that of code <em>commonality</em> -&nbsp; and code differentiation. Some of the code for the <em>multiple platforms </em>may be common to both the platforms. Example – when the <em>AccountService </em>creates an Account, there may be exception handling code that is common to both <em>Oracle </em>and <em>SqlServer. </em>In addition – a good deal of code would be completely unique to each platform – so – a SQLServer account creation would use SQLServer authentication whereas an Oracle account creation would use Oracle specific authentication.</p>
<p>This article presents an architecture to solve both of the problems above (keeping common code as well as differentiation platform specific code) – and provides a full sample implementation. This implementation can be used for various problems that require accommodating multiple services and multiple platforms. The possibilities are limitless – and I have used this on at least 2 projects successfully.&nbsp; It allows for extensibility by allowing more services to be added – as well as more platforms to be added down the road.</p>
<h3>Starting Point &#8211; Make it simple for the client</h3>
<p>What would a sample client need to do to invoke a sample platform-specific service ? Say – a client wanted to use the <em>AccountService </em>specific to SqlServer. The snippet below shows everything that a client should need to do – get a handle to the SqlServer factory. This factory is responsible for all SqlServer specific services – so getting an <em>AccountService </em>back from this factory should be as simple as a <em>GetService </em>call. The snippet below shows everything that a client should need to do.</p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:6c5f70fd-19c7-43a5-bcb4-7dcfe0370491" class="wlWriterEditableSmartContent">
<div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt">
<div style="background: #000080; color: #fff; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px">Code Snippet</div>
<div style="background: #ddd; max-height: 300px; overflow: auto">
<ol style="background: #ffffff; margin: 0 0 0 2em; padding: 0 0 0 5px;">
<li>&nbsp;</li>
<li style="background: #f3f3f3"><span style="background:#ffffff;color:#000000">ServiceFactory.</span><span style="background:#ffffff;color:#2b91af">SqlServerServiceFactory</span><span style="background:#ffffff;color:#000000"> sqlFactory = </span><span style="background:#ffffff;color:#0000ff">new</span><span style="background:#ffffff;color:#000000"> ServiceFactory.</span><span style="background:#ffffff;color:#2b91af">SqlServerServiceFactory</span><span style="background:#ffffff;color:#000000">();</span></li>
<li><span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#2b91af">IAccountService</span><span style="background:#ffffff;color:#000000"> acctService = sqlFactory.GetService&lt;</span><span style="background:#ffffff;color:#2b91af">IAccountService</span><span style="background:#ffffff;color:#000000">&gt;();</span></li>
</ol></div>
</p></div>
</p></div>
<h3>An Introduction to the overall architecture</h3>
<p>To model the various services (AccountService, SecurityService…), we notice firstly that these services are unrelated to each other. A prospective implementation could implement both the AccountService and the SecurityService.&nbsp; This leads us to explore an <em>interface </em>based approach for the set of services. </p>
<h3>Services by Feature (Account, Security) Architecture – An <em>Interface</em> Based Approach</h3>
<p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:201aa302-0939-4577-b35a-8145309a1767" class="wlWriterEditableSmartContent">
<div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt">
<div style="background: #000080; color: #fff; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px">Code Snippet</div>
<div style="background: #ddd; max-height: 300px; overflow: auto">
<ol style="background: #ffffff; margin: 0 0 0 2em; padding: 0 0 0 5px;">
<li><span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">interface</span><span style="background:#ffffff;color:#000000"> </span><span style="background:#ffffff;color:#2b91af">IAccountService</span></li>
<li style="background: #f3f3f3">&#160;&#160;<span style="background:#ffffff;color:#000000">{</span></li>
<li>&#160;&#160;&#160;&#160;&#160;&#160;<span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">void</span><span style="background:#ffffff;color:#000000"> CreateAccount();</span></li>
<li style="background: #f3f3f3">&#160;&#160;<span style="background:#ffffff;color:#000000">}</span></li>
</ol></div>
</p></div>
</p></div>
</p>
<p>&nbsp;</p>
<p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:6c754a20-eb8f-4138-8a77-573f549e6913" class="wlWriterEditableSmartContent">
<div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt">
<div style="background: #000080; color: #fff; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px">Code Snippet</div>
<div style="background: #ddd; max-height: 300px; overflow: auto">
<ol style="background: #ffffff; margin: 0 0 0 2em; padding: 0 0 0 5px;">
<li><span style="background:#ffffff;color:#0000ff">interface</span><span style="background:#ffffff;color:#000000"> </span><span style="background:#ffffff;color:#2b91af">ISecurityService</span></li>
<li style="background: #f3f3f3">&#160;&#160;&#160;&#160;<span style="background:#ffffff;color:#000000">{</span></li>
<li>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">void</span><span style="background:#ffffff;color:#000000"> AuthenticateUser();</span></li>
<li style="background: #f3f3f3">&#160;&#160;&#160;&#160;<span style="background:#ffffff;color:#000000">}</span></li>
</ol></div>
</p></div>
</p></div>
</p>
<h3>Services By Platform (SQLServer, Oracle…) Architecture – An<em> Inheritance</em> Based Approach</h3>
<p>For the <em>platform differentiation, </em>we note that some of the code may be common to both platforms – for e.g. – error handling and exception logging from the AccountService would need to be identical for both Oracle and SqlServer. We use an inheritance based approach – which allows us to use a <em>Template </em>pattern. The template pattern would provide a template method – that consists of a) Common Code b) Platform Specific Code</p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:7a023d25-74ce-42e5-8926-3d923cdbb1fb" class="wlWriterEditableSmartContent">
<div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt">
<div style="background: #000080; color: #fff; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px">Code Snippet</div>
<div style="background: #ddd; max-height: 300px; overflow: auto">
<ol style="background: #ffffff; margin: 0 0 0 2.5em; padding: 0 0 0 5px;">
<li><span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">public</span><span style="background:#ffffff;color:#000000"> </span><span style="background:#ffffff;color:#0000ff">virtual</span><span style="background:#ffffff;color:#000000"> </span><span style="background:#ffffff;color:#0000ff">void</span><span style="background:#ffffff;color:#000000"> CreateAccount()</span></li>
<li style="background: #f3f3f3"><span style="background:#ffffff;color:#000000">{</span></li>
<li>&nbsp;</li>
<li style="background: #f3f3f3">&#160;&#160;&#160;&#160;<span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#008000">//&#160;&#160;common code &#8211; example &#8211; Initialize</span></li>
<li>&#160;&#160;&#160;&#160;<span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#2b91af">Console</span><span style="background:#ffffff;color:#000000">.WriteLine(</span><span style="background:#ffffff;color:#800000">&quot;Account Service: Common Initialization Code&quot;</span><span style="background:#ffffff;color:#000000">);</span></li>
<li style="background: #f3f3f3">&nbsp;</li>
<li>&#160;&#160;&#160;&#160;<span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#008000">// Platform specific code</span></li>
<li style="background: #f3f3f3">&#160;&#160;&#160;&#160;<span style="background:#ffffff;color:#000000">SomePlatformSpecificOperation(); </span></li>
<li>&nbsp;</li>
<li style="background: #f3f3f3">&#160;&#160;&#160;&#160;<span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#008000">// common code again &#8211; example &#8211; cleanup()&#8230;</span></li>
<li>&#160;&#160;&#160;&#160;<span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#2b91af">Console</span><span style="background:#ffffff;color:#000000">.WriteLine(</span><span style="background:#ffffff;color:#800000">&quot;Account Service: Common Cleanup Code&quot;</span><span style="background:#ffffff;color:#000000">);</span></li>
<li style="background: #f3f3f3">&nbsp;</li>
<li><span style="background:#ffffff;color:#000000">}</span></li>
<li style="background: #f3f3f3">&nbsp;</li>
<li><span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">protected</span><span style="background:#ffffff;color:#000000"> </span><span style="background:#ffffff;color:#0000ff">virtual</span><span style="background:#ffffff;color:#000000"> </span><span style="background:#ffffff;color:#0000ff">void</span><span style="background:#ffffff;color:#000000"> SomePlatformSpecificOperation()</span></li>
<li style="background: #f3f3f3"><span style="background:#ffffff;color:#000000">{</span></li>
<li>&#160;&#160;&#160;&#160;<span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#2b91af">Console</span><span style="background:#ffffff;color:#000000">.WriteLine(</span><span style="background:#ffffff;color:#800000">&quot;Some BASE operation that is common to both ORACLE and SQLServer. This can be over-riddent in the child classes for PLATFORM speficic functionality&quot;</span><span style="background:#ffffff;color:#000000">);</span></li>
<li style="background: #f3f3f3"><span style="background:#ffffff;color:#000000">}</span></li>
</ol></div>
</p></div>
</p></div>
<h3>The Overall Architecture – using Inheritance for Platform Variation – and interfaces for services</h3>
<p><a href="http://www.anujvarma.com/wp-content/uploads/services_architecture_object_model_thumb1.png"><strong><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="services_architecture_object_model_thumb" border="0" alt="services_architecture_object_model_thumb" src="http://www.anujvarma.com/wp-content/uploads/services_architecture_object_model_thumb_thumb.png" width="432" height="422"></strong></a></p>
<p>&nbsp;</p>
<h3>The Service Factory</h3>
<p>The only other component (apart from the <em>interface</em> based services and the <em>inheritance</em> based platforms) that we need is a service factory – one that will return the appropriate <em>feature service (e.g. Account Service) – </em>along with the appropriate platform (e.g. <em>SqlServerAccountService). </em></p>
<p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:61ae1851-60e5-43b5-ab46-c42a2e3e6c70" class="wlWriterEditableSmartContent">
<div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt">
<div style="background: #000080; color: #fff; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px">Code Snippet</div>
<div style="background: #ddd; max-height: 300px; overflow: auto">
<ol style="background: #ffffff; margin: 0 0 0 2em; padding: 0 0 0 5px;">
<li><span style="background:#ffffff;color:#000000"> </span><span style="background:#ffffff;color:#0000ff">interface</span><span style="background:#ffffff;color:#000000"> </span><span style="background:#ffffff;color:#2b91af">IServiceFactory</span></li>
<li style="background: #f3f3f3">&#160;&#160;&#160;&#160;<span style="background:#ffffff;color:#000000">{</span></li>
<li>&#160;&#160;&#160;&#160;&#160;&#160;&#160;<span style="background:#ffffff;color:#000000">T GetService&lt;T&gt;();</span></li>
<li style="background: #f3f3f3">&#160;&#160;&#160;&#160;<span style="background:#ffffff;color:#000000">}</span></li>
</ol></div>
</p></div>
</p></div>
</p>
<p>A simple dictionary is used to store the list of services (AccountService, SecurityService…) – and a lookup method is provided as shown below:</p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:4b17e987-f2b6-401a-8a72-6b78ef0e11e0" class="wlWriterEditableSmartContent">
<div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt">
<div style="background: #000080; color: #fff; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px">Code Snippet</div>
<div style="background: #ddd; max-height: 300px; overflow: auto">
<ol style="background: #ffffff; margin: 0 0 0 2.5em; padding: 0 0 0 5px;">
<li><span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">private</span><span style="background:#ffffff;color:#000000"> </span><span style="background:#ffffff;color:#2b91af">IDictionary</span><span style="background:#ffffff;color:#000000">&lt;</span><span style="background:#ffffff;color:#0000ff">string</span><span style="background:#ffffff;color:#000000">, </span><span style="background:#ffffff;color:#0000ff">object</span><span style="background:#ffffff;color:#000000">&gt; allservices = </span><span style="background:#ffffff;color:#0000ff">new</span><span style="background:#ffffff;color:#000000"> </span><span style="background:#ffffff;color:#2b91af">Dictionary</span><span style="background:#ffffff;color:#000000">&lt;</span><span style="background:#ffffff;color:#0000ff">string</span><span style="background:#ffffff;color:#000000">, </span><span style="background:#ffffff;color:#0000ff">object</span><span style="background:#ffffff;color:#000000">&gt;();</span></li>
<li style="background: #f3f3f3">&nbsp;</li>
<li><span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">public</span><span style="background:#ffffff;color:#000000"> T GetService&lt;T&gt;()</span></li>
<li style="background: #f3f3f3"><span style="background:#ffffff;color:#000000">{</span></li>
<li>&#160;&#160;&#160;&#160;<span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">object</span><span style="background:#ffffff;color:#000000"> service = </span><span style="background:#ffffff;color:#0000ff">null</span><span style="background:#ffffff;color:#000000">;</span></li>
<li style="background: #f3f3f3">&#160;&#160;&#160;&#160;<span style="background:#ffffff;color:#000000">T returnedService = (T)service;</span></li>
<li>&#160;&#160;&#160;&#160;<span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">string</span><span style="background:#ffffff;color:#000000"> serviceName = </span><span style="background:#ffffff;color:#0000ff">typeof</span><span style="background:#ffffff;color:#000000">(T).FullName;</span></li>
<li style="background: #f3f3f3">&#160;&#160;&#160;&#160;<span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">if</span><span style="background:#ffffff;color:#000000"> (allservices.TryGetValue(serviceName, </span><span style="background:#ffffff;color:#0000ff">out</span><span style="background:#ffffff;color:#000000"> service))</span></li>
<li>&#160;&#160;&#160;&#160;<span style="background:#ffffff;color:#000000">{</span></li>
<li style="background: #f3f3f3">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<span style="background:#ffffff;color:#000000">returnedService = (T)service;</span></li>
<li>&#160;&#160;&#160;&#160;<span style="background:#ffffff;color:#000000">}</span></li>
<li style="background: #f3f3f3">&nbsp;</li>
<li>&#160;&#160;&#160;&#160;<span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">return</span><span style="background:#ffffff;color:#000000"> returnedService;</span></li>
<li style="background: #f3f3f3">&nbsp;</li>
<li><span style="background:#ffffff;color:#000000">}</span></li>
</ol></div>
</p></div>
</p></div>
<h3>Summary</h3>
<p>Almost every app today follows a service oriented architecture which exposes multiple services. If our app was limited to just that, the above interface based approach coupled with our <em>Service Factory (to return a specific service) </em>would be all that is needed. However, today’s services are not just <em>feature </em>based – but also tend to support multiple platforms. These multiple platforms could be <em>multiple databases (e.g. SQLServer and Oracle on the backend), multiple devices (e.g. Desktop and Mobile), multiple OSes etc. </em></p>
<p>This post provides a full object oriented implementation that supports multiple <em>platforms </em>along with multiple services (<em>features). </em>The multiple services were modeled using interfaces. Then, to account for the different <em>platform </em>implementations of each service, we defined an inheritance hierarchy – coupled with a template pattern to handle code commonality between the different platforms.
<p>&nbsp; This proves to be an elegant solution for a common, real-world problem in Object Oriented projects. There are a multitude of possible applications of the above architecture.&nbsp;<br />
<blockquote>
<p>Perhaps the greatest strength of the above architecture is the extensibility it provides. One can add new database platforms and new services down the road – with ease and minimal code changes.</p>
</blockquote>
<p>NOTE: Ideally, you would want to design a Data Access Layer that was agnostic of the underlying database. This layer would generate all your SQL statements (CRUD) without caring about what the underlying database platform was. Such a <em>database agnostic</em> data access layer is described in an earlier post <a href="http://cut.ms/boWl">here</a>.<br />
<h3>Full Solution Download</h3>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:fb3a1972-4489-4e52-abe7-25a00bb07fdf:8b8917ee-cff2-4907-bebc-34f8d0444a6c" class="wlWriterEditableSmartContent">
<p>Services_By_Platform_Architecture <a href="http://www.anujvarma.com/wp-content/uploads/Services_By_Platform_Architecture2.zip" target="_blank">Download Solution</a></p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.anujvarma.com/a-flexible-service-oriented-architecture-that-handles-multiple-platforms-multiple-devices-multiple-databases/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Getting Started With Microsoft StreamInsight</title>
		<link>http://www.anujvarma.com/getting-started-with-microsoft-streaminsight/</link>
		<comments>http://www.anujvarma.com/getting-started-with-microsoft-streaminsight/#comments</comments>
		<pubDate>Tue, 24 Apr 2012 14:54:11 +0000</pubDate>
		<dc:creator>Anuj Varma</dc:creator>
				<category><![CDATA[Event Driven, CEP Applications]]></category>
		<category><![CDATA[CEP]]></category>
		<category><![CDATA[Event Driven Applications]]></category>
		<category><![CDATA[Event Processing]]></category>
		<category><![CDATA[Querying IIS log files]]></category>
		<category><![CDATA[Stream Insight]]></category>
		<category><![CDATA[StreamInsight]]></category>

		<guid isPermaLink="false">http://www.anujvarma.com/?p=1256</guid>
		<description><![CDATA[Introduction
Imagine a technology that lets you immediately response to variations in energy or water consumption – or one that allows monitoring of real-time stock data (up to 100,000 events per second). Imagine the same technology allowing monitoring of an entire &#8230; <a href="http://www.anujvarma.com/getting-started-with-microsoft-streaminsight/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<h3><font size="3" face="Times New Roman">Introduction</font></h3>
<p><font size="3" face="Times New Roman">Imagine a technology that lets you immediately response to variations in energy or water consumption – or one that allows monitoring of real-time stock data (up to 100,000 events per second). Imagine the same technology allowing monitoring of an entire manufacturing plant’s floor activities – and raising events/alerts when something goes wrong. These are just some of the applications of Microsoft StreamInsight &#8211; a powerful platform that can be used to develop complex event processing (CEP) applications.&nbsp;&nbsp; In this post, I will provide an overview of how StreamInsight can be used to monitor IIS Log Files for events – something that can be used by high-volume, multiple server farm, asp.net websites.</font></p>
<h3><font size="3" face="Times New Roman">Some Typical Applications of Event Driven Applications</font></h3>
<ol>
<li><font size="3" face="Times New Roman">Monitoring Applications </font>
<li><font size="3" face="Times New Roman">Analytics Applications </font>
<li><font size="3" face="Times New Roman">ClickStream Analysis</font>
<li><font size="3" face="Times New Roman">Logistics</font>
<li><font size="3" face="Times New Roman">Financial Trading </font>
<li><font size="3" face="Times New Roman">Manufacturing-&nbsp; Example &#8211; Manufacturing companies require low-latency data collection and analysis of plant-floor devices and sensors. The typical manufacturing scenario includes the following requirements:</font></li>
<ul>
<li>
<p><font size="3" face="Times New Roman">Asset-based monitoring and aggregation of machine-born data.</font></p>
<li>
<p><font size="3" face="Times New Roman">Sensor-based observation of plant floor activities and output.</font></p>
<li>
<p><font size="3" face="Times New Roman">Observation and reaction through device controllers.</font></p>
<li>
<p><font size="3" face="Times New Roman">Ability to handle up to 10,000 data events per second.</font></p>
<li>
<p><font size="3" face="Times New Roman">Event and alert generation the moment something goes wrong.</font></p>
<li>
<p><font size="3" face="Times New Roman">Proactive, condition-based maintenance on key equipment.</font></p>
<li>
<p><font size="3" face="Times New Roman">Low-latency analysis of aggregated data (windowed and log-scales).</font></p>
</li>
</ul>
</ol>
<h3><font size="3" face="Times New Roman">Event Driven Applications versus Database Applications</font></h3>
<table border="0" cellspacing="0" cellpadding="2" width="454">
<tbody>
<tr>
<td valign="top" width="133"><font size="3" face="Times New Roman"></font></td>
<td valign="top" width="133"><strong><font size="3" face="Times New Roman">Database Applications</font></strong></td>
<td valign="top" width="186"><strong><font size="3" face="Times New Roman">Event Driven Applications</font></strong></td>
</tr>
<tr>
<td valign="top" width="133"><font size="3" face="Times New Roman">Query Paradigm</font></td>
<td valign="top" width="133"><font size="3" face="Times New Roman">Ad-Hoc queries or requests</font></td>
<td valign="top" width="186"><font size="3" face="Times New Roman">Continuous.’always-on’ queries</font></td>
</tr>
<tr>
<td valign="top" width="133"><font size="3" face="Times New Roman">Latency</font></td>
<td valign="top" width="133"><font size="3" face="Times New Roman">Seconds, Hours, Days</font></td>
<td valign="top" width="186"><font size="3" face="Times New Roman">Milliseconds or less</font></td>
</tr>
<tr>
<td valign="top" width="133"><font size="3" face="Times New Roman">Data Rate</font></td>
<td valign="top" width="150"><font size="3" face="Times New Roman">Hundreds of events/second</font></td>
<td valign="top" width="186"><font size="3" face="Times New Roman">Tens of thousands of events per sec </font></td>
</tr>
<tr>
<td valign="top" width="133"><font size="3" face="Times New Roman">Query Semantics</font></td>
<td valign="top" width="150"><font size="3" face="Times New Roman">Declarative relational analytics</font></td>
<td valign="top" width="186"><font size="3" face="Times New Roman">Declarative relational and temporal analytics</font></td>
</tr>
</tbody>
</table>
<p><font size="3" face="Times New Roman"></font></p>
<h3><font size="3" face="Times New Roman">STEPS In creating an end-to-end StreamInsight application</font></h3>
<p><font size="3" face="Times New Roman">A typical streaminsight app would need an <em>event source, </em>an <em>event stream, </em>a <em>query to read the event stream </em>and an <em>output sink to handle/display </em>the query results.</font></p>
<ol>
<li><font size="3" face="Times New Roman">Define your input event source (IIS log file etc.) &#8211; and write an input adapter for it </font>
<li><font size="3" face="Times New Roman">Create an event stream from the event source (inputStream) that can consist of custom datatypes </font>
<li><font size="3" face="Times New Roman">Define the query to run against the inputStream- and start the query </font>
<li><font size="3" face="Times New Roman">Specify an output sink &#8211; Write an output adapter for the output sink </font>
<li><font size="3" face="Times New Roman">BIND the query and the output sink &#8211; and you should start seeing the output in your output file etc. </font></li>
</ol>
<h3><font size="3" face="Times New Roman">An Example – Using StreamInsight to Query IIS Log Files</font></h3>
<p><font size="3" face="Times New Roman">If we need to query the IIS logs (txt files), then the process is as follows:</font></p>
<p><font size="3" face="Times New Roman">The event source would be the IIS log file &#8211; and we would write a text file adapter &#8211; which would read each line of the log file and create an &#8216;event&#8217; based on the contents of the line. In addition, we can put custom datatypes inside the event (so &#8211; for e.g. &#8211; if our log file contains customer firstname, lastname as strings, you could create a &#8216;Customer&#8217; datatype from these strings &#8211; and embed it inside the event).</font></p>
<p><font size="3" face="Times New Roman">All these events are sent as part of an &#8216;input stream&#8217; which looks something like:</font></p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:c9de6edc-34e1-4cf6-a30d-c3fba4c1ff11" class="wlWriterSmartContent">
<div style="border-bottom: #000080 1px solid; border-left: #000080 1px solid; font-family: 'Courier New', courier, monospace; color: #000; font-size: 10pt; border-top: #000080 1px solid; border-right: #000080 1px solid">
<div style="padding-bottom: 2px; padding-left: 5px; padding-right: 5px; font-family: verdana, tahoma, arial, sans-serif; background: #000080; color: #fff; font-weight: bold; padding-top: 2px"><font size="3" face="Times New Roman">Code Snippet</font></div>
<div style="background: #ddd; max-height: 300px; overflow: auto">
<ol style="padding-bottom: 0px; margin: 0px 0px 0px 2em; padding-left: 5px; padding-right: 0px; background: #ffffff; padding-top: 0px">
<li><font face="Times New Roman"><font size="3"><span style="color: #0000ff">var</span> inputstream = CepStream&lt;Customer&gt;.Create(<span style="color: #a31515">&#8220;inputStream&#8221;</span>,<span style="color: #0000ff">typeof</span>(MyInputAdapterFactory),<span style="color: #0000ff">new</span> InputAdapterConfig { someFlag = <span style="color: #0000ff">true</span> },EventShape.Point); </font></font></li>
</ol>
</div>
</div>
</div>
<p><font size="3" face="Times New Roman">Now we are ready to query this stream. A simple example would be querying the stream for all customers with firstName = &#8216;Anuj&#8217;</font></p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:123490c7-5e4a-4a22-968e-e226af4ede59" class="wlWriterSmartContent">
<div style="border-bottom: #000080 1px solid; border-left: #000080 1px solid; font-family: 'Courier New', courier, monospace; color: #000; font-size: 10pt; border-top: #000080 1px solid; border-right: #000080 1px solid">
<div style="padding-bottom: 2px; padding-left: 5px; padding-right: 5px; font-family: verdana, tahoma, arial, sans-serif; background: #000080; color: #fff; font-weight: bold; padding-top: 2px"><font size="3" face="Times New Roman">Code Snippet</font></div>
<div style="background: #ddd; max-height: 300px; overflow: auto">
<ol style="padding-bottom: 0px; margin: 0px 0px 0px 2em; padding-left: 5px; padding-right: 0px; background: #ffffff; padding-top: 0px">
<li><font face="Times New Roman"><font size="3"><span style="color: #0000ff">var</span> filtered = <span style="color: #0000ff">from</span> e <span style="color: #0000ff">in</span> inputstream <span style="color: #0000ff">where</span> e.FirstName = <span style="color: #a31515">&#8216;Anuj&#8217;</span> <span style="color: #0000ff">select</span> e; </font></font></li>
</ol>
</div>
</div>
</div>
<p><font size="3" face="Times New Roman">Now that the query is defined, we are ready to &#8216;start&#8217; the query. This essentially instantiates a &#8216;query&#8217; object which stays running for the duration of the application. This effectively &#8216;binds&#8217; the query to the input stream.</font></p>
<p><font size="3" face="Times New Roman">The only remaining step is getting the results of the query. For this, we need an &#8216;output&#8217; adapter. The output can be written to a txt file, csv file etc.</font></p>
<h3><font size="3" face="Times New Roman">Difference between SQL Server Notification Services (SQLNS) and StreamInsight</font></h3>
<p><font size="3" face="Times New Roman">SQL Server Notification Services also works with event sources and event targets, but the similarity ends there. In SQL Notification Services, events are stored in the database and matched against subscriptions to produce notifications. The focus in SQLNS is on storing events, matching, and formatting notifications. Until the event is stored, it&#8217;s not visible to the infrastructure, only to the event provider.</font></p>
<p><font size="3" face="Times New Roman">In StreamInsight, the focus is on processing and querying the data in the input stream, in real-time. The stream processing architecture is lightweight, and almost all of the use cases presented in the docs name &#8220;the ability to handle up to 100,000 events per second for a large number of devices&#8221; as a goal.</font></p>
<h3><u><font size="3" face="Times New Roman">Some benefits of StreamInsight</font></u></h3>
<ul>
<ul>
<li>
<p><font size="3" face="Times New Roman">Highly optimized performance and data throughput</font></p>
<p><font size="3" face="Times New Roman">StreamInsight implements a lightweight streaming architecture that supports highly parallel execution of continuous queries over high-speed data. The use of in-memory caches and incremental result computation provide excellent performance with high data throughout and low latency. Low latency is achieved because the events are processed without costly data load or storage operations in the critical processing path. With StreamInsight, all processing is automatically triggered by incoming events. In particular, applications do not have to incur any overhead for event polling. The platform provides the functionality for handling out-of-order events. In addition, static reference or historical data can be accessed and included in the low-latency analysis.</font></p>
<li>
<p><font size="3" face="Times New Roman">.NET development environment</font></p>
<p><font size="3" face="Times New Roman">Developers can write their CEP applications using Microsoft’s .NET language such as Visual C#, leveraging the advanced language platform LINQ (Language Integrated Query) as an embedded query language. Given the large community of developers already familiar with these technologies, this capability reduces development costs and the time from application development to production. In the current release, StreamInsight supports only C# as the host language.</font></p>
<p><font size="3" face="Times New Roman">By using LINQ, developers familiar with SQL will be able to quickly write queries in a declarative fashion that process and correlate data from multiple streams into meaningful results. The optimizer and scheduler of the StreamInsight server in turn ensure optimal query performance.</font></p>
<li>
<p><font size="3" face="Times New Roman">Flexible deployment capability</font></p>
<p><font size="3" face="Times New Roman">StreamInsight supports three deployment scenarios:</font></p>
<ul>
<li>
<p><font size="3" face="Times New Roman">Fully integrated into the application as a hosted (embedded) DLL.</font></p>
<li>
<p><font size="3" face="Times New Roman">As a stand-alone server with multiple applications and users sharing the server. In its stand-alone configuration, the StreamInsight server runs in a wrapper such as an executable, or the server could be packaged as a Windows Service.</font></p>
<li>
<p><font size="3" face="Times New Roman">The hosted or stand-alone StreamInsight server could be part of a server farm.</font></p>
</li>
</ul>
<li>
<p><font size="3" face="Times New Roman">Manageability</font></p>
<ul>
<li>
<p><font size="3" face="Times New Roman">The monitoring and manageability features built into the StreamInsight server provide for low total cost of ownership (TCO) of CEP applications. The management interface and diagnostic views that are provided in the StreamInsight server allow the administrator to monitor and manage the CEP application. The manageability framework also allows for ISVs and system integrators to remotely monitor and support StreamInsight-deployed systems at manufacturing and other scale-out installations.</font></p>
<li>
<p><font size="3" face="Times New Roman">StreamInsight provides a stand-alone event flow debugger that can be used to analyze, diagnosis, and troubleshoot the queries used in StreamInsight applications. <br /></font><a href="http://www.anujvarma.com/wp-content/uploads/StreamInsight_Datasheet.pdfAdobeRead.png"><font size="3" face="Times New Roman"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="StreamInsight_Datasheet.pdf - Adobe Reader" border="0" alt="StreamInsight_Datasheet.pdf - Adobe Reader" src="http://www.anujvarma.com/wp-content/uploads/StreamInsight_Datasheet.pdfAdobeRead_thumb.png" width="494" height="550"></font></a></p>
</li>
</ul>
</li>
</ul>
</ul>
<h3><font face="Times New Roman"><font size="3"><u>Real Life CEP (StreamInsight) usage Scenarios</u> </font></font></h3>
<p><a><font size="3" face="Times New Roman"></font></a></p>
<p><font size="3" face="Times New Roman">The need for high-throughput, low-latency processing of event streams is common to the following business scenarios:</font></p>
<ul>
<li>
<p><font size="3" face="Times New Roman">Manufacturing process monitoring and control</font></p>
<li>
<p><font size="3" face="Times New Roman">Clickstream analysis</font></p>
<li>
<p><font size="3" face="Times New Roman">Financial services</font></p>
<li>
<p><font size="3" face="Times New Roman">Power utilities</font></p>
<li>
<p><font size="3" face="Times New Roman">Health care</font></p>
<li>
<p><font size="3" face="Times New Roman">IT monitoring</font></p>
<li>
<p><font size="3" face="Times New Roman">Logistics</font></p>
<li>
<p><font size="3" face="Times New Roman">Telecom</font></p>
</li>
</ul>
<p><font size="3" face="Times New Roman">The following sections discuss some of these scenarios and investigate their requirements for event processing.</font></p>
<h3><font size="3" face="Times New Roman">Manufacturing Process Monitoring and Control</font></h3>
<p><font size="3" face="Times New Roman">To ensure that products and processes are running optimally and with the least amount of downtime, manufacturing companies require low-latency data collection and analysis of plant-floor devices and sensors. The typical manufacturing scenario includes the following requirements:</font></p>
<ul>
<li>
<p><font size="3" face="Times New Roman">Asset-based monitoring and aggregation of machine-born data.</font></p>
<li>
<p><font size="3" face="Times New Roman">Sensor-based observation of plant floor activities and output.</font></p>
<li>
<p><font size="3" face="Times New Roman">Observation and reaction through device controllers.</font></p>
<li>
<p><font size="3" face="Times New Roman">Ability to handle up to 10,000 data events per second.</font></p>
<li>
<p><font size="3" face="Times New Roman">Event and alert generation the moment something goes wrong.</font></p>
<li>
<p><font size="3" face="Times New Roman">Proactive, condition-based maintenance on key equipment.</font></p>
<li>
<p><font size="3" face="Times New Roman">Low-latency analysis of aggregated data (windowed and log-scales).</font></p>
</li>
</ul>
<h3><font size="3" face="Times New Roman">Clickstream Analysis</font></h3>
<p><font size="3" face="Times New Roman">An optimal customer experience from a commercial Web site requires low-latency processing of user behavior and interactions at the site. The typical click stream analysis application includes the following requirements:</font></p>
<ul>
<li>
<p><font size="3" face="Times New Roman">Ability to drive page layout, navigation, and presentation based on low-latency click stream analysis.</font></p>
<li>
<p><font size="3" face="Times New Roman">Ability to handle up to 100,000 data events per second during peak traffic times.</font></p>
<li>
<p><font size="3" face="Times New Roman">Immediate click-stream pattern detection and response with targeted advertising.</font></p>
</li>
</ul>
<h3><font size="3" face="Times New Roman">Algorithmic Trading in a Financial Services Environment</font></h3>
<p><font size="3" face="Times New Roman">Algorithmic trading, with its high volume data processing needs, typically has the following requirements:</font></p>
<ul>
<li>
<p><font size="3" face="Times New Roman">Ability to handle up to 100,000 data events per second.</font></p>
<li>
<p><font size="3" face="Times New Roman">Time-critical query processing.</font></p>
<li>
<p><font size="3" face="Times New Roman">Monitoring and capitalizing on current market conditions with very short windows of opportunity.</font></p>
<li>
<p><font size="3" face="Times New Roman">Smart filtering of input data.</font></p>
<li>
<p><font size="3" face="Times New Roman">Ability to define patterns over multiple data sources and over time to automatically trigger buy/sell/hold decisions for assets in a portfolio.</font></p>
</li>
</ul>
<h3><font size="3" face="Times New Roman">Power Utilities</font></h3>
<p><font size="3" face="Times New Roman">The utility sector requires an efficient infrastructure for managing electric grids and other utilities. These systems typically have the following requirements.</font></p>
<ul>
<li>
<p><font size="3" face="Times New Roman">Immediate response to variations in energy or water consumption, to minimize or avoid outages or other disruptions of service.</font></p>
<li>
<p><font size="3" face="Times New Roman">Gaining operational and environmental efficiencies by moving to smart grids.</font></p>
<li>
<p><font size="3" face="Times New Roman">Multiple levels of aggregation along the grid.</font></p>
<li>
<p><font size="3" face="Times New Roman">Ability to handle up to 100,000 events per second from millions of data sources.</font></p>
</li>
</ul>
<h3><font face="Times New Roman"><font size="3"><u>StreamInsight Server Architecture</u> </font></font></h3>
<p><font size="3" face="Times New Roman">The run-time component of Microsoft StreamInsight is the StreamInsight server. It consists of the core engine and the adapter framework. The adapter framework allows developers to create interfaces to event stores such as Web servers, devices or sensors, and stock tickers or news feeds; and to event sinks such as pagers, monitoring devices, KPI dashboards, trading stations, or databases. Incoming events are continuously streamed into standing queries in the StreamInsight server, which process and transform the data according to the logic defined in each query. The query result at the output can then be used to trigger specific actions.</font></p>
<p><font size="3" face="Times New Roman">The following illustration presents a high-level overview of the StreamInsight architecture.</font></p>
<blockquote><p><a href="http://www.anujvarma.com/wp-content/uploads/StreamInsight.gif"><font size="3" face="Times New Roman"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="StreamInsight" border="0" alt="StreamInsight" src="http://www.anujvarma.com/wp-content/uploads/StreamInsight_thumb.gif" width="770" height="478"></font></a><font size="3" face="Times New Roman">&nbsp;</font></p>
</blockquote>
<h3><u><font size="3" face="Times New Roman">Conclusion</font></u></h3>
<p><font size="3" face="Times New Roman">Using Microsoft’s StreamInsight platform for complex event processing, one can develop robust event-driven applications with high-performance and scalability. This post was meant to serve as an overview of the capabilities of the technology – and also provide a real-life example (querying IIS log files across a server farm) using StreamInsight.</font></p>
<h3><font size="3" face="Times New Roman">References : Raising Events from a PUSH Source</font></h3>
<p><a href="http://blogs.msdn.com/b/masimms/archive/2010/08/10/building-your-first-end-to-end-streaminsight-application.aspx"><font size="3" face="Times New Roman">http://blogs.msdn.com/b/masimms/archive/2010/08/10/building-your-first-end-to-end-streaminsight-application.aspx</font></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.anujvarma.com/getting-started-with-microsoft-streaminsight/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Recovering from a (baaaaaaad) tennis elbow</title>
		<link>http://www.anujvarma.com/recovering-from-a-baaaaaaad-tennis-elbow/</link>
		<comments>http://www.anujvarma.com/recovering-from-a-baaaaaaad-tennis-elbow/#comments</comments>
		<pubDate>Tue, 17 Apr 2012 05:07:30 +0000</pubDate>
		<dc:creator>Anuj Varma</dc:creator>
				<category><![CDATA[Diet, Health]]></category>
		<category><![CDATA[cure for tendonitis]]></category>
		<category><![CDATA[exercises for tennis elbow]]></category>
		<category><![CDATA[medicines for tennis elbow]]></category>
		<category><![CDATA[ointments tennis elbow]]></category>
		<category><![CDATA[quick recovery tennis elbow]]></category>
		<category><![CDATA[recovering tendonitis]]></category>
		<category><![CDATA[regaining strenght tendonitis]]></category>
		<category><![CDATA[stretching tennis elbow]]></category>
		<category><![CDATA[tennis elbow recovery]]></category>
		<category><![CDATA[tennis elbow rehab]]></category>

		<guid isPermaLink="false">http://www.anujvarma.com/recovering-from-a-baaaaaaad-tennis-elbow/</guid>
		<description><![CDATA[Tennis Elbow (severe) – is something I would not wish on anyone. It is one of the hardest things I have had to recover from. While the site of injury is obviously the elbow, the loss of strength one experiences &#8230; <a href="http://www.anujvarma.com/recovering-from-a-baaaaaaad-tennis-elbow/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Tennis Elbow (severe) – is something I would not wish on anyone. It is one of the hardest things I have had to recover from. While the site of injury is obviously the elbow, the loss of strength one experiences is throughout the hands and forearms. One may find it difficult to even open a door. In my case, I was unable to even type at a keyboard – or shake hands – or open doors. This complete ‘hand-strength’ loss baffled me at first. After all – it was my <em>elbow</em>&nbsp; &#8211; not my hands that were injured. Nevertheless, as a little research will uncover, tennis elbow causes complete loss of strength in various parts of the hands, shoulders and arms.</p>
<p>This was the second time I got tennis elbow. The first time, like others out there – I tried everything from physiotherapy to miracle ointments to pain killers – and learnt the hard way what works and what doesn’t. The first time – it took me 6 months – including LOTS of physiotherapy to get over it. The second time, it took me less than 3 weeks – and zero physiotherapy. I just knew what exercises to do – and what things to avoid. This article summarizes everything I did during those 2-3 weeks – and also everything that I continue to do on a preventative basis. </p>
<h3>Intuitive Recovery Time</h3>
<p>At an intuitive level, when one is unable to even pick up small objects (or open doors), one feels that one may never recover (or at least, that it is going be a super slow process). This is exactly how I felt.</p>
<h3>Actual Recovery Time</h3>
<p>I was able to work on my computer within a week – and actually made a full recovery in less than 3 weeks – but I had to do a LOT of things right. Had I not done any of these things, I doubt if my recovery would be as quick. </p>
<h3>Step 1 – Think that you have the flu (Limit your movements)</h3>
<p>When you are down with something bad – like the flu – do you think about going to work? Or sitting on your computer? Or doing anything except lying down? Well – that is how you must treat your tennis elbow. Except – you do not have to be bed confined. But you do have to limit your movements – especially movements that involve your hands. I cut down on my driving – and only drove short distances (that too with elbow braces (see below) always around my forearms). Goes without saying that – tennis, golf etc. are all taboo. Lifting anything remotely heavy is out of the question. You have a serious ailment – and you need to treat it as such. This is one of those obstinate things that will just not go away if you do not give it complete rest (see step 2 below).</p>
<h3>Step 2 – Wear an elbow brace 24/7 (except while sleeping)</h3>
<p>My orthopedic explained the importance of this brace. Anything that you do with your hands – is connected to the same, common tendons in your elbow. This is why even a small action such as opening a door – hurts like hell. The idea is to arrest all hand motion from reaching the elbow – and the brace helps do just that. Without it – your elbow never really gets rested – and even the slightest hand motion keeps injuring it further.</p>
<p>These braces need to be worn even after your elbow starts improving. For a period of at least 6 months. Let the brace become part of your fashion statement – don’t worry about how it looks or whether it feels warm etc. Just wear it – otherwise chances are you will end up with a relapse (in my case, I believe this WAS a cause of the relapse – I started feeling better – and started doing things without the brace. Bad idea – just wear the brace at all times).</p>
<ol>
<li>Imak Elbow Band</li>
</ol>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:7dc1bd33-94bd-46fd-a20b-0131235bcd47:ebd2e186-af73-428b-bd35-2adb2381f431" class="wlWriterEditableSmartContent">
<table cellspacing="0" cellpadding="2" width="400" border="0" unselectable="on">
<tbody>
<tr>
<td valign="top" width="400">
<p><a title="Imak Elbow Band: Health &amp; Personal Care" href="http://www.amazon.com/exec/obidos/ASIN/B0014WXF8M/portallycom"><img src="http://images.amazon.com/images/P/B0014WXF8M.01.MZZZZZZZ.jpg" border="0" align="left" style="float:left">Imak Elbow Band: Health &amp; Personal Care</a></p>
<p><b>ASIN</b>: B0014WXF8M</p>
</td>
</tr>
</tbody>
</table>
</div>
<p>2. Medspec Tennis Elbow Support</p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:7dc1bd33-94bd-46fd-a20b-0131235bcd47:654ff517-02e3-46e2-8b2e-bfbf885d483a" class="wlWriterEditableSmartContent">
<table cellspacing="0" cellpadding="2" width="400" border="0" unselectable="on">
<tbody>
<tr>
<td valign="top" width="400">
<p><a title="MedSpec EpiGel Tennis Elbow Support: Health &amp; Personal Care" href="http://www.amazon.com/exec/obidos/ASIN/B002SIQH7W/portallycom"><img src="http://images.amazon.com/images/P/B002SIQH7W.01.MZZZZZZZ.jpg" border="0" align="left" style="float:left">MedSpec EpiGel Tennis Elbow Support: Health &amp; Personal Care</a></p>
<p><b>ASIN</b>: B002SIQH7W</p>
</td>
</tr>
</tbody>
</table>
</div>
<p>If you can afford to put your affected arm in a sling – do so. That is the ultimate rest for the elbow.</p>
<h3>Step 3 – Do Forearm/Elbow stretching exercises – ALL DAY LONG</h3>
<p>If you want your elbows, hands and forearms to get strong – you must do a specific set of exercises. And do these as often as you can. The three sets of exercises that I did religiously included:</p>
<ol>
<li><strong>Resistance Band (Stretch Band) Exercises</strong> – This was recommended to me by a top physiotherapist (this guy treats some of the top athletes – tennis players, soccer players etc.).&nbsp; Just tie one end to a staircase knob or any other solid support – and grasp the other end in your affected hand. </li>
</ol>
<blockquote><p>Stretch 1 – Straight Back elbow stretches – holding your end of the band at about belly-button height. Stretch it straight back – so your elbow moves past your hip &#8211; and hold for at least 10 seconds. Keep increasing the time you can hold it. </p>
</blockquote>
<blockquote><p>Stretch 2 – Diagonally across elbow stretches. Hold your end again at belly button height. Now try and stretch it diagonally across your chest towards your opposite shoulder (if you are holding it in your right hand – move towards your left shoulder). </p>
</blockquote>
<p>How often should you do them? At a minimum – twice a day – but as often as you can is ok. My physiotherapist (who taught me these stretching exercise) – said you cannot do enough of these. </p>
<p>&nbsp;</p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:7dc1bd33-94bd-46fd-a20b-0131235bcd47:21119803-9886-4730-b236-72722da196fc" class="wlWriterEditableSmartContent">
<table cellspacing="0" cellpadding="2" width="400" border="0" unselectable="on">
<tbody>
<tr>
<td valign="top" width="400">
<p><a title="Valeo Stretch Bands: Sports &amp; Outdoors" href="http://www.amazon.com/exec/obidos/ASIN/B0007IS714/portallycom"><img src="http://images.amazon.com/images/P/B0007IS714.01.MZZZZZZZ.jpg" border="0" align="left" style="float:left">Valeo Stretch Bands: Sports &amp; Outdoors</a></p>
<p><b>ASIN</b>: B0007IS714</p>
</td>
</tr>
</tbody>
</table>
</div>
<p>2.&nbsp; <strong>Theraband Twisting</strong> – This was something I tried on my own (as opposed to the resistance band which my physiotherapist recommended). The theraband comes in various ‘flexes’ – I got the ‘light’ – and that was good enough. I have heard the medium can be a little hard for seriously affected elbows. There are several youtube videos on tennis elbow theraband exercises.</p>
<p>How often should you do them? At a minimum – twice a day – but I did these more than twice – based on the advice of my physio about the stretch band exercises. </p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:7dc1bd33-94bd-46fd-a20b-0131235bcd47:eab599de-abee-41e1-b51b-d46c2af7fe2c" class="wlWriterEditableSmartContent">
<table cellspacing="0" cellpadding="2" width="400" border="0" unselectable="on">
<tbody>
<tr>
<td valign="top" width="400">
<p><a title="Thera-Band Flex Bars - LIGHT - Red: Health &amp; Personal Care" href="http://www.amazon.com/exec/obidos/ASIN/B000WBK9QC/portallycom"><img src="http://images.amazon.com/images/P/B000WBK9QC.01.MZZZZZZZ.jpg" border="0" align="left" style="float:left">Thera-Band Flex Bars &#8211; LIGHT &#8211; Red: Health &amp; Personal Care</a></p>
<p><b>ASIN</b>: B000WBK9QC</p>
</td>
</tr>
</tbody>
</table>
</div>
<p>3.&nbsp;&nbsp; <strong>Tennis Ball Squeezing </strong></p>
<p>In an ironic twist, the thing that causes tennis elbow (tennis) – can also help in the recovery process. Just hold a regular tennis ball held in your palm – and squeeze it as hard as you can. Initially, you will find this to be difficult – since your hand will have very little strength. As you do this more and more – you will find your grip getting stronger. This is the simplest and one of the more effective exercises that I did. I carried that ball everywhere (I didn’t care if other lunch folks saw me squeezing a tennis ball while waiting for my food..). Again – like the rest of the exercises – there is no limit to how often you do this. As much as possible!</p>
<h3><strong>Exercises Summary</strong></h3>
<p>I am sure there are dozens of other recommended exercises (wrist flex with small weights, hold out your palm and flex it upwards/downwards). These are all worth doing – in addition to the ones above. The ones I have listed above (the stretch band exercises especially) – were shown to me by a really good physiotherapist (some famous sportspeople go this guy for their injuries). I take these exercises to be the most important of the lot. The theraband was something I tried on my own – and it seemed to help as well (it comes with its own instructions – but you can youtube theraband exercises for tennis elbow). </p>
<p>How often should you do them? At a minimum – twice a day – but as often as you can is ok. My physiotherapist (who taught me the stretching exercise) – said you cannot do enough of these. In case you are worried that you may be ‘over working’ an already inflamed elbow – you would be wrong. These stretches actually help the elbow recover. Something as simple as trying to squeeze a tennis ball builds hand strength and wrist strength. These exercises were the centerpiece of my recovery program – and I am convinced that without these – my recovery would have taken longer.</p>
<h3>Step 4 – Homeopathic medicines</h3>
<p>I grew up in India – and have seen these little pills work magic on all kinds of ailments. They work on a somewhat similar principle to vaccines – where you introduce a minute quantity of something that causes your body’s immune system to spring into action. The best thing about these medicines is that they have no side effects whatsoever.&nbsp; The specific items that I took for tennis elbow (on the recommendation of an excellent homeopathic doctor) were :</p>
<ol>
<li>Hypericum Perforatum 200 C </li>
</ol>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:7dc1bd33-94bd-46fd-a20b-0131235bcd47:68f99474-f1c2-40ec-afbe-ffd47a5fd082" class="wlWriterEditableSmartContent">
<table cellspacing="0" cellpadding="2" width="400" border="0" unselectable="on">
<tbody>
<tr>
<td valign="top" width="400">
<p><a title="Boiron Hypericum Perforatum 200C 75 pellets: Health &amp; Personal Care" href="http://www.amazon.com/exec/obidos/ASIN/B0006NXGF2/portallycom"><img src="http://images.amazon.com/images/P/B0006NXGF2.01.MZZZZZZZ.jpg" border="0" align="left" style="float:left">Boiron Hypericum Perforatum 200C 75 pellets: Health &amp; Personal Care</a></p>
<p><b>ASIN</b>: B0006NXGF2</p>
</td>
</tr>
</tbody>
</table>
</div>
<p>&nbsp; 2. Symphatum 200 C </p>
<p>&nbsp;</p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:7dc1bd33-94bd-46fd-a20b-0131235bcd47:267bd209-491a-43f4-b407-1c11c426670b" class="wlWriterEditableSmartContent">
<table cellspacing="0" cellpadding="2" width="400" border="0" unselectable="on">
<tbody>
<tr>
<td valign="top" width="400">
<p><a title="Boiron Symphytum Officinale 200C 75 pellets: Health &amp; Personal Care" href="http://www.amazon.com/exec/obidos/ASIN/B0006NXGQ6/portallycom"><img src="http://images.amazon.com/images/P/B0006NXGQ6.01.MZZZZZZZ.jpg" border="0" align="left" style="float:left">Boiron Symphytum Officinale 200C 75 pellets: Health &amp; Personal Care</a></p>
<p><b>ASIN</b>: B0006NXGQ6</p>
</td>
</tr>
</tbody>
</table>
</div>
<p>&nbsp;</p>
<p>Alternate these two medicines every 3 hours. Within a week you should see some relief. Continue taking these for a total of 3 weeks. (These are easily available at whole foods or other natural grocery stores – as well as online).</p>
<h3>Step 5 – Change your keyboard, mouse</h3>
<p>Tennis elbow is caused by repetitive stress. Computer typing is one of the most common forms of this type of stress. In my case, it was at least partly responsible for my tennis elbow (besides actual tennis and golf). Once you have regained some strength – consider getting a keyboard and mouse that is as ‘soft’ as possible. </p>
<p>The keyboard I settled on (after trying a lot of them) – is the <a href="http://www.amazon.com/gp/product/B005HNHRA6/ref=oh_o02_s00_i00_details">HP Elite Keyboard</a>.</p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:7dc1bd33-94bd-46fd-a20b-0131235bcd47:7e5fedb7-6277-4c53-a51f-c614a2582b49" class="wlWriterEditableSmartContent">
<table cellspacing="0" cellpadding="2" width="400" border="0" unselectable="on">
<tbody>
<tr>
<td valign="top" width="400">
<p><a title="HP Wireless Elite Keyboard V2: Electronics" href="http://www.amazon.com/exec/obidos/ASIN/B005HNHRA6/portallycom"><img src="http://images.amazon.com/images/P/B005HNHRA6.01.MZZZZZZZ.jpg" border="0" align="left" style="float:left">HP Wireless Elite Keyboard V2: Electronics</a></p>
<p><b>ASIN</b>: B005HNHRA6</p>
</td>
</tr>
</tbody>
</table>
</div>
<p>The mouse I settled on was the <a type="amzn"></a>Microsoft Arc Touch Mouse</a>.</p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:7dc1bd33-94bd-46fd-a20b-0131235bcd47:06df9ce2-688a-401c-a433-f06c9e159dd6" class="wlWriterEditableSmartContent">
<table cellspacing="0" cellpadding="2" width="400" border="0" unselectable="on">
<tbody>
<tr>
<td valign="top" width="400">
<p><a title="Microsoft Arc Touch Mouse (Black): Electronics" href="http://www.amazon.com/exec/obidos/ASIN/B003UT6C9G/portallycom"><img src="http://images.amazon.com/images/P/B003UT6C9G.01.MZZZZZZZ.jpg" border="0" align="left" style="float:left">Microsoft Arc Touch Mouse (Black): Electronics</a></p>
<p><b>ASIN</b>: B003UT6C9G</p>
</td>
</tr>
</tbody>
</table>
</div>
<p>They both continue to serve me well – and are very soft to the touch.</p>
<p>&nbsp;</p>
<h3>Things that did not work</h3>
<p>Thanks to the internet, I got to try virtually every “miracle-cure” that my friend, Google could suggest. I was desperate to get better fast – and while I did eventually get better, I learnt a lot about what worked for me and what did not.</p>
<ol>
<li>Ointments, Penetrex etc. – Penetrex is the highest rated product on amazon.com for treating tennis elbow. I must have rubbed four jars full. Did not make the slightest difference as far as I could tell. Not saying it does not work for others – just did not work for me. Also – as an alternative, I tried <strong>Capsaicin</strong> – WHICH ACTUALLY HELPED. It is the only ointment/topical pain reliever that made the slightest bit of difference. I would apply it at least twice a day on both my elbows. Be sure to start with a small concentration (0.035) – this small dosage burnt a bit – so I can only imagine how much the 0.1 (high potency) would burn. Good news is that I found the small concentration (0.035) to be very effective – so did not have to try the higher concentration.</li>
</ol>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:7dc1bd33-94bd-46fd-a20b-0131235bcd47:11475404-7ef9-4016-bfcf-76041a201890" class="wlWriterEditableSmartContent">
<table cellspacing="0" cellpadding="2" width="400" border="0" unselectable="on">
<tbody>
<tr>
<td valign="top" width="400">
<p><a title="Capzasin-P Topical Analgesic Cream, .035-Percent Capsaicin, 1.5-Ounce Tubes (Pack of 3): Health &amp; Personal Care" href="http://www.amazon.com/exec/obidos/ASIN/B001G7QGC2/portallycom"><img src="http://images.amazon.com/images/P/B001G7QGC2.01.MZZZZZZZ.jpg" border="0" align="left" style="float:left">Capzasin-P Topical Analgesic Cream, .035-Percent Capsaicin, 1.5-Ounce Tubes (Pack of 3): Health &amp; Personal Care</a></p>
<p><b>ASIN</b>: B001G7QGC2</p>
</td>
</tr>
</tbody>
</table>
</div>
<p>&nbsp;&nbsp; 2. Advil, Tylenol etc. – These had the least effect in terms of actually helping the tennis elbow. They may mask the pain temporarily – but this can be a bad thing – since you start ‘doing more’ with your arms – leading to further aggravation of the condition. I stopped taking all pain killers (and stuck to the homeopathic medicines above – which have no side effects). </p>
<p>&nbsp;&nbsp; 3.&nbsp; Prolotherapy – There is a lot of discussion about the effectiveness of this for tennis elbow. I tried it – it did not work. This was the most expensive thing I tried (cost $500) – but it did nothing to relieve my pain.</p>
<h3>Long Term &#8211; Continued Prevention</h3>
<p>Steps 2 (wearing elbow braces),&nbsp; 3 (stretching exercises) – and 5 (use softer keyboards, mice) – are a must on an ongoing basis – if you want to avoid a relapse of the condition. </p>
<h3>Summary</h3>
<p>As I mentioned before, everyone’s experience of what works and what doesn’t may differ. This is just my own experience. Having suffered from tennis elbow TWICE (in quick succession) – and having tried everything from ointments, pills, lots of physiotherapy, prolotherapy, home exercises to homeopathic medicine, I have learnt what works for me. If you are suffering from this serious condition, I feel for you – and wish you a quick recovery. Hopefully, something from this post would be helpful to you.&nbsp; While I have listed these sequentially (Step 1….6), obviously, they all need to be done in parallel. Each step is an important part of the recovery process – and trust me, if you take this condition lightly, it WILL get the better of you.</p>
<p>Here is a quick recap of the ‘goodie bag’ (of things that worked).</p>
<table border="0" cellspacing="0" cellpadding="2" width="557">
<tbody>
<tr>
<td valign="top" width="200">
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:7dc1bd33-94bd-46fd-a20b-0131235bcd47:51734eda-ecf6-40f0-90d2-56b22435531f" class="wlWriterEditableSmartContent">
<table cellspacing="0" cellpadding="2" width="400" border="0" unselectable="on">
<tbody>
<tr>
<td valign="top" width="400">
<p><a title="Imak Elbow Band: Health &amp; Personal Care" href="http://www.amazon.com/exec/obidos/ASIN/B0014WXF8M/portallycom"><img src="http://images.amazon.com/images/P/B0014WXF8M.01.MZZZZZZZ.jpg" border="0" align="left" style="float:left">Imak Elbow Band: Health &amp; Personal Care</a></p>
<p><b>ASIN</b>: B0014WXF8M</p>
</td>
</tr>
</tbody>
</table>
</div>
</td>
<td valign="top" width="355">Continue to wear throughout the day&nbsp; &#8211; even after your elbow starts to recover. Wear for 6 months (advice of my ortho and my physiotherapist).</td>
</tr>
<tr>
<td valign="top" width="200">
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:7dc1bd33-94bd-46fd-a20b-0131235bcd47:01a47379-6c27-4ad2-a89e-2acc291b156d" class="wlWriterEditableSmartContent">
<table cellspacing="0" cellpadding="2" width="400" border="0" unselectable="on">
<tbody>
<tr>
<td valign="top" width="400">
<p><a title="Valeo Stretch Bands: Sports &amp; Outdoors" href="http://www.amazon.com/exec/obidos/ASIN/B0007IS714/portallycom"><img src="http://images.amazon.com/images/P/B0007IS714.01.MZZZZZZZ.jpg" border="0" align="left" style="float:left">Valeo Stretch Bands: Sports &amp; Outdoors</a></p>
<p><b>ASIN</b>: B0007IS714</p>
</td>
</tr>
</tbody>
</table>
</div>
</td>
<td valign="top" width="355">Do the ‘straight back’ and ‘diagonally across’ stretches every day – as often as you can (minimum twice a day). Continue doing even after your elbow recovers.</td>
</tr>
<tr>
<td valign="top" width="200">
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:7dc1bd33-94bd-46fd-a20b-0131235bcd47:6c8c7d5e-273a-4a25-bf4a-9726813a6ad4" class="wlWriterEditableSmartContent">
<table cellspacing="0" cellpadding="2" width="400" border="0" unselectable="on">
<tbody>
<tr>
<td valign="top" width="400">
<p><a title="Capzasin-P Topical Analgesic Cream, .035-Percent Capsaicin, 1.5-Ounce Tubes (Pack of 3): Health &amp; Personal Care" href="http://www.amazon.com/exec/obidos/ASIN/B001G7QGC2/portallycom"><img src="http://images.amazon.com/images/P/B001G7QGC2.01.MZZZZZZZ.jpg" border="0" align="left" style="float:left">Capzasin-P Topical Analgesic Cream, .035-Percent Capsaicin, 1.5-Ounce Tubes (Pack of 3): Health &amp; Personal Care</a></p>
<p><b>ASIN</b>: B001G7QGC2</p>
</td>
</tr>
</tbody>
</table>
</div>
</td>
<td valign="top" width="355">Apply over the sensitive elbow – at least twice a day – or whenever the pain gets bad. Use the low concentration – 0.035 – to begin with. This worked for me.</td>
</tr>
<tr>
<td valign="top" width="200">
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:7dc1bd33-94bd-46fd-a20b-0131235bcd47:24067887-c186-451e-b25d-42ac9b7a43b7" class="wlWriterEditableSmartContent">
<table cellspacing="0" cellpadding="2" width="400" border="0" unselectable="on">
<tbody>
<tr>
<td valign="top" width="400">
<p><a title="Boiron Hypericum Perforatum 200C 75 pellets: Health &amp; Personal Care" href="http://www.amazon.com/exec/obidos/ASIN/B0006NXGF2/portallycom"><img src="http://images.amazon.com/images/P/B0006NXGF2.01.MZZZZZZZ.jpg" border="0" align="left" style="float:left">Boiron Hypericum Perforatum 200C 75 pellets: Health &amp; Personal Care</a></p>
<p><b>ASIN</b>: B0006NXGF2</p>
</td>
</tr>
</tbody>
</table>
</div>
</td>
<td valign="top" width="355">Take this medicine and the one below – alternating every three hours. 5 pellets each is the dosage on each dose (but read your particular bottle to double-check).</td>
</tr>
<tr>
<td valign="top" width="200">
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:7dc1bd33-94bd-46fd-a20b-0131235bcd47:4946053a-f4f3-49f5-b56f-51cf797a3dcb" class="wlWriterEditableSmartContent">
<table cellspacing="0" cellpadding="2" width="400" border="0" unselectable="on">
<tbody>
<tr>
<td valign="top" width="400">
<p><a title="Boiron Symphytum Officinale 200C 75 pellets: Health &amp; Personal Care" href="http://www.amazon.com/exec/obidos/ASIN/B0006NXGQ6/portallycom"><img src="http://images.amazon.com/images/P/B0006NXGQ6.01.MZZZZZZZ.jpg" border="0" align="left" style="float:left">Boiron Symphytum Officinale 200C 75 pellets: Health &amp; Personal Care</a></p>
<p><b>ASIN</b>: B0006NXGQ6</p>
</td>
</tr>
</tbody>
</table>
</div>
</td>
<td valign="top" width="355">&nbsp;</td>
</tr>
<tr>
<td valign="top" width="200">
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:7dc1bd33-94bd-46fd-a20b-0131235bcd47:bacfc8b0-8d10-4264-bbf0-d71b5f7a2fb0" class="wlWriterEditableSmartContent">
<table cellspacing="0" cellpadding="2" width="400" border="0" unselectable="on">
<tbody>
<tr>
<td valign="top" width="400">
<p><a title="Microsoft Arc Touch Mouse (Black): Electronics" href="http://www.amazon.com/exec/obidos/ASIN/B003UT6C9G/portallycom"><img src="http://images.amazon.com/images/P/B003UT6C9G.01.MZZZZZZZ.jpg" border="0" align="left" style="float:left">Microsoft Arc Touch Mouse (Black): Electronics</a></p>
<p><b>ASIN</b>: B003UT6C9G</p>
</td>
</tr>
</tbody>
</table>
</div>
</td>
<td valign="top" width="355">Get rid of your old mouse – and use this or something similar which has soft touch – and touch based scrolling.</td>
</tr>
<tr>
<td valign="top" width="200">
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:7dc1bd33-94bd-46fd-a20b-0131235bcd47:0fc05302-01e7-408e-80ee-02b40c02250e" class="wlWriterEditableSmartContent">
<table cellspacing="0" cellpadding="2" width="400" border="0" unselectable="on">
<tbody>
<tr>
<td valign="top" width="400">
<p><a title="HP Wireless Elite Keyboard V2: Electronics" href="http://www.amazon.com/exec/obidos/ASIN/B005HNHRA6/portallycom"><img src="http://images.amazon.com/images/P/B005HNHRA6.01.MZZZZZZZ.jpg" border="0" align="left" style="float:left">HP Wireless Elite Keyboard V2: Electronics</a></p>
<p><b>ASIN</b>: B005HNHRA6</p>
</td>
</tr>
</tbody>
</table>
</div>
</td>
<td valign="top" width="355">This is the softest ever keyboard – apart from having a touchscreen (like the Ipad) this is the least strain on my typing fingers.</td>
</tr>
<tr>
<td valign="top" width="200"><a href="http://www.anujvarma.com/wp-content/uploads/tennisball.jpg"><img style="background-image: none; border-right-width: 0px; margin: 0px 10px 5px 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="tennisball" border="0" alt="tennisball" src="http://www.anujvarma.com/wp-content/uploads/tennisball_thumb.jpg" width="113" height="114"></a></td>
<td valign="top" width="355">Hold this in your palm – and squeeze as hard as you can. Slowly, as you regain strength, you will be able to squeeze harder.</td>
</tr>
</tbody>
</table>
]]></content:encoded>
			<wfw:commentRss>http://www.anujvarma.com/recovering-from-a-baaaaaaad-tennis-elbow/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Yoga–swing thoughts</title>
		<link>http://www.anujvarma.com/yogaswing-thoughts/</link>
		<comments>http://www.anujvarma.com/yogaswing-thoughts/#comments</comments>
		<pubDate>Tue, 17 Apr 2012 02:42:21 +0000</pubDate>
		<dc:creator>Anuj Varma</dc:creator>
				<category><![CDATA[Diet, Health]]></category>
		<category><![CDATA[maximum yoga]]></category>
		<category><![CDATA[strong yoga]]></category>
		<category><![CDATA[yoga and strength]]></category>
		<category><![CDATA[yoga intention]]></category>
		<category><![CDATA[yoga practice]]></category>
		<category><![CDATA[yoga thought]]></category>

		<guid isPermaLink="false">http://www.anujvarma.com/yogaswing-thoughts/</guid>
		<description><![CDATA[When you step out on the golf course, generally you take with you – a swing thought or two. All golfers know what I am talking about – it is essentially a certain physical or mental state that you would &#8230; <a href="http://www.anujvarma.com/yogaswing-thoughts/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>When you step out on the golf course, generally you take with you – a <em>swing thought </em>or two. All golfers know what I am talking about – it is essentially a certain physical or mental state that you would like to maintain for your entire round (18 holes). If, like me, you are a golf hacker, chances are you have experimented with various different swing thoughts.&nbsp; One of my favorite golf books is a compilation of such thoughts – used by professional golfers. What better swing thoughts to experiment with?</p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:7dc1bd33-94bd-46fd-a20b-0131235bcd47:3a719fe7-8cc4-4e38-a859-a3f686f12d09" class="wlWriterEditableSmartContent">
<table cellspacing="0" cellpadding="2" width="400" border="0" unselectable="on">
<tbody>
<tr>
<td valign="top" width="400">
<p><a title="Swing thoughts :the world&#39;s greatest golfers share their keys to mastering the game: Don Wade: Books" href="http://www.amazon.com/exec/obidos/ASIN/B001VUST4M/portallycom"><img src="http://images.amazon.com/images/P/B001VUST4M.01.MZZZZZZZ.jpg" border="0" align="left" style="float:left">Swing thoughts :the world&#39;s greatest golfers share their keys to mastering the game: Don Wade: Books</a></p>
<p><b>ASIN</b>: B001VUST4M</p>
</td>
</tr>
</tbody>
</table>
</div>
<h3>What does this have to do with Yoga?</h3>
<p>Too often, we just show up on our mat – without really having a ‘purpose’. We figure – this is an <em>instructor led </em>session – I’ll let the instructor do the leading. And we go through the motions, However, I believe that to get the most of a session, one needs to come into each session with a mindset- analogous to a golf swing thought. </p>
<p>This mindset is referred to (by one of my yoga instructors) as your ‘intention’. Figure out what your <em>intention </em>is before you get on your mat. </p>
<p>Two swing thoughts (intentions) that have worked for me:</p>
<ul>
<li><strong><u>Strong with breath –</u></strong> I like to think of myself as growing strong with each breath I take.&nbsp; I try to ‘feel strong’ even though it may not start out that way. As I keep telling myself ‘I am strong’ – I realize that I am able to hold the poses longer – and with more resolve. This is a great thought&nbsp; &#8211; and works well for most yoga sessions (except ones where I am really out of it – and feeling somewhat weak).
<li><strong><u>Entire body as one connected block (e.g. slab of wood)</u></strong> – This is a curious swing thought – and one that works well when it does. What happens is that as I stretch different parts of my body, I realize that I am just moving those parts – independent of the rest of the body. The waist may be twisting – but my hips and legs are not involved. Then – I start visualizing my entire body as one continuous slab of wood. This helps me realize the ‘connectedness’ of every part of the body.&nbsp; NOW – each stretch I do – involves the entire body – moving as one piece. This helps me feel stronger through the practice.</li>
</ul>
<p>Hope those two thoughts (or any of them) work for you. If you have a favorite thought that you take into your yoga practice session, please do share it via comments on this post.</p>
<p><strong>Namaste!</strong></p>
]]></content:encoded>
			<wfw:commentRss>http://www.anujvarma.com/yogaswing-thoughts/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>New interfaces for implementing Publish-Subscribe in .NET</title>
		<link>http://www.anujvarma.com/new-interfaces-for-implementing-publish-subscribe-in-net/</link>
		<comments>http://www.anujvarma.com/new-interfaces-for-implementing-publish-subscribe-in-net/#comments</comments>
		<pubDate>Tue, 10 Apr 2012 04:36:14 +0000</pubDate>
		<dc:creator>Anuj Varma</dc:creator>
				<category><![CDATA[C# 4.0]]></category>
		<category><![CDATA[.net iobserve]]></category>
		<category><![CDATA[.net iobserver]]></category>
		<category><![CDATA[.net observer]]></category>
		<category><![CDATA[.net subscriber]]></category>
		<category><![CDATA[observer pattern]]></category>
		<category><![CDATA[publish subscribe c#]]></category>
		<category><![CDATA[publish subscribe pattern]]></category>

		<guid isPermaLink="false">http://www.anujvarma.com/?p=1226</guid>
		<description><![CDATA[You know you are a techie at heart if you find yourself getting excited at the introduction of a couple of new interfaces.
.NET 4.0 introduces IObservable (Publisher) and IObserver (Subscriber). These interfaces were long overdue – for a couple of &#8230; <a href="http://www.anujvarma.com/new-interfaces-for-implementing-publish-subscribe-in-net/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>You know you are a techie at heart if you find yourself getting excited at the introduction of a couple of new interfaces.</p>
<p>.NET 4.0 introduces <em>IObservable (Publisher)</em><t> and <em>IObserver (Subscriber)</em><t>. These interfaces were long overdue – for a couple of reasons:</p>
<ol>
<li>The ubiquitous nature of the <em>Publish Subscribe </em>pattern. </li>
<li>The cludgeability of implementing these using events and delegates. Prior to these, one had to build a <a href="http://www.dotnetarchitecthouston.com/post/The-Publish-Subscribe-Pattern-in-C-and-some-gotchas.aspx">publish subscribe solution</a> using events and delegates. This came with its own set of <a href="http://www.dotnetarchitecthouston.com/post/The-Publish-Subscribe-Pattern-in-C-and-some-gotchas.aspx">gotchas</a>.</li>
<li>Even a <a href="http://www.anujvarma.com/series/wcf-publish-subscribe-c/" target="_blank">WCF Publish Subscribe</a>&nbsp; implementation could not get away from explicitly publishing ( using events ) and subscribing ( using event handlers)</li>
</ol>
<p>And while these new interfaces will not save you the effort of an actual implementation, they provide a standard template for implementing the publish subscribe pattern in .NET. This article provides: </p>
<ol>
<li>A simple, starting implementation of these two interfaces. </li>
<li>As a second step, to illustrate a real-world usage of the sample implementation, a <em>MagazinePublisher </em>class is defined. This class maintains a list of all magazine subscribers – and notifies them whenever a new issue is available.</li>
</ol>
<p>This sample application (full source code available below) can be used as a starting point for any publish subscribe application.</p>
<h3>The &#8216;Publisher&#8217; Interface </h3>
<p>1. In these new interfaces, the <i>Publisher</i> goes by the name <i>Observable</i>. <br />2. Two primary responsibilities of the Publisher are:</p>
<blockquote><p>a) Subscription and Unsubscription (Adding and Removing subscribers) </p>
<p>b) Notification (of all subscribers)</p>
</blockquote>
<h3>Subscription and Unsubscription</h3>
<p>The implementation of IObservable(T) contains a <i>subscribe</i> method &#8211; which returns an instance of the RemoveMe class (which implements the IDisposable interface). This ensures that subscribers can call Dispose() when they are ready to unsubscribe.</p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:a7b4856e-f02f-465d-a1f4-38d94019270a" class="wlWriterEditableSmartContent">
<div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt">
<div style="background: #000080; color: #fff; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px">Code Snippet</div>
<div style="background: #ddd; max-height: 300px; overflow: auto">
<ol style="background: #ffffff; margin: 0 0 0 2.5em; padding: 0 0 0 5px;">
<li><span style="background:#ffffff;color:#000000"> </span><span style="background:#ffffff;color:#0000ff">public</span><span style="background:#ffffff;color:#000000"> </span><span style="background:#ffffff;color:#2b91af">IDisposable</span><span style="background:#ffffff;color:#000000"> Subscribe(</span><span style="background:#ffffff;color:#2b91af">IObserver</span><span style="background:#ffffff;color:#000000">&lt;T&gt; observer)</span></li>
<li style="background: #f3f3f3">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<span style="background:#ffffff;color:#000000">{</span></li>
<li>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">if</span><span style="background:#ffffff;color:#000000"> (!observers.Contains(observer))</span></li>
<li style="background: #f3f3f3">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<span style="background:#ffffff;color:#000000">{</span></li>
<li>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<span style="background:#ffffff;color:#000000">observers.Add(observer);</span></li>
<li style="background: #f3f3f3">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<span style="background:#ffffff;color:#000000">}</span></li>
<li>&nbsp;</li>
<li style="background: #f3f3f3">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">return</span><span style="background:#ffffff;color:#000000"> </span><span style="background:#ffffff;color:#0000ff">new</span><span style="background:#ffffff;color:#000000"> </span><span style="background:#ffffff;color:#2b91af">RemoveMe</span><span style="background:#ffffff;color:#000000">(observers, observer);</span></li>
<li>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<span style="background:#ffffff;color:#000000">}</span></li>
<li style="background: #f3f3f3">&nbsp;</li>
<li>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">private</span><span style="background:#ffffff;color:#000000"> </span><span style="background:#ffffff;color:#0000ff">class</span><span style="background:#ffffff;color:#000000"> </span><span style="background:#ffffff;color:#2b91af">RemoveMe</span><span style="background:#ffffff;color:#000000"> : </span><span style="background:#ffffff;color:#2b91af">IDisposable</span></li>
<li style="background: #f3f3f3">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<span style="background:#ffffff;color:#000000">{</span></li>
<li>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">private</span><span style="background:#ffffff;color:#000000"> </span><span style="background:#ffffff;color:#2b91af">List</span><span style="background:#ffffff;color:#000000">&lt;</span><span style="background:#ffffff;color:#2b91af">IObserver</span><span style="background:#ffffff;color:#000000">&lt;T&gt;&gt; observers;</span></li>
<li style="background: #f3f3f3">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">private</span><span style="background:#ffffff;color:#000000"> </span><span style="background:#ffffff;color:#2b91af">IObserver</span><span style="background:#ffffff;color:#000000">&lt;T&gt; observer;</span></li>
<li>&nbsp;</li>
<li style="background: #f3f3f3">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">public</span><span style="background:#ffffff;color:#000000"> RemoveMe(</span><span style="background:#ffffff;color:#2b91af">List</span><span style="background:#ffffff;color:#000000">&lt;</span><span style="background:#ffffff;color:#2b91af">IObserver</span><span style="background:#ffffff;color:#000000">&lt;T&gt;&gt; observers, </span><span style="background:#ffffff;color:#2b91af">IObserver</span><span style="background:#ffffff;color:#000000">&lt;T&gt; observer)</span></li>
<li>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<span style="background:#ffffff;color:#000000">{</span></li>
<li style="background: #f3f3f3">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">this</span><span style="background:#ffffff;color:#000000">.observers = observers;</span></li>
<li>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">this</span><span style="background:#ffffff;color:#000000">.observer = observer;</span></li>
<li style="background: #f3f3f3">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<span style="background:#ffffff;color:#000000">}</span></li>
<li>&nbsp;</li>
<li style="background: #f3f3f3">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">public</span><span style="background:#ffffff;color:#000000"> </span><span style="background:#ffffff;color:#0000ff">void</span><span style="background:#ffffff;color:#000000"> Dispose()</span></li>
<li>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<span style="background:#ffffff;color:#000000">{</span></li>
<li style="background: #f3f3f3">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">if</span><span style="background:#ffffff;color:#000000"> (observer != </span><span style="background:#ffffff;color:#0000ff">null</span><span style="background:#ffffff;color:#000000"> &amp;&amp; observers.Contains(observer))</span></li>
<li>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<span style="background:#ffffff;color:#000000">{</span></li>
<li style="background: #f3f3f3">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<span style="background:#ffffff;color:#000000">observers.Remove(observer);</span></li>
<li>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<span style="background:#ffffff;color:#000000">}</span></li>
<li style="background: #f3f3f3">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<span style="background:#ffffff;color:#000000">}</span></li>
<li>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<span style="background:#ffffff;color:#000000">}</span></li>
</ol></div>
</p></div>
</p></div>
<h3>Notification</h3>
<p><i>Notify</i> can be called to notify all observers that there are changes in the observed object.</p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:93f16294-3b84-4670-8812-142426da5caf" class="wlWriterEditableSmartContent">
<div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt">
<div style="background: #000080; color: #fff; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px">Code Snippet</div>
<div style="background: #ddd; max-height: 300px; overflow: auto">
<ol style="background: #ffffff; margin: 0 0 0 2em; padding: 0 0 0 5px;">
<li><span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">protected</span><span style="background:#ffffff;color:#000000"> </span><span style="background:#ffffff;color:#0000ff">void</span><span style="background:#ffffff;color:#000000"> Notify(T obj)</span></li>
<li style="background: #f3f3f3">&#160;&#160;&#160;&#160;&#160;&#160;<span style="background:#ffffff;color:#000000">{</span></li>
<li>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">foreach</span><span style="background:#ffffff;color:#000000"> (</span><span style="background:#ffffff;color:#2b91af">IObserver</span><span style="background:#ffffff;color:#000000">&lt;T&gt; observer </span><span style="background:#ffffff;color:#0000ff">in</span><span style="background:#ffffff;color:#000000"> observers)</span></li>
<li style="background: #f3f3f3">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<span style="background:#ffffff;color:#000000">{</span></li>
<li>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<span style="background:#ffffff;color:#000000">observer.OnNext(obj);</span></li>
<li style="background: #f3f3f3">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<span style="background:#ffffff;color:#000000">}</span></li>
<li>&#160;&#160;&#160;&#160;&#160;&#160;<span style="background:#ffffff;color:#000000">}</span></li>
</ol></div>
</p></div>
</p></div>
<h3>The Subscriber</h3>
<p>Now that we have successfully described the two main responsibilities of the <em>Publisher, </em>we are ready to look at a sample <em>Subscriber. </em>The only thing a Subscriber needs to do is implement the <em>IObserver&lt;T&gt; </em>interface – using the <em>Publisher </em>as the type T that it is <em>observing. </em>This is a particular simple approach – even though it somewhat couples the subscriber to a specific publisher type. </p>
<p>Since the Publisher instance is passed in to the OnNext method, it is easy to retrieve all Publisher specific info in the subscriber. This example shows a subscriber getting notified of a new issue – and printing out the month of the issue. </p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:632f4b8f-738f-4680-86ca-98bfc950e2df" class="wlWriterEditableSmartContent">
<div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt">
<div style="background: #000080; color: #fff; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px">Code Snippet</div>
<div style="background: #ddd; max-height: 300px; overflow: auto">
<ol style="background: #ffffff; margin: 0 0 0 2.5em; padding: 0 0 0 5px;">
<li><span style="background:#ffffff;color:#808080">///</span><span style="background:#ffffff;color:#008000"> </span><span style="background:#ffffff;color:#808080">&lt;summary&gt;</span></li>
<li style="background: #f3f3f3">&#160;&#160;&#160;&#160;<span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#808080">///</span><span style="background:#ffffff;color:#008000"> &#39;Real-World&#39; Subscriber &#8211; Notice that it takes the type parameter MagazinePublisher in the IObserver interface</span></li>
<li>&#160;&#160;&#160;&#160;<span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#808080">///</span><span style="background:#ffffff;color:#008000"> </span><span style="background:#ffffff;color:#808080">&lt;/summary&gt;</span></li>
<li style="background: #f3f3f3">&#160;&#160;&#160;&#160;<span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">class</span><span style="background:#ffffff;color:#000000"> </span><span style="background:#ffffff;color:#2b91af">Subscriber</span><span style="background:#ffffff;color:#000000"> : </span><span style="background:#ffffff;color:#2b91af">IObserver</span><span style="background:#ffffff;color:#000000">&lt;</span><span style="background:#ffffff;color:#2b91af">MagazinePublisher</span><span style="background:#ffffff;color:#000000">&gt;</span></li>
<li>&#160;&#160;&#160;&#160;<span style="background:#ffffff;color:#000000">{</span></li>
<li style="background: #f3f3f3">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">public</span><span style="background:#ffffff;color:#000000"> </span><span style="background:#ffffff;color:#0000ff">void</span><span style="background:#ffffff;color:#000000"> OnCompleted()</span></li>
<li>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<span style="background:#ffffff;color:#000000">{</span></li>
<li style="background: #f3f3f3">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#2b91af">Console</span><span style="background:#ffffff;color:#000000">.WriteLine(</span><span style="background:#ffffff;color:#800000">&quot;Unsubscribed&quot;</span><span style="background:#ffffff;color:#000000">);</span></li>
<li>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<span style="background:#ffffff;color:#000000">}</span></li>
<li style="background: #f3f3f3">&nbsp;</li>
<li>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">public</span><span style="background:#ffffff;color:#000000"> </span><span style="background:#ffffff;color:#0000ff">void</span><span style="background:#ffffff;color:#000000"> OnError(</span><span style="background:#ffffff;color:#2b91af">Exception</span><span style="background:#ffffff;color:#000000"> error)</span></li>
<li style="background: #f3f3f3">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<span style="background:#ffffff;color:#000000">{</span></li>
<li>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#2b91af">Console</span><span style="background:#ffffff;color:#000000">.WriteLine(</span><span style="background:#ffffff;color:#800000">&quot;Error&quot;</span><span style="background:#ffffff;color:#000000">);</span></li>
<li style="background: #f3f3f3">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<span style="background:#ffffff;color:#000000">}</span></li>
<li>&nbsp;</li>
<li style="background: #f3f3f3">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">public</span><span style="background:#ffffff;color:#000000"> </span><span style="background:#ffffff;color:#0000ff">void</span><span style="background:#ffffff;color:#000000"> OnNext(</span><span style="background:#ffffff;color:#2b91af">MagazinePublisher</span><span style="background:#ffffff;color:#000000"> mp)</span></li>
<li>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<span style="background:#ffffff;color:#000000">{</span></li>
<li style="background: #f3f3f3">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#2b91af">Console</span><span style="background:#ffffff;color:#000000">.WriteLine(</span><span style="background:#ffffff;color:#800000">&quot;New Issue: &quot;</span><span style="background:#ffffff;color:#000000"> + mp.NewIssue);</span></li>
<li>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<span style="background:#ffffff;color:#000000">}</span></li>
<li style="background: #f3f3f3">&#160;&#160;&#160;&#160;<span style="background:#ffffff;color:#000000">}</span></li>
</ol></div>
</p></div>
</p></div>
<h3>Tying the Subscriber to the Publisher</h3>
<p>This is the last step in our sample solution – now that we have both the Subscriber and the Publisher completely defined, we can use them in a simple program.</p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:3ac03c14-1966-4ab1-87d7-71bd3543443a" class="wlWriterEditableSmartContent">
<div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt">
<div style="background: #000080; color: #fff; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px">Code Snippet</div>
<div style="background: #ddd; max-height: 300px; overflow: auto">
<ol style="background: #ffffff; margin: 0 0 0 2.5em; padding: 0 0 0 5px;">
<li><span style="background:#ffffff;color:#000000"> </span><span style="background:#ffffff;color:#0000ff">static</span><span style="background:#ffffff;color:#000000"> </span><span style="background:#ffffff;color:#0000ff">void</span><span style="background:#ffffff;color:#000000"> Main(</span><span style="background:#ffffff;color:#0000ff">string</span><span style="background:#ffffff;color:#000000">[] args)</span></li>
<li style="background: #f3f3f3">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<span style="background:#ffffff;color:#000000">{</span></li>
<li>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#2b91af">MagazinePublisher</span><span style="background:#ffffff;color:#000000"> mp = </span><span style="background:#ffffff;color:#0000ff">new</span><span style="background:#ffffff;color:#000000"> </span><span style="background:#ffffff;color:#2b91af">MagazinePublisher</span><span style="background:#ffffff;color:#000000">();</span></li>
<li style="background: #f3f3f3">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#2b91af">Subscriber</span><span style="background:#ffffff;color:#000000"> s1 = </span><span style="background:#ffffff;color:#0000ff">new</span><span style="background:#ffffff;color:#000000"> </span><span style="background:#ffffff;color:#2b91af">Subscriber</span><span style="background:#ffffff;color:#000000">();</span></li>
<li>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#2b91af">Subscriber</span><span style="background:#ffffff;color:#000000"> s2 = </span><span style="background:#ffffff;color:#0000ff">new</span><span style="background:#ffffff;color:#000000"> </span><span style="background:#ffffff;color:#2b91af">Subscriber</span><span style="background:#ffffff;color:#000000">();</span></li>
<li style="background: #f3f3f3">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<span style="background:#ffffff;color:#000000"></span></li>
<li>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">var</span><span style="background:#ffffff;color:#000000"> removeMe1 = mp.Subscribe(s1);</span></li>
<li style="background: #f3f3f3">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">var</span><span style="background:#ffffff;color:#000000"> removeMe2 = mp.Subscribe(s2);</span></li>
<li>&nbsp;</li>
<li style="background: #f3f3f3">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#008000">// &#39;setting&#39; this NewIssue property &#8211; will call notify on all the subscribers</span></li>
<li>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<span style="background:#ffffff;color:#000000">mp.NewIssue = </span><span style="background:#ffffff;color:#2b91af">DateTime</span><span style="background:#ffffff;color:#000000">.Now.ToString(</span><span style="background:#ffffff;color:#800000">&quot;MMMM&quot;</span><span style="background:#ffffff;color:#000000">) + </span><span style="background:#ffffff;color:#800000">&quot; issue&quot;</span><span style="background:#ffffff;color:#000000">;</span></li>
<li style="background: #f3f3f3">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<span style="background:#ffffff;color:#000000"></span></li>
<li>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#008000">// Cleanup </span></li>
<li style="background: #f3f3f3">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<span style="background:#ffffff;color:#000000">removeMe1.Dispose();</span></li>
<li>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<span style="background:#ffffff;color:#000000">removeMe2.Dispose();</span></li>
<li style="background: #f3f3f3">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<span style="background:#ffffff;color:#000000">}</span></li>
</ol></div>
</p></div>
</p></div>
<h3>Summary</h3>
<p>There are several advantages of using these new interfaces to use in your own publish subscribe solution. </p>
<ol>
<li>Consistency, Uniformity – Everyone’s Publish Subscribe will now look the same – a great time-saver for new people brought onto a project. </li>
<li>Moving away from events delegates –While events and delegates are great-&nbsp; and can be used to provide the same implementation as the one above, one needs to be extra careful in removing (unsubscribing) from subscribed events. There are also a few other <a href="http://www.dotnetarchitecthouston.com/post/The-Publish-Subscribe-Pattern-in-C-and-some-gotchas.aspx">&#8216;gotchas’</a> in a typical publish subscribe pattern (that are discussed in detail here).</li>
</ol>
<p>It isn’t everyday that one gets excited about the introduction of a couple of new interfaces – but given the ubiquitous applicability of the <em>Publish Subscribe (or Observer) </em>pattern, this is a fairly big deal. The only thing I disliked was the naming of the two interfaces – it leads to confusion. Which is why this article continues to refer to them as Publisher (IObservable) and Subscriber (IObserver).</p>
<h3>Full Solution</h3>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:fb3a1972-4489-4e52-abe7-25a00bb07fdf:3e5e1b59-d0e2-43ee-a433-4a21368df45b" class="wlWriterEditableSmartContent">
<p>Download .NET 4.0 IObservable Implementation <a href="http://www.anujvarma.com/wp-content/uploads/PublishSubscribeInterfaces_4_0.zip" target="_blank">Full Solution</a></p>
</div>
<p>Note – To compile successfully, your target framework must be set to .NET 4.0&nbsp; (Right click the project properties and set the target framework). If you haven’t already, I would recommend using Visual Studio 2011 (beta) available <a href="http://www.microsoft.com/visualstudio/11/en-us">here.</a></p>
<p><a href="http://www.anujvarma.com/wp-content/uploads/target_platform_dotnet_40.png"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="target_platform_dotnet_40" border="0" alt="target_platform_dotnet_40" src="http://www.anujvarma.com/wp-content/uploads/target_platform_dotnet_40_thumb.png" width="403" height="273"></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.anujvarma.com/new-interfaces-for-implementing-publish-subscribe-in-net/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Cold Fusion Administrator–Unable to browse the server</title>
		<link>http://www.anujvarma.com/cold-fusion-administratorunable-to-browse-the-server/</link>
		<comments>http://www.anujvarma.com/cold-fusion-administratorunable-to-browse-the-server/#comments</comments>
		<pubDate>Thu, 29 Mar 2012 21:33:57 +0000</pubDate>
		<dc:creator>Anuj Varma</dc:creator>
				<category><![CDATA[Cold Fusion]]></category>
		<category><![CDATA[browse server error cold fusion]]></category>
		<category><![CDATA[datasource coldfusion administrator]]></category>

		<guid isPermaLink="false">http://www.anujvarma.com/cold-fusion-administratorunable-to-browse-the-server/</guid>
		<description><![CDATA[When adding datasources to the Cold Fusion Administrator, one might encounter the following error:
&#160;

&#160;
Solution
The browse server functionality uses the RDS server in Cold Fusion. I wish they would display a huge warning during installation to warn users that without RDS, &#8230; <a href="http://www.anujvarma.com/cold-fusion-administratorunable-to-browse-the-server/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>When adding datasources to the Cold Fusion Administrator, one might encounter the following error:</p>
<p>&nbsp;</p>
<p><a href="http://www.anujvarma.com/wp-content/uploads/browse_server_broken.jpg"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="browse_server_broken" border="0" alt="browse_server_broken" src="http://www.anujvarma.com/wp-content/uploads/browse_server_broken_thumb.jpg" width="505" height="382"></a></p>
<p>&nbsp;</p>
<h3>Solution</h3>
<p>The browse server functionality uses the RDS server in Cold Fusion. I wish they would display a huge warning during installation to warn users that without RDS, they will be unable to do a lot of tasks which they could in the previous versions (previously RDS ran as a separate windows service – and was NOT required to add datasources to your Cold Fusion administrator). Be that as it may, enabling RDS is a simple matter to two tweaks to your web.xml file (under ColdFusion9\wwwroot\WEB-INF). Simple open up this file – and look for RDS. You will find two occurrences – both of them commented out – like the one shown below:</p>
<p>&lt;!&#8211; begin RDS <br />&nbsp;&nbsp; &lt;servlet id=&#8221;coldfusion_servlet_8789&#8243;&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;servlet-name&gt;RDSServlet&lt;/servlet-name&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;display-name&gt;RDS Servlet&lt;/display-name&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;servlet-class&gt;coldfusion.bootstrap.BootstrapServlet&lt;/servlet-class&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;init-param id=&#8221;InitParam_103401311065856789&#8243;&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;param-name&gt;servlet.class&lt;/param-name&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;param-value&gt;coldfusion.rds.RdsFrontEndServlet&lt;/param-value&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/init-param&gt;<br />&nbsp;&nbsp; &lt;/servlet&gt;<br /> end RDS &#8211;&gt;</p>
<p>Just uncomment these two occurrences, save&nbsp; your web.xml and restart the Cold Fusion server. That should allow you to browse your server&nbsp; &#8211; and add datasources to your cold fusion administrator</p>
]]></content:encoded>
			<wfw:commentRss>http://www.anujvarma.com/cold-fusion-administratorunable-to-browse-the-server/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ODBC 32 bit drivers on Windows 7</title>
		<link>http://www.anujvarma.com/odbc-32-bit-drivers-on-windows-7/</link>
		<comments>http://www.anujvarma.com/odbc-32-bit-drivers-on-windows-7/#comments</comments>
		<pubDate>Thu, 29 Mar 2012 01:40:43 +0000</pubDate>
		<dc:creator>Anuj Varma</dc:creator>
				<category><![CDATA[Windows Quirks, Email, Internet Gotchas]]></category>
		<category><![CDATA[32 bit odbc drivers]]></category>
		<category><![CDATA[odbc access driver]]></category>
		<category><![CDATA[windows 7]]></category>

		<guid isPermaLink="false">http://www.anujvarma.com/odbc-32-bit-drivers-on-windows-7/</guid>
		<description><![CDATA[When I opened the ODBC control panel (on Windows 7) and started enumerating the built-in database drivers, I got a bit of a shock. Not only were the Microsoft Access drivers missing from the list – so were a bunch &#8230; <a href="http://www.anujvarma.com/odbc-32-bit-drivers-on-windows-7/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>When I opened the ODBC control panel (on Windows 7) and started enumerating the built-in database drivers, I got a bit of a shock. Not only were the Microsoft Access drivers missing from the list – so were a bunch of other default ODBC drivers. In fact, the only drivers available were for SQLServer (which I had recently installed). What gives?</p>
<h3>The 32 bit ODBC driver panel</h3>
<p>It turns out that those drivers are available via a DIFFERENT odbc control panel – the 32 bit one. The default ODBC control panel is the 64 bit one – and does not list any of the older, 32 bit drivers.</p>
<p>To get to the older drivers, you have to fire up this <em>odbcad32.exe</em> – found under the folder&nbsp; <em>C:\Windows\SysWow64.</em></p>
<p>Once you launch this panel, you should see all your old friends again.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.anujvarma.com/odbc-32-bit-drivers-on-windows-7/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

