<?xml version='1.0' encoding='UTF-8'?><rss xmlns:atom="http://www.w3.org/2005/Atom" xmlns:openSearch="http://a9.com/-/spec/opensearchrss/1.0/" xmlns:blogger="http://schemas.google.com/blogger/2008" xmlns:georss="http://www.georss.org/georss" xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr="http://purl.org/syndication/thread/1.0" version="2.0"><channel><atom:id>tag:blogger.com,1999:blog-2907200877901329962</atom:id><lastBuildDate>Fri, 20 Sep 2024 10:59:34 +0000</lastBuildDate><category>C# 4.0</category><category>Named Parameters</category><category>Optional Parameters</category><category>64bit</category><category>Cleancode</category><category>Faulting application name: w3wp.exe</category><category>Faulting module name: mscorwks.dll</category><category>Functions Arguments</category><category>How to Read a book</category><category>ISAPI rewrite module</category><category>Mindmaps</category><category>Pragmatic Programmer</category><category>Pragmatic Thinking and Learning</category><category>Refactoring Parameters</category><category>SEO</category><category>Screencasts</category><category>Test Automated</category><category>Test early</category><category>Test often</category><category>URL rewriting</category><category>WCF</category><category>WebFaultException</category><category>asp.net http module</category><category>quick feedback</category><category>ruby</category><category>testing</category><title>Being Agile/Doing Agile</title><description>&lt;p&gt;TDD,Agile Principles, XP/Scrum Practices, .NET/Ruby Web development, Lessons Learned ...&lt;/p&gt;</description><link>http://codinggym.blogspot.com/</link><managingEditor>noreply@blogger.com (Isha Narravula)</managingEditor><generator>Blogger</generator><openSearch:totalResults>9</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><item><guid isPermaLink="false">tag:blogger.com,1999:blog-2907200877901329962.post-3174480831300886903</guid><pubDate>Wed, 13 Oct 2010 18:58:00 +0000</pubDate><atom:updated>2010-10-14T11:34:36.058-05:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">64bit</category><category domain="http://www.blogger.com/atom/ns#">Faulting application name: w3wp.exe</category><category domain="http://www.blogger.com/atom/ns#">Faulting module name: mscorwks.dll</category><title>IIS 7: Faulting module name: mscorwks.dll Faulting application name: w3wp.exe</title><description>We experienced w3wp process crash during our testing on staging environment, with following dump in the event log.&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #990000;&quot;&gt; Faulting application name: w3wp.exe, version: 7.5.7600.16385, time stamp: 0x4a5bd0eb&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;color: #990000;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Faulting module name: mscorwks.dll, version: 2.0.50727.4952, time stamp: 0x4bebe78c&lt;/div&gt;&lt;div style=&quot;color: #990000;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Exception code: 0xc0000005&lt;/div&gt;&lt;br /&gt;
Environment:&lt;br /&gt;
&amp;nbsp;&amp;nbsp; IIS 7 &lt;br /&gt;
&amp;nbsp;&amp;nbsp; ASP.NET&lt;br /&gt;
&amp;nbsp; .NET 3.5&lt;br /&gt;
&amp;nbsp; Windows Server 2008, 64 bit &lt;br /&gt;
&amp;nbsp; &lt;br /&gt;
&lt;br /&gt;
We had following three issues crashing the asp.net w3wp process: &lt;br /&gt;
&lt;br /&gt;
1. Check whether the application pool&#39;s user has &lt;span style=&quot;background-color: yellow;&quot;&gt;permissions&amp;nbsp; &lt;/span&gt;( To detect, see this &lt;a href=&quot;http://weblogs.asp.net/steveschofield/archive/2008/03/07/detecting-permission-issues-using-auditing-and-process-monitor.aspx&quot;&gt;post&lt;/a&gt; )&lt;br /&gt;
2. Check whether&lt;span style=&quot;background-color: yellow;&quot;&gt; enable 32-bit applications&lt;/span&gt; setting is true (Go to advance settings of the application pool)&lt;br /&gt;
&amp;nbsp;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgDVLdn0ElBW1ZVG5wx1x2zb8LrzEToEteSxvTUrPZjJgOafWmi4eRAHDOXBeptyIGAwwXaJ2_R9PpAENpP400D2F0borQiA8NFBPv9APsRhLFVS-RKFO1OctHjNnoyobUphrGuFaEpVbs/s1600/Enable32BitApps.JPG&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;64&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgDVLdn0ElBW1ZVG5wx1x2zb8LrzEToEteSxvTUrPZjJgOafWmi4eRAHDOXBeptyIGAwwXaJ2_R9PpAENpP400D2F0borQiA8NFBPv9APsRhLFVS-RKFO1OctHjNnoyobUphrGuFaEpVbs/s320/Enable32BitApps.JPG&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;br /&gt;
3. Check whether your &lt;span style=&quot;background-color: yellow;&quot;&gt;code is in infinite loop&lt;/span&gt; (we had ISAPI URL rewrite module going in long recursive for particular urls. For more details,&lt;a href=&quot;http://codinggym.blogspot.com/2010/10/isolating-url-rewriting-testing-aspnet.html&quot;&gt;see my other post&lt;/a&gt;) &lt;br /&gt;
&lt;br /&gt;
Once these are in place, things went smoothly.&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: #073763;&quot;&gt;How did we find the issue earlier:&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #073763;&quot;&gt;&amp;nbsp;&lt;/span&gt; &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; All team testing on staging environment helped us in finding these issues sooner, making the production deployment much smoother. This particular team didn&#39;t have the safety net of tests, as technical practices that enable Agile is not followed during development. By that time I joined the team, it was too late to bring the technical practices to the team. So I had to request all team testing in staging environment covering major scenarios.&lt;br /&gt;
&lt;br /&gt;
This exercise proved me once again that It&#39;s never too late to test, and get the quick feedback.&lt;br /&gt;
In any process, I found XP practice &quot;&lt;span style=&quot;background-color: yellow;&quot;&gt;Test Early, Test Often, Test Automated&lt;/span&gt;&quot; is very essential in delivering quality software. That to me is the core of Agile practices. It enables the Agile.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgDVLdn0ElBW1ZVG5wx1x2zb8LrzEToEteSxvTUrPZjJgOafWmi4eRAHDOXBeptyIGAwwXaJ2_R9PpAENpP400D2F0borQiA8NFBPv9APsRhLFVS-RKFO1OctHjNnoyobUphrGuFaEpVbs/s1600/Enable32BitApps.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;br /&gt;
&lt;/a&gt;&lt;/div&gt;</description><link>http://codinggym.blogspot.com/2010/10/faulting-module-name-mscorwksdll.html</link><author>noreply@blogger.com (Isha Narravula)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgDVLdn0ElBW1ZVG5wx1x2zb8LrzEToEteSxvTUrPZjJgOafWmi4eRAHDOXBeptyIGAwwXaJ2_R9PpAENpP400D2F0borQiA8NFBPv9APsRhLFVS-RKFO1OctHjNnoyobUphrGuFaEpVbs/s72-c/Enable32BitApps.JPG" height="72" width="72"/></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-2907200877901329962.post-4449265720848593470</guid><pubDate>Thu, 07 Oct 2010 06:44:00 +0000</pubDate><atom:updated>2010-10-13T13:59:00.084-05:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">asp.net http module</category><category domain="http://www.blogger.com/atom/ns#">ISAPI rewrite module</category><category domain="http://www.blogger.com/atom/ns#">quick feedback</category><category domain="http://www.blogger.com/atom/ns#">ruby</category><category domain="http://www.blogger.com/atom/ns#">SEO</category><category domain="http://www.blogger.com/atom/ns#">Test Automated</category><category domain="http://www.blogger.com/atom/ns#">Test early</category><category domain="http://www.blogger.com/atom/ns#">Test often</category><category domain="http://www.blogger.com/atom/ns#">testing</category><category domain="http://www.blogger.com/atom/ns#">URL rewriting</category><title>Isolating URL rewriting changes- ASP.NET IHttpModule + simple Ruby test for Quick Feedback</title><description>&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; I had to deal with URL rewriting very recently for a site. The old site was using &lt;a href=&quot;http://www.helicontech.com/isapi_rewrite/&quot;&gt;ISAPI Rewrite module&lt;/a&gt;, so we decided to continue to use it, even though IIS7 comes with the &lt;a href=&quot;http://learn.iis.net/page.aspx/734/url-rewrite-module/&quot;&gt;URL rewriting module&lt;/a&gt;. Our SEO team came up with better URL scheme for the new site. As Search Engines indexed the old site URLS, a mapping between the old scheme and the new scheme had to be implemented, with proper redirection(301 status code) where ever necessary.&amp;nbsp; &lt;br /&gt;
&amp;nbsp; &lt;br /&gt;
Most of the URL scheme mapping involved regular expressions. I have had used regular expressions time to time, but not that extensive as required by this effort.&lt;br /&gt;
&lt;br /&gt;
Following two things kept my fear factor very high, as this effort was added to the release very late.&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; 1)&amp;nbsp; making sure all 4000 possible old site links redirected to correct links in the new site&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; 2)&amp;nbsp; making sure new URL scheme works&lt;br /&gt;
&lt;br /&gt;
When my fear factor goes high, I usually lean on tests.&amp;nbsp; I tried with tools used by SEO team, but they weren&#39;t quick enough.&amp;nbsp; I just wanted to focus on testing the URL rewriting in isolation with out running entire asp.net page processing.&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &lt;br /&gt;
So I needed to come up with a isolated testing solution that gives me quick feedback. A custom HTTP module came in handy for this situation. &lt;span style=&quot;background-color: yellow;&quot;&gt;The idea is to have a ASP.NET HTTP module, that does nothing but writes the rewritten URL in begin request event, and ends the request.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
My manual testing got faster, as the page responses were coming quickly with URL in the body.&amp;nbsp; I could finish new URL scheme working with manual testing. &lt;br /&gt;
&lt;br /&gt;
Half of the battle is won. Still my fear factor is high, as I didn&#39;t have time to manually test all those 4000 old site links, while making sure nothing breaks as I add regular expressions for old scheme to new scheme mapping.&lt;br /&gt;
&lt;br /&gt;
That&#39;s when I turned to Ruby. I have been playing around with Ruby on and off.&amp;nbsp; I decided to use Ruby to write tests to hit the site with all the links that I want to test. &lt;br /&gt;
&lt;br /&gt;
So I got from the SEO team the list of old site links with following format in a spreadsheet.&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Old Scheme&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; new scheme &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; expected status code&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;/div&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: yellow;&quot;&gt;I wrote not more than 200&amp;nbsp; lines of&amp;nbsp; ruby code which reads this test data from excel, and hit the server using net/http module, and saves the results back to the excel&lt;/span&gt;.It also prints the test results on the console similar to NUnit. &lt;b style=&quot;color: #20124d;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;This testing solution tested around 4600 links in about a minute&lt;/span&gt;.&lt;/b&gt;&amp;nbsp; All my fear was gone away when I looked at the test results in command window.(a sample test window is shown below.) &lt;br /&gt;
&lt;div style=&quot;color: black;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhQswhjQbwuZSIe9Gpzb7ZurQkHRKk_IzSdqhtFZYVAI1jo0Wi2nITx4bO31Sv5wmVaKZ1mZvWEWTt2hqaJF4hq_E-fWhVyQLyH29xuFxmhDsNDfJSW4EgyMpyQ0vFPd__DwB1OSQ4Oq2o/s1600/urlrewritetests.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;200&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhQswhjQbwuZSIe9Gpzb7ZurQkHRKk_IzSdqhtFZYVAI1jo0Wi2nITx4bO31Sv5wmVaKZ1mZvWEWTt2hqaJF4hq_E-fWhVyQLyH29xuFxmhDsNDfJSW4EgyMpyQ0vFPd__DwB1OSQ4Oq2o/s200/urlrewritetests.JPG&quot; width=&quot;171&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br /&gt;
&lt;div style=&quot;color: darkgrey;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;This quick feedback helped us in finding the issues quickly. These tests in conjunction with SEO tools helped us in finding&amp;nbsp; the recursive behavior of URL rewriting which was crashing w3wp process.&amp;nbsp; SEO tools found a recursive behavior that was sending permanent redirects in loop. We had configuration file of&amp;nbsp; ISAPI rewrite engine&#39;s earlier version, which created this recursive behavior. Once it&#39;s removed,everything went smoothly.&lt;br /&gt;
&lt;br /&gt;
Now with the safety&amp;nbsp;net of tests, changes to url rewritings can be accomplished easily. It allows us to switch to different URL rewriting engines in future if the situation demands. Team can now embrace the change in much the XP way.&lt;br /&gt;
&lt;br /&gt;
Next tasks added to my Todo list:&lt;br /&gt;
&amp;nbsp;1)&amp;nbsp; Add these tests to continuous integration.&lt;br /&gt;
&amp;nbsp;2)&amp;nbsp; Add a redirection limit to the test expectations to keep a tab on the looping behavior of URL rewrite engines.&lt;br /&gt;
&lt;br /&gt;
This is my first ruby program at work. I am planning to use more ruby in writing tests. &lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;http://ws.amazon.com/widgets/q?MarketPlace=US&amp;amp;ServiceVersion=20070822&amp;amp;ID=AsinImage&amp;amp;WS=1&amp;amp;Format=_SL160_&amp;amp;ASIN=0977616614&amp;amp;tag=one0a5-20&quot; imageanchor=&quot;1&quot; style=&quot;clear: right; float: right; margin-bottom: 1em; margin-left: 1em;&quot;&gt;&lt;br /&gt;
&lt;/a&gt;&lt;/div&gt;Some of the ruby inspirations came from the book&amp;nbsp;&lt;a href=&quot;http://www.amazon.com/Everyday-Scripting-Ruby-Teams-Testers/dp/0977616614?ie=UTF8&amp;amp;tag=one0a5-20&amp;amp;link_code=btl&amp;amp;camp=213689&amp;amp;creative=392969&quot; target=&quot;_blank&quot;&gt;Everyday Scripting with Ruby: For Teams, Testers, and You&lt;/a&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; height=&quot;1&quot; src=&quot;http://www.assoc-amazon.com/e/ir?t=one0a5-20&amp;amp;l=btl&amp;amp;camp=213689&amp;amp;creative=392969&amp;amp;o=1&amp;amp;a=0977616614&quot; style=&quot;border: medium none; margin: 0px; padding: 0px ! important;&quot; width=&quot;1&quot; /&gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;background-color: white;&quot;&gt;&lt;br /&gt;
This is how&amp;nbsp; XP&#39;s &lt;b&gt;Test early, Test often, and Test Automated&lt;/b&gt; was applied.&lt;/div&gt;&lt;br /&gt;
Wish you a fearless programming.&lt;/div&gt;</description><link>http://codinggym.blogspot.com/2010/10/isolating-url-rewriting-testing-aspnet.html</link><author>noreply@blogger.com (Isha Narravula)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhQswhjQbwuZSIe9Gpzb7ZurQkHRKk_IzSdqhtFZYVAI1jo0Wi2nITx4bO31Sv5wmVaKZ1mZvWEWTt2hqaJF4hq_E-fWhVyQLyH29xuFxmhDsNDfJSW4EgyMpyQ0vFPd__DwB1OSQ4Oq2o/s72-c/urlrewritetests.JPG" height="72" width="72"/></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-2907200877901329962.post-4329613434360564760</guid><pubDate>Sun, 14 Mar 2010 22:44:00 +0000</pubDate><atom:updated>2010-03-16T15:46:47.512-05:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">C# 4.0</category><category domain="http://www.blogger.com/atom/ns#">Cleancode</category><category domain="http://www.blogger.com/atom/ns#">Functions Arguments</category><category domain="http://www.blogger.com/atom/ns#">Named Parameters</category><category domain="http://www.blogger.com/atom/ns#">Optional Parameters</category><category domain="http://www.blogger.com/atom/ns#">Refactoring Parameters</category><title>C# 4.0: Code might smell with  Optional Parameters</title><description>&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; I wrote few tests to understand &lt;a href=&quot;http://codinggym.blogspot.com/2010/03/c-40-named-parameters.html&quot;&gt;Named&lt;/a&gt;, and &lt;a href=&quot;http://codinggym.blogspot.com/2010/03/c-40-optional-parameters.html&quot;&gt;Optional&lt;/a&gt; Parameters, and also &lt;a href=&quot;http://codinggym.blogspot.com/2010/03/c-40-reflecting-named-optional.html&quot;&gt;reflected &lt;/a&gt;them in reflector to see what happens behind the scene.Now let&#39;s think about their impact on code readability. &lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; These would be very useful in calling Office Automation API. We don&#39;t need to worry about passing Type.Missing to zillion arguments, we can now just&amp;nbsp;pass necessary arguments with the use of Named parameters.&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; I can see misuse as well. I won&#39;t be surprised to see functions with lengthy optional parameters. That brings me a question: How many parameters can a function&amp;nbsp; have? I often&amp;nbsp;find myself&amp;nbsp; debating whether a parameter can be an&amp;nbsp;instance field of current object, or some other object. Let&#39;s turn to an expert, and see what he thinks.&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Uncle Bob talked about functional arguments in his articles for InformIT, and there is a dedicated chapter in his book &lt;a href=&quot;http://www.amazon.com/Clean-Code-Handbook-Software-Craftsmanship/dp/0132350882?ie=UTF8&amp;amp;tag=one0a5-20&amp;amp;link_code=btl&amp;amp;camp=213689&amp;amp;creative=392969&quot; target=&quot;_blank&quot;&gt;Clean Code&lt;/a&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; height=&quot;1&quot; src=&quot;http://www.assoc-amazon.com/e/ir?t=one0a5-20&amp;amp;l=btl&amp;amp;camp=213689&amp;amp;creative=392969&amp;amp;o=1&amp;amp;a=0132350882&quot; style=&quot;border: medium none; margin: 0px; padding: 0px ! important;&quot; width=&quot;1&quot; /&gt;.&amp;nbsp; He says in this article &lt;a href=&quot;http://www.informit.com/articles/article.aspx?p=1375308&quot;&gt;Avoid Too Many Arguments&lt;/a&gt;, &quot;&lt;i&gt;Functions should have a small number of arguments. &lt;span style=&quot;background-color: yellow;&quot;&gt;No argument is best, followed by one, two, and three. More than three is very questionable and should be avoided with prejudice&lt;/span&gt;&lt;/i&gt;&lt;span style=&quot;background-color: yellow;&quot;&gt;.&lt;/span&gt;&quot;.&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://www.amazon.com/Clean-Code-Handbook-Software-Craftsmanship/dp/0132350882?ie=UTF8&amp;amp;tag=one0a5-20&amp;amp;link_code=bil&amp;amp;camp=213689&amp;amp;creative=392969&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot; target=&quot;_blank&quot;&gt;&lt;img alt=&quot;Clean Code: A Handbook of Agile Software Craftsmanship&quot; src=&quot;http://ws.amazon.com/widgets/q?MarketPlace=US&amp;amp;ServiceVersion=20070822&amp;amp;ID=AsinImage&amp;amp;WS=1&amp;amp;Format=_SL160_&amp;amp;ASIN=0132350882&amp;amp;tag=one0a5-20&quot; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; He also recommends to&amp;nbsp;not to have&amp;nbsp;boolean arguments, as this is an indication that a function is doing two things.&amp;nbsp;He writes&amp;nbsp;in this article &lt;a href=&quot;http://www.informit.com/articles/article.aspx?p=1392524&quot;&gt;Eliminate Boolean arguments&lt;/a&gt;&amp;nbsp; &lt;i&gt;&quot;&lt;span style=&quot;background-color: yellow;&quot;&gt;Boolean arguments loudly declare that the function does more than one thing&lt;/span&gt;. They are confusing and should be eliminated.&quot;. &quot;&lt;/i&gt;&lt;i style=&quot;background-color: blue; color: white;&quot;&gt;&lt;b&gt;Arguments are hard. They take a lot of conceptual power&lt;/b&gt;&lt;/i&gt;&lt;u&gt;&lt;i style=&quot;color: #0c343d;&quot;&gt;&lt;b&gt;.&lt;/b&gt;&lt;/i&gt;&lt;/u&gt;&lt;span style=&quot;background-color: white;&quot;&gt;&lt;/span&gt;&quot;, Uncle Bob writes in the book Clean Code.Writing unit tests for function with many arguments will be harder. Tests should cover all possible combinations of the parameters.&lt;br /&gt;
&lt;a href=&quot;http://www.amazon.com/Refactoring-Improving-Design-Existing-Code/dp/0201485672?ie=UTF8&amp;amp;tag=one0a5-20&amp;amp;link_code=bil&amp;amp;camp=213689&amp;amp;creative=392969&quot; imageanchor=&quot;1&quot; style=&quot;clear: right; float: right; margin-bottom: 1em; margin-left: 1em;&quot; target=&quot;_blank&quot;&gt;&lt;img alt=&quot;Refactoring: Improving the Design of Existing Code&quot; src=&quot;http://ws.amazon.com/widgets/q?MarketPlace=US&amp;amp;ServiceVersion=20070822&amp;amp;ID=AsinImage&amp;amp;WS=1&amp;amp;Format=_SL160_&amp;amp;ASIN=0201485672&amp;amp;tag=one0a5-20&quot; /&gt;&lt;/a&gt;&lt;br /&gt;
&lt;img alt=&quot;&quot; border=&quot;0&quot; height=&quot;1&quot; src=&quot;http://www.assoc-amazon.com/e/ir?t=one0a5-20&amp;amp;l=bil&amp;amp;camp=213689&amp;amp;creative=392969&amp;amp;o=1&amp;amp;a=0201485672&quot; style=&quot;border: medium none; margin: 0px; padding: 0px ! important;&quot; width=&quot;1&quot; /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; If you end up having function with&amp;nbsp;more arguments, you can try following refactorings. Related Refactorings: (The book refered in this catalog)&amp;nbsp; &lt;br /&gt;
&lt;a href=&quot;http://www.refactoring.com/catalog/replaceParameterWithMethod.html&quot;&gt;Replace Parameter with Method&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://www.refactoring.com/catalog/replaceParameterWithExplicitMethods.html&quot;&gt;Replace Parameter with Explicit Methods&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://www.refactoring.com/catalog/replaceRecordWithDataClass.html&quot;&gt;Replace Record with Data Class&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://www.refactoring.com/catalog/parameterizeMethod.html&quot;&gt;Parameterize Method&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://www.refactoring.com/catalog/removeParameter.html&quot;&gt;Remove Parameter&lt;/a&gt;</description><link>http://codinggym.blogspot.com/2010/03/c-40-code-smells-with-named-optional.html</link><author>noreply@blogger.com (Isha Narravula)</author></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-2907200877901329962.post-2484536248625050942</guid><pubDate>Sun, 14 Mar 2010 21:07:00 +0000</pubDate><atom:updated>2010-03-16T15:05:04.722-05:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">C# 4.0</category><category domain="http://www.blogger.com/atom/ns#">Named Parameters</category><category domain="http://www.blogger.com/atom/ns#">Optional Parameters</category><title>C# 4.0: Reflecting Named &amp; Optional Parameters</title><description>I wrote few tests to understand &lt;a href=&quot;http://codinggym.blogspot.com/2010/03/c-40-named-parameters.html&quot;&gt;Named&lt;/a&gt; and &lt;a href=&quot;http://codinggym.blogspot.com/2010/03/c-40-optional-parameters.html&quot;&gt;Optional&lt;/a&gt; Parameters. Now it&#39;s time to reflect.&lt;br /&gt;
I wrote few tests to see the what happens behind the scene.&lt;br /&gt;
&lt;br /&gt;
Tests.&lt;br /&gt;
1. Reflecting Optional with default values &lt;br /&gt;
&lt;div&gt;&lt;pre class=&quot;brush: csharp; wrap-lines: false&quot;&gt;public void MethodWithDefaultValue(string name =&quot;N/A&quot;, int cound =50)
 {
 
 }
&lt;/pre&gt;&lt;/div&gt;gets converted to &lt;br /&gt;
&lt;div&gt;&lt;pre class=&quot;brush: csharp; wrap-lines:false;&quot;&gt;public void MethodWithDeffaults([Optional, DefaultParameterValue(&quot;N/A&quot;)] string name, 
[Optional, DefaultParameterValue(50)] int count) 
{
}
&lt;/pre&gt;&lt;/div&gt;You can declare a method using Optional Attribute, which allows you to have optional reference objects.&lt;br /&gt;
&lt;br /&gt;
2. Reflecting Optional parametes when ommitted : When above method is called &lt;br /&gt;
&lt;div&gt;&lt;pre class=&quot;brush: csharp;wrap-lines:false;&quot;&gt;public void ReflectMethodSignatureForOptionalWithDefaultValue()
{
ReflectClass optionalWithDefaultValue = new ReflectClass();
optionalWithDefaultValue.MethodWithDefaults();
}
&lt;/pre&gt;&lt;/div&gt;gets converted to &lt;br /&gt;
&lt;div&gt;&lt;pre class=&quot;brush: csharp;wrap-lines:false;&quot;&gt;public void ReflectMethodSignatureForOptionalWithDefaultValue()
{
new ReflectClass().MethodWithDefaults(&quot;N/A&quot;, 50);
}
&lt;/pre&gt;&lt;/div&gt;Default values for the optional arguments are injected in the caller code.&lt;br /&gt;
&lt;br /&gt;
3. Reflecting Named Parameters: if method in Test 1 called with named parameters, &lt;br /&gt;
&lt;div&gt;&lt;pre class=&quot;brush: csharp;wrap-lines:false;&quot;&gt;public void ReflectNamedParametersCallerCode()
{
&amp;nbsp;&amp;nbsp; ReflectClass optionalWithDefaultValue = new ReflectClass();
&amp;nbsp; optionalWithDefaultValue.MethodWithDefaults(count: 20, name: &quot;Hello&quot;);
}
&lt;/pre&gt;&lt;/div&gt;gets converted to &lt;br /&gt;
&lt;div&gt;&lt;pre class=&quot;brush: csharp;wrap-lines:false;&quot;&gt;public void ReflectNamedParametersCallerCode() 
{ 
 ReflectClass optionalWithDefaultValue = new ReflectClass();
 int CS$0$0000 = 20;
string CS$0$0001 = &quot;Hello&quot;;
optionalWithDefaultValue.MethodWithDefaults(CS$0$0001, CS$0$0000);
}
&lt;/pre&gt;&lt;/div&gt;In the caller code,&amp;nbsp;&amp;nbsp;A &amp;nbsp;local variable is created for every named parameter.&lt;br /&gt;
&lt;div&gt;Complete Listing: In case you want to see yourself in reflector. Mouse hover on the listing to see clipboard/view source options.&lt;br /&gt;
&lt;div&gt;&lt;pre class=&quot;brush: csharp;wrap-lines:false;&quot;&gt;using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace episodes
{
    
    public  class ReflectingNamedOptionalParams
    {
        public void ReflectMethodSignatureForOptionalWithDefaultValue()
        {
            ReflectClass optionalWithDefaultValue = new ReflectClass();
            optionalWithDefaultValue.MethodWithDefaults();
        }
        public void ReflectNamedParametersCallerCode()
        {
            ReflectClass optionalWithDefaultValue = new ReflectClass();
            optionalWithDefaultValue.MethodWithDefaults(count: 20, name: &quot;Hello&quot;);
        }
    }

    public class ReflectClass
    {
        public void MethodWithDefaults(string name=&quot;N/A&quot;,int count=50)
        {
            
        }
    }
}
&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;</description><link>http://codinggym.blogspot.com/2010/03/c-40-reflecting-named-optional.html</link><author>noreply@blogger.com (Isha Narravula)</author></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-2907200877901329962.post-1868486507721663133</guid><pubDate>Sun, 14 Mar 2010 20:26:00 +0000</pubDate><atom:updated>2010-03-16T15:06:16.075-05:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">C# 4.0</category><category domain="http://www.blogger.com/atom/ns#">Optional Parameters</category><title>C# 4.0: Optional Parameters</title><description>C# 4.0 introduces &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/dd264739%28VS.100%29.aspx&quot;&gt;optional parameters&lt;/a&gt; along with named parameters. A method can have optional parameters, which allows callers to skip them. A default value, which should be constant.&amp;nbsp;can be specified for a optional parameter as part of the method declaration. When caller omits a optional parameter, a default value will be passed to the method. With the use of Named parameters syntax, you can&amp;nbsp;skip&amp;nbsp;some optional parameters in the order.&amp;nbsp;&amp;nbsp;This is very&amp;nbsp;useful when calling a COM interop assembly like Office integration. &amp;nbsp;I wrote few tests to understand these concepts. I wrote &lt;a href=&quot;http://codinggym.blogspot.com/2010/03/c-40-named-parameters.html&quot;&gt;few tests&lt;/a&gt; on Named Parameters.&lt;br /&gt;
Note: VS2010, and NUnit is required to use this code as is in your machine.Mouse hover on the listing, you will see options like copy to clipboard,view source.&lt;br /&gt;
&lt;br /&gt;
Tests:&lt;br /&gt;
TestOptionalAttribute&lt;br /&gt;
SkipOptionalParameters&lt;br /&gt;
SkipOrderWithTheUseOfNamedParmeters&lt;br /&gt;
TestOverloadResolution&lt;br /&gt;
&lt;br /&gt;
&lt;div&gt;&lt;pre class=&quot;brush: csharp; wrap-lines:false&quot;&gt;using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using NUnit.Framework;

namespace LearningCSharp40
{
    public class ParamArg
    {

    }
    public class UseOfOptionalAttribute
    {
        public string StringValue { get; set; }
        public UseOfOptionalAttribute([Optional]string param, [Optional] bool flag)
        {
            StringValue = param;
            BooleanValue = flag;
        }

        public ParamArg OptionalObjects([Optional]ParamArg arg, [Optional] ParamArg arg2)
        {
            return arg;
        }

        public bool BooleanValue { get; set; }
    }

    public class OptionalParamWithDefaultValue
    {
        public string StringValue { get; set; }
        public OptionalParamWithDefaultValue(string param)
            : this(param, true)
        {

        }

        public OptionalParamWithDefaultValue(string param = &quot;N/A&quot;, bool flag = true, string name = &quot;hi&quot;)
        {
            StringValue = param;
            BooleanValue = flag;
            Name = name;
        }
        public string Name { get; set; }
        public bool BooleanValue { get; set; }
    }

    [TestFixture]
    class LearnOptionalParams
    {
        //.NET reflector: When used with Optional attribute, compiler does substitute the default values of the types.
        [Test]
        public void TestOptionalAttribute()
        {
            UseOfOptionalAttribute useOfOptionalAttribute = new UseOfOptionalAttribute();
            Assert.AreEqual(useOfOptionalAttribute.StringValue, null);
            Assert.AreEqual(useOfOptionalAttribute.BooleanValue, false);
            Assert.IsNull(useOfOptionalAttribute.OptionalObjects(), &quot;expecting null&quot;);
            Assert.IsNotNull(useOfOptionalAttribute.OptionalObjects(new ParamArg()), &quot;expecting null&quot;);

        }

        [Test]
        public void SkipOptionalParameters()
        {

            OptionalParamWithDefaultValue optionalParamWithDefaultValue = new OptionalParamWithDefaultValue(&quot;Hello&quot;);
            Assert.AreEqual(optionalParamWithDefaultValue.StringValue, &quot;Hello&quot;, &quot;Expecting value passed in constructor&quot;);
            Assert.AreEqual(optionalParamWithDefaultValue.BooleanValue, true, &quot;Expecting default value of flag&quot;);
            Assert.AreEqual(optionalParamWithDefaultValue.Name, &quot;hi&quot;, &quot;Expecting default value of Name&quot;);
        }

        [Test]
        public void SkipOrderWithTheUseOfNamedParmeters()
        {
            bool result = false;
            OptionalParamWithDefaultValue optionalParamWithDefaultValue = new OptionalParamWithDefaultValue(flag: result);
            Assert.AreEqual(optionalParamWithDefaultValue.StringValue, &quot;N/A&quot;);
            Assert.AreEqual(optionalParamWithDefaultValue.BooleanValue, result);
        }




        [Test]
        public void TestOverloadResolution()
        {
            OverloadResolution overloadResolution = new OverloadResolution();
            Assert.AreEqual(&quot;NoArg&quot;, overloadResolution.Confused(), &quot;Priority is for matching method signature: method with no arguments should be called&quot;);
            Assert.AreEqual(&quot;1Arg&quot;, overloadResolution.Confused(&quot;Hello&quot;), &quot;Method with one argument should be called&quot;);
        }
    }
    public class OverloadResolution
    {

        public string Confused()
        {
            return &quot;NoArg&quot;;
        }

        public string Confused(string stringValue)
        {
            return &quot;1Arg&quot;;
        }

        public string Confused(string stringValue = &quot;N/A&quot;, bool flag = true)
        {
            return &quot;2Arg&quot;;
        }

    }

}




&lt;/pre&gt;&lt;/div&gt;</description><link>http://codinggym.blogspot.com/2010/03/c-40-optional-parameters.html</link><author>noreply@blogger.com (Isha Narravula)</author></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-2907200877901329962.post-3538122564903661891</guid><pubDate>Wed, 10 Mar 2010 05:17:00 +0000</pubDate><atom:updated>2010-03-14T15:05:35.366-05:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">C# 4.0</category><category domain="http://www.blogger.com/atom/ns#">Named Parameters</category><title>C# 4.0: Named Parameters</title><description>&lt;a href=&quot;http://msdn.microsoft.com/en-us/library/dd264739(VS.100).aspx&quot;&gt;C# 4.0: Named Parameters&lt;/a&gt; : C# introduces Named parameters.  While calling a method, name: value pair syntax can be used for the parameters. Order doesn&#39;t matter. As you might guess, Named parameters can&#39;t precede optional parameters. I wrote few tests to understand these concepts.&lt;br /&gt;
You need VS2010, and NUnit if you want to try this code as is on your machine.&lt;br /&gt;
&lt;br /&gt;
&lt;div&gt;&lt;pre class=&quot;brush: csharp; wrap-lines: false&quot;&gt;using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Framework;

namespace LearningCSharp40
{
    public class Division
    {
        public int Divide(int dividend, int divisor)
        {
            return dividend / divisor;
        }
    }
    [TestFixture]
    public class LearnNamedParameters
    {
        Division division = new Division();
        private int quotientFromPositional = 0;
            
        [SetUp]
        public void Setup()
        {
            quotientFromPositional = division.Divide(20, 10); // positional
        }

        [Test]
        public void  QuotientShouldbeSameWhenCalledWithNamedParameters()
        {
            int quotientWithNamedParams = division.Divide(dividend: 20, divisor: 10); // named parameters
            Assert.AreEqual(quotientFromPositional, quotientWithNamedParams, 
                            &quot;quotient should be 2 even with named parameters&quot;);
       
        }
        
        [Test]
        public void NamedParametersInDifferentOrder()
        {
            int quotientWithNamedParamsInDifferentOrder = division.Divide( dividend:20,divisor:10); // Order is different
            Assert.AreEqual(quotientFromPositional, quotientWithNamedParamsInDifferentOrder, 
                            &quot;quotient should be same even called with named paratmeters in different parameter&quot;);
        }

       
        [Test]
        public void QuotientShouldBeSameWhenMixOfPositionalAndNamedApproachIsUsed()
        {
            int quotient = division.Divide( 20, divisor: 10); 
            Assert.AreEqual(quotientFromPositional, quotient,
                            &quot;quotient should be same even with mix of positional, and named parameters&quot;);

        }
        [Test]
        [Ignore]
        public void NamedParametersCantProcedePosition_CompilerError()
        {
            Division division = new Division();
            //Uncomment to see the compiler error...
            // int quotient = division.Divide( dividend: 20,10); // named parameters cannot procede positional
            // Assert.AreEqual(2, quotient, &quot;quotient should be 2 even with named parameters&quot;);
        }

        [Test]
        [Ignore]
        public void NamedParameterSpecifiesAParameterForWhichAPositionalArgumentHasAlreadyGiven_CompilerError()
        {
            Division division = new Division();
            //Uncomment to see the compiler error...
           // int quotient = division.Divide( 20,dividend:20); 
        }
    }
}
&lt;/pre&gt;&lt;/div&gt;</description><link>http://codinggym.blogspot.com/2010/03/c-40-named-parameters.html</link><author>noreply@blogger.com (Isha Narravula)</author></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-2907200877901329962.post-3974288742839155750</guid><pubDate>Tue, 02 Mar 2010 04:53:00 +0000</pubDate><atom:updated>2010-03-04T02:53:45.411-06:00</atom:updated><title>.NET 4.0: New API</title><description>&lt;!-- code formatted by http://manoli.net/csharpformat/ --&gt;&lt;br /&gt;
&lt;style type=&quot;text/css&quot;&gt;
.csharpcode, .csharpcode pre
{
 font-size: small;
 color: black;
 font-family: Consolas, &quot;Courier New&quot;, Courier, Monospace;
 background-color: #ffffff;
 /*white-space: pre;*/
}

.csharpcode pre { margin: 0em; }

.csharpcode .rem { color: #008000; }

.csharpcode .kwrd { color: #0000ff; }

.csharpcode .str { color: #006080; }

.csharpcode .op { color: #0000c0; }

.csharpcode .preproc { color: #cc6633; }

.csharpcode .asp { background-color: #ffff00; }

.csharpcode .html { color: #800000; }

.csharpcode .attr { color: #ff0000; }

.csharpcode .alt 
{
 background-color: #f4f4f4;
 width: 100%;
 margin: 0em;
}

.csharpcode .lnum { color: #606060; }
&lt;/style&gt;&lt;br /&gt;
.NET 4.0 adds several new methods.&amp;nbsp; &lt;br /&gt;
1&lt;span style=&quot;background-color: white; color: black;&quot;&gt;)&lt;/span&gt;&lt;b style=&quot;background-color: white; color: black;&quot;&gt; &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/system.enum.hasflag%28VS.100%29.aspx&quot;&gt;Enum.HasFlag&lt;/a&gt;&amp;nbsp; checks&amp;nbsp; whether a flag field present in the enum instance.&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;!-- code formatted by http://manoli.net/csharpformat/ --&gt;&lt;br /&gt;
&lt;div class=&quot;csharpcode&quot;&gt;&lt;pre class=&quot;alt&quot;&gt;[Flags]&lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;enum&lt;/span&gt; PizzaToppings&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;{&lt;/pre&gt;&lt;pre&gt;Onions = 1,&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;Mushrooms = 2,&lt;/pre&gt;&lt;pre&gt;Chicken = 4&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;}&lt;/pre&gt;&lt;pre&gt;&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;PizzaToppings myToppings = PizzaToppings.Onions |&lt;/pre&gt;&lt;pre&gt;PizzaToppings.Mushrooms;&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre&gt;Assert.IsFalse( myToppings.HasFlag(PizzaToppings.Chicken),&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;str&quot;&gt;&quot;Chicken is not expected&quot;&lt;/span&gt;); &lt;/pre&gt;&lt;/div&gt;2) &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/system.string.isnullorwhitespace%28VS.100%29.aspx&quot;&gt;String.IsNullOrWhiteSpace&lt;/a&gt; can be useful when whitespace condition needs to be&amp;nbsp;checked along with Empty, and Null conditions.&lt;br /&gt;
&lt;!-- code formatted by http://manoli.net/csharpformat/ --&gt;&lt;br /&gt;
&lt;!-- code formatted by http://manoli.net/csharpformat/ --&gt;&lt;br /&gt;
&lt;div class=&quot;csharpcode&quot;&gt;&lt;pre class=&quot;alt&quot;&gt;[Test]&lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;void&lt;/span&gt; TestIsNullOrWhiteSpace()&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;{&lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt; s = &lt;span class=&quot;str&quot;&gt;&quot; \t &quot;&lt;/span&gt;;&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;Assert.IsTrue( &lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt;.IsNullOrWhiteSpace(s),&lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;str&quot;&gt;&quot;tabbed white spaces&quot;&lt;/span&gt;);&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;Assert.IsTrue(&lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt;.IsNullOrWhiteSpace(&lt;span class=&quot;kwrd&quot;&gt;null&lt;/span&gt;), &lt;span class=&quot;str&quot;&gt;&quot;Null&quot;&lt;/span&gt;);&lt;/pre&gt;&lt;pre&gt;Assert.IsTrue(&lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt;.IsNullOrWhiteSpace(&lt;span class=&quot;str&quot;&gt;&quot;&quot;&lt;/span&gt;), &lt;span class=&quot;str&quot;&gt;&quot;Empty&quot;&lt;/span&gt;);&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;Assert.IsTrue(&lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt;.IsNullOrEmpty(&lt;span class=&quot;str&quot;&gt;&quot; \t &quot;&lt;/span&gt;.Trim()));&lt;/pre&gt;&lt;pre&gt;}&lt;/pre&gt;&lt;/div&gt;</description><link>http://codinggym.blogspot.com/2010/03/net-40-new-features.html</link><author>noreply@blogger.com (Isha Narravula)</author></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-2907200877901329962.post-6837210027048076297</guid><pubDate>Mon, 22 Feb 2010 07:50:00 +0000</pubDate><atom:updated>2010-03-15T15:03:05.949-05:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">C# 4.0</category><category domain="http://www.blogger.com/atom/ns#">WCF</category><category domain="http://www.blogger.com/atom/ns#">WebFaultException</category><title>.NET 4.0 WCF: Issues with WebFaultException</title><description>&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; In WCF 3.5,&amp;nbsp; WebHttpBinding&amp;nbsp; doesn&#39;t return faults in expected response format. It ignores the format specified in the contract, and returns the error in html format. I was expecting error to be in the format specified in the WebGet/WebInvoke. For one of my project with WCF RESTful/JQuery solution stack, I end up writing a custom error handler implementing IErrorHandler to receive the fault in the desired JSON format. &lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .NET 4.0 introduces a class &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/system.servicemodel.web.webfaultexception%28VS.100%29.aspx&quot;&gt;WebFaultException&amp;lt;&amp;gt;&lt;/a&gt; to tackle this formatting issue. What all you have to do is throw the fault using this class, and you get the HTTP response in correct desired format. Digging deep the WebHttpErrorHandler with Reflector, I found that formatting decision is made based on type of the fault thrown.The expected fault should of type&amp;nbsp; IWebFaultException. WebFaultException implements IWebFaultException. &lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; I see few problems with this solution. If I forget to use WebFaultException in one of my operation implementation, I am screwed, I get response in same old html format. Deriving message format from the implementation(i.e. service behavior) seems to me odd.&amp;nbsp; Second one, If I have to go with this solution and to retire my custom error handler, I will have to modify code in several places changing use of FaultException to WebFaultException. These two issues making me to think whether I should stick with custom error handler solution unless situtation demands for different status codes. With WebFaultException, you can set http status code. &amp;nbsp; I was just throwing one status code BadRequest, and application specific status codes were in the fault details object.</description><link>http://codinggym.blogspot.com/2010/02/half-baked-solution-by.html</link><author>noreply@blogger.com (Isha Narravula)</author></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-2907200877901329962.post-8460908983065798965</guid><pubDate>Tue, 16 Feb 2010 15:36:00 +0000</pubDate><atom:updated>2010-03-15T15:05:24.595-05:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">How to Read a book</category><category domain="http://www.blogger.com/atom/ns#">Mindmaps</category><category domain="http://www.blogger.com/atom/ns#">Pragmatic Programmer</category><category domain="http://www.blogger.com/atom/ns#">Pragmatic Thinking and Learning</category><category domain="http://www.blogger.com/atom/ns#">Screencasts</category><title>Improving learning  skills</title><description>&lt;div class=&quot;separator&quot; style=&quot;border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none; clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;http://www.amazon.com/How-Read-Book-Touchstone-book/dp/0671212095?ie=UTF8&amp;amp;tag=one0a5-20&amp;amp;link_code=bil&amp;amp;camp=213689&amp;amp;creative=392969&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot; target=&quot;_blank&quot;&gt;&lt;/a&gt;&lt;a href=&quot;http://www.amazon.com/How-Read-Book-Touchstone-book/dp/0671212095?ie=UTF8&amp;amp;tag=one0a5-20&amp;amp;link_code=bil&amp;amp;camp=213689&amp;amp;creative=392969&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot; target=&quot;_blank&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; height=&quot;1&quot; src=&quot;http://www.assoc-amazon.com/e/ir?t=one0a5-20&amp;amp;l=bil&amp;amp;camp=213689&amp;amp;creative=392969&amp;amp;o=1&amp;amp;a=1445219948&quot; style=&quot;border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none; margin: 0px; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important;&quot; width=&quot;1&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;span style=&quot;border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; In Year 2009, I luckily found two books&amp;nbsp; &lt;a href=&quot;http://www.amazon.com/How-Read-Book-Touchstone-book/dp/0671212095?ie=UTF8&amp;amp;tag=one0a5-20&amp;amp;link_code=btl&amp;amp;camp=213689&amp;amp;creative=392969&quot; target=&quot;_blank&quot;&gt;How to Read a Book&lt;/a&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; height=&quot;1&quot; src=&quot;http://www.assoc-amazon.com/e/ir?t=one0a5-20&amp;amp;l=btl&amp;amp;camp=213689&amp;amp;creative=392969&amp;amp;o=1&amp;amp;a=0671212095&quot; style=&quot;border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none; margin: 0px; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important;&quot; width=&quot;1&quot; /&gt; and &lt;a href=&quot;http://www.amazon.com/How-Read-Book-Touchstone-book/dp/0671212095?ie=UTF8&amp;amp;tag=one0a5-20&amp;amp;link_code=btl&amp;amp;camp=213689&amp;amp;creative=392969&quot; target=&quot;_blank&quot;&gt;Pragmatic Thinking &amp;amp; Learning&lt;/a&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; height=&quot;1&quot; src=&quot;http://www.assoc-amazon.com/e/ir?t=one0a5-20&amp;amp;l=btl&amp;amp;camp=213689&amp;amp;creative=392969&amp;amp;o=1&amp;amp;a=0671212095&quot; style=&quot;border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none; margin: 0px; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important;&quot; width=&quot;1&quot; /&gt;. These books helped me in enhancing my learning abilities.&amp;nbsp; I wish I had these books especially How to Read a Book in my high school curriculum. But it is never too late.In this book,&amp;nbsp; You would find several key skills such as how to actually own a book not just physical ownership, note making, how to decide quickly whether a book is worthy of your valuable time, and when to agree/disagree with author, the absent teacher so on.Book talks about use of information in book cover, preface, and table of contents. &lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; With these new skills in reading, I am rereading my favorite books. Lot of satisfaction these days I have in reading.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; If How to Read a Book makes you a demanding reader by empowering you with the necessary skills in reading difficult books,&amp;nbsp; &lt;i&gt;Pragmatic Thinking &amp;amp; Learning&lt;/i&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; height=&quot;1&quot; src=&quot;http://www.assoc-amazon.com/e/ir?t=one0a5-20&amp;amp;l=btl&amp;amp;camp=213689&amp;amp;creative=392969&amp;amp;o=1&amp;amp;a=1934356050&quot; style=&quot;border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none; margin: 0px; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important;&quot; width=&quot;1&quot; /&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; height=&quot;1&quot; src=&quot;http://www.assoc-amazon.com/e/ir?t=one0a5-20&amp;amp;l=btl&amp;amp;camp=213689&amp;amp;creative=392969&amp;amp;o=1&amp;amp;a=1934356050&quot; style=&quot;border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none; margin: 0px; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important;&quot; width=&quot;1&quot; /&gt; helps you in taking care of your inner learning and thinking processes. Writing a book on thinking is tough, but the author Andy Hunt has done fantastic job in covering the subject.&amp;nbsp; If you don&#39;t know Andy Hunt, He is one of the signatory of agile manifesto, and author of several books. This book gives you not only practical tools in improving your thinking and learning, but also gives you tools for your awareness.&amp;nbsp; What matters most, at least to me, is this awareness. Tools might go, but this awareness stays with you, and helping you in growing your mind. Book talks about use of Mind maps, Screencasts, Podcasts, Blogging, and Wiki, and how you can integrate these tools in to your learning &amp;amp; thinking process. &lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; I was reluctant to blog, but these books changed my view, and I am here writing first post for my blog.&amp;nbsp; I am thankful to the authors Andy Hunt, and Mortime&amp;nbsp; J. Adler.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; For those, who like to read&amp;nbsp; but don&#39;t have time, I recommend you&amp;nbsp;&lt;span style=&quot;border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none;&quot;&gt; &lt;a href=&quot;http://www.pomodorotechnique.com/&quot;&gt;Pomodoro technique&lt;/a&gt;.&amp;nbsp; This simple technique helps you in gaining quality of your time. Best of Luck. &lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none;&quot;&gt;&lt;iframe align=&quot;left&quot; frameborder=&quot;0&quot; marginheight=&quot;0&quot; marginwidth=&quot;0&quot; scrolling=&quot;no&quot; src=&quot;http://rcm.amazon.com/e/cm?t=one0a5-20&amp;amp;o=1&amp;amp;p=8&amp;amp;l=bpl&amp;amp;asins=1934356050&amp;amp;fc1=000000&amp;amp;IS2=1&amp;amp;lt1=_blank&amp;amp;m=amazon&amp;amp;lc1=0000FF&amp;amp;bc1=000000&amp;amp;bg1=FFFFFF&amp;amp;f=ifr&quot; style=&quot;height: 245px; padding-right: 10px; padding-top: 5px; width: 131px;&quot;&gt;&lt;/iframe&gt;&lt;/span&gt;&lt;br /&gt;
&lt;iframe align=&quot;left&quot; frameborder=&quot;0&quot; marginheight=&quot;0&quot; marginwidth=&quot;0&quot; scrolling=&quot;no&quot; src=&quot;http://rcm.amazon.com/e/cm?t=one0a5-20&amp;amp;o=1&amp;amp;p=8&amp;amp;l=bpl&amp;amp;asins=0671212095&amp;amp;fc1=000000&amp;amp;IS2=1&amp;amp;lt1=_blank&amp;amp;m=amazon&amp;amp;lc1=0000FF&amp;amp;bc1=000000&amp;amp;bg1=FFFFFF&amp;amp;f=ifr&quot; style=&quot;height: 245px; padding-right: 10px; padding-top: 5px; width: 131px;&quot;&gt;&lt;/iframe&gt;</description><link>http://codinggym.blogspot.com/2010/02/becoming-effective-learner.html</link><author>noreply@blogger.com (Isha Narravula)</author></item></channel></rss>