<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Nagarro Blog &#187; .Net</title>
	<atom:link href="http://www.nagarro.com/blog/category/dotnet/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.nagarro.com/blog</link>
	<description>Nagarro blog: software development, design, architecture and usability</description>
	<lastBuildDate>Tue, 24 Aug 2010 20:57:47 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Nagarro Empowers HKMP Technologies to Secure Strategic Sales Win</title>
		<link>http://www.nagarro.com/blog/nagarro-empowers-hkmp-technologies-to-secure-strategic-sales-win/</link>
		<comments>http://www.nagarro.com/blog/nagarro-empowers-hkmp-technologies-to-secure-strategic-sales-win/#comments</comments>
		<pubDate>Wed, 23 Jun 2010 23:46:47 +0000</pubDate>
		<dc:creator>Vishal Gauri</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[News]]></category>

		<guid isPermaLink="false">http://www.nagarro.com/blog/?p=640</guid>
		<description><![CDATA[At Nagarro we pride ourselves on taking a personal interest not just in the success of each project, but also in the success of each customer. So when one of our custom software products directly benefits a customer’s bottom line, that’s about as good as it gets for us. As you can see from Nagarro’s [...]]]></description>
			<content:encoded><![CDATA[<p>At Nagarro we pride ourselves on taking a personal interest not just in the success of each project, but also in the success of each customer. So when one of our custom software products directly benefits a customer’s bottom line, that’s about as good as it gets for us. As you can see from Nagarro’s press release today- <span style="text-decoration: underline;"><a href="http://www.nagarro.com/NewsEvents/Press%20Releases/Nagarro-Empowers-HKMP.aspx" target="_blank">Nagarro Empowers HKMP Technologies to Secure Strategic Sales Win</a></span>, today is a good day here at Nagarro.<span id="more-640"></span></p>
<p>HKMP Technologies came to us with a tall order– upgrading its market-leading paperless accounting software on a tight deadline in order to secure a strategic customer deal. To make matters more complicated, a new release of Microsoft Silverlight – the technology platform for the product – was scheduled right in the middle of the development cycle.</p>
<p>Our team here at Nagarro approached the problem creatively,<span style="text-decoration: underline;"> </span><a href="http://www.hkmpt.com/pages/press/release13.php"><span style="text-decoration: underline;">allowing HKMP to successfully seal a critical new deal</span> </a>and improve its eco-footprint. For more details, please check out our new<a href="http://www.nagarro.com/Industry%20Solutions/Finance/Case%20Studies/HKMP-Case-Study.aspx"> <span style="text-decoration: underline;">HKMP Technologies case study</span></a> and <span style="text-decoration: underline;"><a href="http://www.nagarro.com/Clients/Video%20testimonials.aspx">customer testimonial video</a></span>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.nagarro.com/blog/nagarro-empowers-hkmp-technologies-to-secure-strategic-sales-win/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Case study: load balancing high transaction volume databases</title>
		<link>http://www.nagarro.com/blog/case-study-load-balancing-high-transaction-volume-databases/</link>
		<comments>http://www.nagarro.com/blog/case-study-load-balancing-high-transaction-volume-databases/#comments</comments>
		<pubDate>Thu, 03 Jun 2010 06:33:10 +0000</pubDate>
		<dc:creator>Girish Chhabra</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[database scaling]]></category>
		<category><![CDATA[SQL Server]]></category>

		<guid isPermaLink="false">http://www.nagarro.com/blog/case-study-load-balancing-high-transaction-volume-databases/</guid>
		<description><![CDATA[Recently, while working on a SQL server optimization project, we had the opportunity to look into one interesting problem. We had a huge database (to the tune of 800GB) which was being hammered with approximately 30000 transactions per second. Database load was expected to grow by a factor of 100 in coming days and the [...]]]></description>
			<content:encoded><![CDATA[<p>Recently, while working on a SQL server optimization project, we had the opportunity to look into one interesting problem. We had a huge database (to the tune of 800GB) which was being hammered with approximately 30000 transactions per second. Database load was expected to grow by a factor of 100 in coming days and the idea was to devise a solution which could handle that load. This was a SQL server 2005 enterprise edition database hosted on an 8 processor fifth Generation server. We wouldn&#8217;t say this server was on its knees with this load but yes there were wait times longer than expected and to add to that there were times when data traffic suddenly went up significantly and in those times DB was not able to keep up. </p>
<p> <span id="more-637"></span>
<p>Though this is not a very common scenario in many of the modern day applications out there but this definitely is a hallmark of databases handling loads from specific industries like banking. Applications intended for these industries normally have huge volume of small database transactions. In this article, we present one of the approaches you can take to handle a scenario such as this.</p>
<h4>Introducing Broker Hub</h4>
<p>To demonstrate the problem which has these type of database requirements, let&#8217;s use the example of a Broker Hub &#8211; a stock broking hub. Stock broking applications have very high volume of small database transactions and also there are spurts in database activity depending on market conditions. For simplicity sake, let&#8217;s assume that we were at a point when database design and usage pattern for Broker hub database was in the most optimal state. </p>
<h4>First choice &#8211; Scale up</h4>
<p>So to optimize Broker Hub further, we had a number of ideas and first choice was obviously to increase the hardware capacity. Increasing the hardware capacity did help the case. We could handle upwards of 50000 transactions a second by moving to a better system with 16 processors and a SAN array of high speed disks. But above 50000 in our load environments, we could still see the database to be the bottleneck. </p>
<p>Next obvious idea was to try SQL Server 2008 which has support for performance optimization features like advanced compression (reducing the overall disk IO) and support for virtually unlimited number of objects (2,147,483,647) and database size (524,272 TB). Again we could see the difference. Without enabling features like compression we could achieve a bigger number of around 70000 transactions per second. </p>
<h4>Would it work? Probably not long term.</h4>
<p>Probably enabling compression and using other features to optimize performance would have resulted in a higher figure but the problem here was that there was a limit to this. Adding hardware or moving to newer version of a database (or even to a different database) wouldn&#8217;t have given us the virtually unlimited (100 times 30000 transactions per minute) capacity we were looking at. Obviously we needed some way to deploy more than one server to split the load and thus increase the capacity to handle very high transaction loads. In simpler terms we needed a scale out solution instead of scale up for our database. Looking around for out of the box solutions in the market didn&#8217;t help, simply because there aren&#8217;t many scale-out solutions available in the market to load balance SQL server. Oracle has launched such a solution but even that requires syncing between different servers in cluster which takes up a lot of network bandwidth thus reducing the overall effectiveness of the solution. </p>
<h4>Scale out &#8211; Approach </h4>
<p>After a lot of brainstorming sessions, it was decided that it was time to create our own scale out solution. The idea was to create a design which could help us scale out as our user base grew but at the same time being able to handle sudden increases in transaction volumes. But as it happens all the time, we didn&#8217;t have too much money to be spent on this. We looked at various existing products such as SharePoint to see how they stored their data and came up with a very simple first draft of the scale out solution. It looked very similar to way SharePoint does load balancing for its data stores. We had a cluster of database servers connected to the Broker Hub. Each database was configured to handle a set of users with specific user Ids and thus held data only for those users. Merge replication was used to replicate data from all databases to a central database which was used for all reporting. Here&#8217;s how it looked like:</p>
<p><img style="border-bottom: 0px; border-left: 0px; margin: 10px auto; display: block; float: none; border-top: 0px; border-right: 0px" title="clip_image002" border="0" alt="clip_image002" src="http://www.nagarro.com/blog/wp-content/uploads/2010/06/clip_image002.jpg" width="575" height="490" /></p>
<p>Broker Hub front end had to be modified a bit in terms of process flow. In this case, each user logging into Broker Hub had to be connected to a specific database based on his user id. The task of identifying which database has the information related to the user trying to log in was handled by a new module added to the application called DB Load balancer. The process flow in this approach looked like this:</p>
<ul>
<li>User foo with User ID (n) logs in.</li>
<li>Application calls Custom DB load balancer to find out that all data specific to user foo is on database server DB 2.</li>
<li>Application creates a connection to DB 2 on behalf of this user.</li>
<li>All user transactions from User 1 are directed to DB 2 thereafter.</li>
<li>Periodically user data is synchronized to the master database.</li>
</ul>
<h4>Design Decisions for this approach</h4>
<p>This approach was pretty simple to implement and could achieve the results we were looking for. But there were a few practical issues:</p>
<ul>
<li>We have to introduce concept of ID buckets. So every transaction table on each server was assigned unique bucket from which it could allocate Ids. With this we overcame the problem of how to maintain unique IDs. </li>
<li>All the masters would be replicated using transaction with update option. So a change on one gets replicated all over.</li>
<li>Adding new users was not as simple as before. Every database was configured for a specific set of users and this set increased sequentially. This meant that we always had to add the new user in the last server available and if last server was full then we had to deploy a new database even for a single user (and probably even before the last server was at its full capacity). This was accepted as an acceptable fact as this would happen once a while.</li>
<li>Any admin report had to combine the data from all the servers to be useful which meant an additional job to aggregate all the data. This was accepted as a design reality.</li>
</ul>
<h4>Conclusion</h4>
<p>So we could see very clearly that we were achieving the desired performance figures for this approach. Our aim was to find out how best we could achieve load balancing capabilities for the specific database load our application was creating and that was achieved. It actually became a life saver for us in more than one situation.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.nagarro.com/blog/case-study-load-balancing-high-transaction-volume-databases/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>.NET Reflection: The untouchable? No, not at all.</title>
		<link>http://www.nagarro.com/blog/net-reflection-the-untouchable-no-not-at-all/</link>
		<comments>http://www.nagarro.com/blog/net-reflection-the-untouchable-no-not-at-all/#comments</comments>
		<pubDate>Sun, 18 Oct 2009 14:08:25 +0000</pubDate>
		<dc:creator>Vikas Burman</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[Concepts]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.nagarro.com/blog/net-reflection-the-untouchable-no-not-at-all/</guid>
		<description><![CDATA[I am a big fan of .NET reflection. However most often you will hear more of critics than praise. The biggest of all &#8220;It’s slow.&#8221; Web is full of cautions and warnings telling you not to use it. Some will go as far as saying that if you care for performance, do not even think [...]]]></description>
			<content:encoded><![CDATA[<p>I am a big fan of .NET reflection. However most often you will hear more of critics than praise. The biggest of all &#8220;<em>It’s slow.</em>&#8221; Web is full of cautions and warnings telling you not to use it. Some will go as far as saying that if you care for performance, do not even think about using reflection. If you go on and read beyond the highlight points, you will realize that a large percentage of these warnings and cautions are discussing a particular scenario where some developer failed to get what s/he was trying to achieve. And while being judgmental with the experiment a generalized statement like this comes up as an end result.<span id="more-453"></span></p>
<p>The problem of making such general rules about programming practices is that you tend to miss out the benefits by following these rules too literally in every context. Think it on the lines – Reflection or any feature for that matter, if included must have a valid reason for its presence. We should be able to see and know how and when to use it and when specifically to avoid it.</p>
<p>Reflection is slow; but the question is <em>how slow is slow?</em> One should worry about performance but this worry should not keep you away from making best use of a technology. If you look around in .NET world, you will realize that .NET framework itself uses a lot of reflection. Ability to store meta-data about your code and to be able to use it at runtime opens the door to a whole lot of possibilities limited only by your imagination.</p>
<p><!--more--></p>
<p>If you rethink it it’s just one another way of storing and working with information; difference being that this information is stored in code itself. So instead of retrieving information from some XML file or database, you are pulling it in from the code itself. Therefore your concerns towards writing optimized code while reading data from XML (e.g., load once read many times) or from database (e.g., making fewer trips to database), etc. will not be much different when using reflection. You might want to fetch type info once and hold it for future calls as well instead of fetching it every time you need it.</p>
<p>As in case of database, we know where to use joins, on which columns to create indexes and which <em><strong>where</strong></em> clauses to use to get optimized execution time; in case of reflection too there is a well defined grammar to make optimized reflective calls. For example, using <strong><em>BindingFlags</em></strong> enumeration correctly, not trying to use <strong><em>IgnoreCase</em></strong> flag, and limiting your searches to <strong><em>public</em></strong> or <strong><em>static</em></strong> or <strong><em>instance</em></strong> members as required, will definitely give you best possible results. <a href="http://msdn.microsoft.com/en-us/magazine/cc163759.aspx">Joel Pobar’s post</a> talks at length about how reflection works internally and is a good reference to understand how to avoid performance pitfalls.</p>
<p>Don’t just assume that reflection will hit the performance, but use it, test it, tweak it for performance optimization and enjoy the flexibility it provides. If you think your problem statement has a solution in reflection; don’t hesitate in going ahead just because someone says that it will be slow. If this turns out to be slow; there are ways to optimize it too. For instance <a href="http://msmvps.com/blogs/jon_skeet/archive/2008/08/09/making-reflection-fly-and-exploring-delegates.aspx">Jon Skeet’s post</a> talks about using <strong><em>Delegate.CreateDelegate</em></strong> to turn a <strong><em>MethodInfo</em></strong> into a strongly-typed delegate. This can improve performance massively in scenarios where you need to set the same properties multiple times. Essentially this means that a lot of the type checking is done once when you created the delegate, rather than on every invocation.</p>
<p>Let’s explore a scenario where reflection is no harm to use and probably the only way you can achieve the end result with.</p>
<p><strong><em>You want dynamic extensibility to your desktop application; your revenue model includes selling various groups of features separately. You do not want to build multiple deployment packages and you want to be able to provide even more features to your customers after they have started using your application.</em></strong> How would you do it?</p>
<p>You might do this by developing a plug-in model in your application.</p>
<p>You may define an <em>IMyAppPlugin</em> interface which can be implemented in each of your application’s plug-in assembly implementing a specific feature. At minimum you may have following definition:</p>
<pre class="csharpcode"><span class="kwrd">public</span> <span class="kwrd">interface</span> IMyAppPlugin
{
    Guid Identifier { get; }
    <span class="kwrd">string</span> Name { get; }
    <span class="kwrd">string</span> Copyright { get; }
    <span class="kwrd">bool</span> Start(IHostApp hostApp);
    <span class="kwrd">void</span> Stop();
    <span class="kwrd">bool</span> Run();
}</pre>
<p>You will not have any reference of these assemblies in your project at design time. Its only at runtime when you will try to discover these plug-in assemblies (using some mechanism such as looking in specific folder or registry, an XML file or anything else) and load it using reflection.</p>
<p>You will write code to find and create instance of the class that implements this IMyAppPlugin interface. Once you have this object you can initialize it by calling its <em>Start()</em> method passing your application’s reference as required. You may also write code to add access points (such as menu items) for this dynamic functionality to appear in your application’s user interface when this plug-in is successfully loaded.</p>
<p>A call to <em>Run()</em> method anytime after this will do what is desired.</p>
<p>So essentially what we are doing here is that we have loaded the assembly using reflection and we are calling methods dynamically again using reflection. If we just go by numbers, yes dynamically invoking a method is slow. Referring to <a href="http://www.west-wind.com/weblog/posts/351.aspx">Rick Strahl’s post</a> we can say that invoking a method dynamically is about 3.5 to 4 times slower than directly calling of a method. But again the question needs to be asked – <em>how slow is slow?</em> Here we are talking about few milliseconds extra. Unless you are making calls in a loop for a large number of times, does it really matter in the larger perspective of a typical application? Most likely – No!</p>
<p>Remember .Net Framework and especially ASP.Net uses a lot of reflection internally to provide dynamic execution of code and controls.</p>
<p>Talking again about the above scenario, if not reflection, do we have some other relevant approach of dynamically extending the application? You may talk about using COM interfaces to achieve it – but reflection or no reflection – the essence of every approach is to dynamically resolve the address of the method to be called, which is the only major difference wrt static calls where this address is readily available.</p>
<p>This is just one scenario where reflection proves to be the most effective and simplified approach to work with. There are a lot of other scenarios where reflective access to properties, fields and methods provides enormous flexibility that simply wouldn&#8217;t be there otherwise.</p>
<p>With <a href="http://msdn.microsoft.com/en-us/library/dd233052(VS.100).aspx">Dynamic Language Runtime</a> (DLR) in .NET 4.0 we are heading towards a cleaner reflection. Eventually this may replace reflection how we see it today, due to its simplified code and caching advantages. In-fact as mentioned in this <a href="http://blogs.msdn.com/hugunin/">Jim hugunin’s post</a>, it appears that DLR too internally makes good use of reflection.</p>
<p>In short, do not shy away from using reflection, just because you hear warnings about it. Always verify if these warnings apply to your project or scenario. Often they will not. As they say, “trust but verify!</p>
<p><!--.csharpcode, .csharpcode pre { 	font-size: small; 	color: black; 	font-family: consolas, "Courier New", 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; } --></p>
]]></content:encoded>
			<wfw:commentRss>http://www.nagarro.com/blog/net-reflection-the-untouchable-no-not-at-all/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>A better way to test email sending functionality is to use your own SMTP Server</title>
		<link>http://www.nagarro.com/blog/a-better-way-to-test-email-sending-functionality-is-to-use-your-own-smtp-server/</link>
		<comments>http://www.nagarro.com/blog/a-better-way-to-test-email-sending-functionality-is-to-use-your-own-smtp-server/#comments</comments>
		<pubDate>Mon, 29 Jun 2009 07:09:14 +0000</pubDate>
		<dc:creator>Vaibhav Gadodia</dc:creator>
				<category><![CDATA[Testing]]></category>
		<category><![CDATA[Tools and Utilities]]></category>
		<category><![CDATA[Email]]></category>
		<category><![CDATA[SMTP Server]]></category>

		<guid isPermaLink="false">http://www.nagarro.com/blog/a-better-way-to-test-email-sending-functionality-is-to-use-your-own-smtp-server/</guid>
		<description><![CDATA[A large number of applications today have some kind of a notification mechanism built-in. More often than not, an email is used to send these notifications. Typically, while developing these applications, developers use their own inbox to send notifications to. Or they setup some dummy account to send test emails to; or sometimes they might [...]]]></description>
			<content:encoded><![CDATA[<p>A large number of applications today have some kind of a notification mechanism built-in. More often than not, an email is used to send these notifications. Typically, while developing these applications, developers use their own inbox to send notifications to. Or they setup some dummy account to send test emails to; or sometimes they might send test mails to real users (it&#8217;s been known to happen).<span id="more-335"></span></p>
<p>There are many limitations to this approach:</p>
<ul>
<li>one has to deal with dummy messages arriving in the inbox, when all that you want to test is your email sending code.</li>
<li>automating the testing of the email sending code will result in a large number of emails being generated and delivered to your inbox.</li>
<li>code that is supposed to deliver large amounts of email will generate a lot of load on the Internet bandwidth (and yes that can be a problem).</li>
<li>if you are testing on a copy of a production database, you might inadvertently end up sending test emails to real users.</li>
</ul>
<p>There are other issues present as well. One solution to solving these problems is to use your own SMTP server to handle all these emails in a manner that it receives an email and doesn&#8217;t sent it forward. So, it is like a dummy SMTP server. But setting up an SMTP server is usually a hassle.</p>
<p><!--more--></p>
<p>There are plenty of options out there which make your job much easier than you think it is. In this post, I am going to list some solutions which can be used (though there are many more). The basic premise behind this approach is to run a local SMTP server (either on the developer box, or the test server, or both, or somewhere on the LAN). This local SMTP server address is what is configured as the server address in your application which is being tested. Any mail sent to such a server is kept with the server and not forwarded, thus preventing all the above listed issues.</p>
<p>Following are some of the more popular out-of-the-box programs that can be used (click on the names to go to their websites):</p>
<ul>
<li><a href="http://invalidlogic.com/papercut/"><strong>Papercut</strong></a><strong> </strong>- this is a simple windows application which will run in your System Tray and simulate an SMTP server; it receives and stores any messages it receives. It allows you to view the messages. It sits in your system tray and alerts you whenever a new message arrives.</li>
<li><a href="http://www.donovanbrown.com/post/2008/10/20/Neptune.aspx"><strong>Neptune</strong></a><strong> &#8211; </strong>this is another application which will do a similar task. It is however a little more advanced. It has an admin API interface which allows you to run custom queries to analyze the messages that it processes. It doesn&#8217;t have a UI through which you can view the received message though &#8211; but sometimes all you need to check is if the messages are being delivered. Very useful in a bulk messaging scenario.</li>
<li><a href="http://smtp4dev.codeplex.com/"><strong>smtp4dev</strong></a> &#8211; this is another option similar to Papercut, which again sits in the system tray and will let you know whenever any message arrives and will let you look at the message details.</li>
</ul>
<p>There are many more out there which can be used to do similar things with some features here and there (for example, Neptune doesn&#8217;t generate all SMTP responses). Here&#8217;s a post by Phil Haack from long ago which is also interesting: <a href="http://haacked.com/archive/2006/05/30/ATestingMailServerForUnitTestingEmailFunctionality.aspx">A testing mail server for unit testing email functionality</a>.</p>
<p>So, when you feel the need to test your email sending code the next time, it might make sense to have one of the tools (or something similar) available.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.nagarro.com/blog/a-better-way-to-test-email-sending-functionality-is-to-use-your-own-smtp-server/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>The Ado.Net Entity Framework v2, are we there yet?</title>
		<link>http://www.nagarro.com/blog/the-adonet-entity-framework-v2-are-we-there-yet/</link>
		<comments>http://www.nagarro.com/blog/the-adonet-entity-framework-v2-are-we-there-yet/#comments</comments>
		<pubDate>Mon, 08 Jun 2009 10:11:48 +0000</pubDate>
		<dc:creator>Vaibhav Gadodia</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[Ado.Net]]></category>
		<category><![CDATA[Entity Framework]]></category>

		<guid isPermaLink="false">http://www.nagarro.com/blog/the-adonet-entity-framework-v2-are-we-there-yet/</guid>
		<description><![CDATA[At Nagarro, we are always looking to stay tuned into upcoming technology (of all types &#8211; gadgets to frameworks); and the current flavor is of course Visual Studio 2010 and .Net Framework 4. We have been trying out the beta and the earlier preview versions of VS2010, however, that is not the topic of this [...]]]></description>
			<content:encoded><![CDATA[<p>At <a href="http://www.nagarro.com/">Nagarro</a>, we are always looking to stay tuned into upcoming technology (of all types &#8211; gadgets to frameworks); and the current flavor is of course Visual Studio 2010 and .Net Framework 4. We have been trying out the beta and the earlier preview versions of VS2010, however, that is not the topic of this post.</p>
<p>Recently, we had the opportunity to give our opinion on the latest avatar of the Ado.Net Entity Framework to Jeffrey Schwartz from Application Development Trends magazine. Jeff was kind enough to publish our opinions in an article on the Visual Studio Magazine (thank you Jeff). The article is titled &#8220;<a href="http://visualstudiomagazine.com/blogs/data-driver/2009/06/will-entity-framework-2-appease-early-adopters-of-linq-to-sql.aspx">Will Entity Framework 2 appease early adopters of LINQ to SQL?</a>&#8220;. We, as can be deduced, were early adopters of LINQ (to SQL and others).</p>
<p>If you would like to see that question answered, I urge you to go and read that article. In this article, I wanted to discuss a little bit more about how we look at Entity Framework v2.</p>
<p> <span id="more-304"></span>
<p>When Microsoft first announced the Ado.Net Entity Framework, we were unsure about what to do with it. We had already started training our developers on LINQ to SQL, and some of our projects were already using the technology. We found it (L2S) to be a very good way to implement the ORM layer of an application (and that worked very well in most cases). Additionally, we weren&#8217;t sure how mature the framework was. Sure, it looked perfect for some of our larger projects, but somehow it wasn&#8217;t fitting the bill (and we were not alone). And compared to LINQ to SQL, it felt quite lackluster in features.</p>
<p>The new version of the Entity Framework looks much better. It almost feels as if Microsoft went out of their way to ensure that Ado.Net EFv2 can stand on its own when compared to LINQ to SQL. However, by this time, we are pretty invested in LINQ to SQL, so there is no question of moving any of our existing projects over. But, we are very keen to try out the EFv2 in newer projects and internal applications. Specifically, we will looking at integrating it the next version of our Nagarro .Net Application Framework (which is a base framework that we use for most of our projects).</p>
<p>&#8220;<strong>Are we there yet?</strong>&#8221; &#8211; I would say, almost. The latest version of the Entity Framework looks a much more complete product as compared to the earlier version. Some of the features from an implementation-as-a-tool-in-a-software-development-services-shop perspective are really great:</p>
<ul>
<li><strong>POCO support </strong>- the support for persistence ignorant objects make a great deal of difference because we can continue to leverage the features of the Entity Framework while using your own custom data layer logic alongside it. This is beneficial because this means we can at least consider using the EF in existing applications where the data model and the layers are already defined.</li>
<li><strong>First class code generation &#8211; </strong>this will come as a relief to most developers. The code generation engine, T4, is much more versatile that what we used to have earlier. This means that each application development team can customize the code generation a little bit according to their specific needs.</li>
</ul>
<p>And of course there are hosts of improvements in general and there are tons of articles covering those.</p>
<p>From Nagarro&#8217;s perspective, <strong>I think we are almost there</strong>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.nagarro.com/blog/the-adonet-entity-framework-v2-are-we-there-yet/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Use the features of the .Net framework to implement good coding patterns</title>
		<link>http://www.nagarro.com/blog/use-the-features-of-the-net-framework-to-implement-good-coding-patterns/</link>
		<comments>http://www.nagarro.com/blog/use-the-features-of-the-net-framework-to-implement-good-coding-patterns/#comments</comments>
		<pubDate>Wed, 29 Apr 2009 21:55:02 +0000</pubDate>
		<dc:creator>Ramesh Soni</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[Code Snippets]]></category>
		<category><![CDATA[.net framework]]></category>
		<category><![CDATA[event processing]]></category>
		<category><![CDATA[IDisposable]]></category>
		<category><![CDATA[Tips and Tricks]]></category>

		<guid isPermaLink="false">http://www.nagarro.com/blog/?p=200</guid>
		<description><![CDATA[In our haste to finish the coding of a given application, we often overlook great little techniques which can be deployed to ensure best practices in code. And since one of the best ways to learn is by example, we will walk through a very common block of code that is found in almost all [...]]]></description>
			<content:encoded><![CDATA[<p>In our haste to finish the coding of a given application, we often overlook great little techniques which can be deployed to ensure best practices in code. And since one of the best ways to learn is by example, we will walk through a very common block of code that is found in almost all Windows based applications &#8211; the block which shows and hides a wait cursor when a time consuming task is being executed by the application.<span id="more-200"></span></p>
<p>A quick  review of event processing in Windows Application tells us that there are 3 different types:</p>
<ol>
<li><strong>Quick Processing (less than a second) &#8211; </strong>Action performed is executed almost instantaneously without any significant wait period. In this case, you would generally not display any indication to the user about the background task execution. For instance, Open a dialog on the Click of a button.</li>
<li><strong>Short Processing (1 second &#8211; 5 seconds) &#8211; </strong>User action consumed a few seconds in execution. In such cases, recommended practice is to show a wait cursor. For instance, Pick records from database to list them in the application screen requested by the user.</li>
<li><strong>Long Processing (more than 5 seconds) -</strong> Actions which involve a significantly longer processing time, in such cases it is recommended to show progress bar indication to users.<!--more--></li>
</ol>
<p>In order to display a wait cursor (category 2 above) the following is the most common block of code seen in most applications:</p>
<pre class="csharpcode"><span class="kwrd">public</span> <span class="kwrd">object</span> GetData(<span class="kwrd">int</span> id)
{
    Cursor.Current = Cursors.WaitCursor;
    <span class="kwrd">try</span>
    {
        <span class="rem">// Processing code here    </span>
    }
    <span class="kwrd">finally</span>
    {
        Cursor.Current = Cursors.Default;
    }
}</pre>
<p>The code piece above will have to be duplicated at all the places where we want to use wait cursor during processing, this would be a pretty tedious task. Now, let&#8217;s have a look at another approach to implement the same feature:</p>
<pre class="csharpcode"><span class="kwrd">using</span> System;
<span class="kwrd">using</span> System.Windows.Forms;

<span class="kwrd">public</span> <span class="kwrd">class</span> WaitCursor : IDisposable
{
    <span class="kwrd">private</span> Cursor cursor;

    <span class="kwrd">public</span> WaitCursor()
    {
        cursor = Cursor.Current;
        Cursor.Current = Cursors.WaitCursor;
    }

    <span class="kwrd">public</span> <span class="kwrd">void</span> Dispose()
    {
        Cursor.Current = cursor;
    }
}</pre>
<p>The WaitCursor class above implements <a href="http://msdn.microsoft.com/en-us/library/system.idisposable.aspx">IDisposable</a> interface, hence you may use this is the using block. Now see how simple it is to add a wait cursor to your application:</p>
<pre class="csharpcode"><span class="kwrd">public</span> <span class="kwrd">object</span> GetData(<span class="kwrd">int</span> id)
{
    <span class="kwrd">using</span> (<span class="kwrd">new</span> WaitCursor())
    {
        <span class="rem">// Processing code here</span>
    }
}</pre>
<p>There are some very obvious benefits by doing it this way:</p>
<ul>
<li>It simplifies the code at several places into a single line statement.</li>
<li>More importantly, we just ensured that a bug where some developer forgot to restore the cursor to normal can never happen (as long as we have trained our team to simply call the above code).</li>
<li>Finally, it is always a best practice to encapsulate repeated code in one place.</li>
</ul>
<p>One should always be on the lookout for such small coding patterns and implement them.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.nagarro.com/blog/use-the-features-of-the-net-framework-to-implement-good-coding-patterns/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Application programming in the era of multicore processors</title>
		<link>http://www.nagarro.com/blog/application-programming-in-the-era-of-multicore-processors/</link>
		<comments>http://www.nagarro.com/blog/application-programming-in-the-era-of-multicore-processors/#comments</comments>
		<pubDate>Wed, 15 Apr 2009 20:44:55 +0000</pubDate>
		<dc:creator>Abhijat Vatsyayan</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Tools and Utilities]]></category>
		<category><![CDATA[Concurrent programming]]></category>

		<guid isPermaLink="false">http://www.nagarro.com/blog/?p=142</guid>
		<description><![CDATA[Computer chip manufacturers cannot keep on increasing the clock speed indefinitely to make their processors faster. They seem to have already reached the limit (on clock speed) and have started putting multiple independent processing cores on a single chip to increase the computational capacity. As most systems start running on processors with tens of cores (if [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;"><span style="color: #000000;">Computer chip manufacturers cannot keep on increasing the clock speed indefinitely to make their processors faster. They seem to have already reached the limit (on clock speed) and have started putting multiple<span id="more-142"></span> independent processing cores on a single chip to increase the computational capacity. As most systems start running on processors with tens of cores (if not hundreds right away) application programmers will need to start relying on concurrent programming to make their applications faster and responsive. This will lead to significant changes in the way we design, develop, debug and test programs. We will have new tools, APIs, compilers, languages and frameworks for supporting highly concurrent programs written by application programmers.</span></p>
<p><span style="color: #000000;">The first and most obvious change will be that programmers will start using many more threads and use current lock based approaches to synchronize access to shared data. Now detecting bugs in multithreaded programs is extremely difficult and as we write more concurrent programs, it will become increasingly important to have tools which can check our programs for correctness. Two such tools are <span style="text-decoration: underline;"><a href="http://research.microsoft.com/en-us/projects/chess/" target="_blank">CHESS</a></span> from Microsoft research and <span style="text-decoration: underline;"><a href="http://fsl.cs.uiuc.edu/index.php/JPredictor" target="_blank">jPredictor</a></span> from UIUC. Both are still research projects but are definitely worth taking a look at and playing around with.</span></p>
<p style="text-align: justify;"><span style="color: #000000;">The transactional memory research community advocates getting rid of lock based approach for managing access to shared data. The idea comes from the database world where transactions have been around for a long time. Hardware transactional memory, hybrid transactional memory and software transactional memory, the three broad categories in which implementations are often split, are all under active research but there already are quite a few implementations out there for you to play around with. One of the core ideas behind using transactional memory for accessing shared data is to allow users to specify &#8220;what&#8221; needs to be synchronized and then let the machine take care of the &#8220;how&#8221; part (compare this to how you use locks today). This is supposed to greatly simplify the concurrent programming model but it is too early to say if it really does make the programming model simpler.</span></p>
<p style="text-align: justify;"><span style="color: #000000;">While  I cannot cover or summarize the work being done on transactional memory without making it into a small project, I can provide a few starting points that you may find interesting. Microsoft is doing very interesting work in this area and while a lot of it uses Haskel, there is a <span style="text-decoration: underline;"><a href="http://research.microsoft.com/en-us/downloads/6cfc842d-1c16-4739-afaf-edb35f544384/default.aspx" target="_blank">C-sharp API for software transactional memory</a></span> that you should look at. If you are a Java programmer, you should take a look at <span style="text-decoration: underline;"><a href="http://www.sun.com/download/products.xml?id=453fb28e" target="_blank">DSTM2</a></span>. And irrespective of what technology you use for building systems, I will recommend reading publications on transactional memory by Maurice Herlihy, Simon Peyton-Jones, Victor Luchangco and Mark Moir (there are others, I just picked up the four I see often in the literature).</span></p>
<p style="text-align: justify;"><span style="color: #000000;">Finally, we should not ignore the world of message passing. <span style="text-decoration: underline;"><a href="http://www.openmp.org/" target="_blank">OpenMP</a></span> and <span style="text-decoration: underline;"><a href="http://erlang.org/" target="_blank">Erlang</a></span> have been around for a long time and are designed for concurrent programming. OpenMP is an API you can use from C/C++ and FORTRAN to write parallel programs to take advantage of shared-memory architectures.  Erlang is a programming language in which you write processes that communicate exclusively using messages and if you write your Erlang programs correctly, you get the ability to scale to hundreds of processors for free.</span></p>
<p style="text-align: justify;"><span style="color: #000000;"><br />
</span></p>
<p style="text-align: justify;"><span style="color: #000000;"><br />
</span></p>
]]></content:encoded>
			<wfw:commentRss>http://www.nagarro.com/blog/application-programming-in-the-era-of-multicore-processors/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>A readymade caching solution for scalable .Net applications</title>
		<link>http://www.nagarro.com/blog/shared-cache/</link>
		<comments>http://www.nagarro.com/blog/shared-cache/#comments</comments>
		<pubDate>Wed, 15 Apr 2009 11:36:08 +0000</pubDate>
		<dc:creator>Vikas Gandhi</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[Tools and Utilities]]></category>
		<category><![CDATA[caching]]></category>

		<guid isPermaLink="false">http://www.nagarro.com/blog/?p=133</guid>
		<description><![CDATA[One of the challenges of scaling out applications through server farms is the need to share memory artifacts (session and cache). There are of course many techniques which can be employed. As always, looking around the Internet  reveals that there are good solutions already available.
Recently, I evaluated SharedCache, which according to their website is a [...]]]></description>
			<content:encoded><![CDATA[<p>One of the challenges of scaling out applications through server farms is the need to share memory artifacts (session and cache). There are of course many techniques which can be employed. As always, looking around the Internet <span id="more-133"></span> reveals that there are good solutions already available.</p>
<p>Recently, I evaluated <a href="http://www.sharedcache.com/" target="_blank">SharedCache</a>, which according to their website is a high performance distributed and replication cache system built for .Net applications running in server farms. The system is made available to .Net applications through a Windows service.</p>
<p> Some of the key features are listed of SharedCache are listed below:</p>
<ul>
<li>Works for both web and non-web solutions.</li>
<li>Is extremely fast for fetch.</li>
<li>It supports multiple topologies: distributed partitioned caching, replicated caching, and single instance caching. You can choose which you need based on your requirements (for example, you may want to choose replicated caching over single caching to ensure that you don&#8217;t have any single points of failure)</li>
<li>In case of Caching, one of the most important aspect is purging. With SharedCache, you have a choice to make amongst the several that are supported:
<ul>
<li>Cache Item Priority</li>
<li>Least Recent Used Item (LRU)</li>
<li>Least Frequently Used Item (LFU)</li>
<li>Time based</li>
<li>Biggest Latency First (BLF)</li>
<li>Lowest Latency First (LLF)</li>
<li>Hybrid &#8211; Creating an index based on various item attributes such as: time in cache, Amount of requests, Size, Cache Life Time, etc.</li>
</ul>
</li>
<li>Configurable maximum cache size and the load factor when the system starts to purge cached items.</li>
</ul>
<p>You can install the service by downloading it from <a href="http://www.codeplex.com/SharedCache/SourceControl/ListDownloadableCommits.aspx" target="_blank">CodePlex</a>. And several samples and discussions are available at the <a href="http://netrsc.blogspot.com/search/label/SharedCache" target="_blank">author&#8217;s blog</a>. The best thing about this service is that there is plenty of documentation to guide you.</p>
<p>Just try it out. Its pretty cool.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.nagarro.com/blog/shared-cache/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Log your exceptions to the cloud</title>
		<link>http://www.nagarro.com/blog/an-alternative-way-to-do-exception-logging/</link>
		<comments>http://www.nagarro.com/blog/an-alternative-way-to-do-exception-logging/#comments</comments>
		<pubDate>Fri, 20 Mar 2009 07:58:04 +0000</pubDate>
		<dc:creator>Vaibhav Gadodia</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[Framework]]></category>
		<category><![CDATA[Exception Logging]]></category>

		<guid isPermaLink="false">http://www.nagarro.com/blog/an-alternative-way-to-do-exception-logging/</guid>
		<description><![CDATA[Exception Logging is always an interesting problem to solve. Depending on your needs you may have a simple log statement which writes to a text file, or you may need to have a full-fledged exception management module which logs exceptions to the database, categorized them, and generates notifications. There is no single solution for how [...]]]></description>
			<content:encoded><![CDATA[<p>Exception Logging is always an interesting problem to solve. Depending on your needs you may have a simple log statement which writes to a text file, or you may need to have a full-fledged exception management module which <span id="more-108"></span>logs exceptions to the database, categorized them, and generates notifications. There is no single solution for how to log and manage your exceptions. It helps then to be aware of as many techniques and options as you can; since you never know which will come in handy in a situation.</p>
<p>One method to log exceptions is to log them in the cloud. And there exists a useful service which makes your job easier.</p>
<p> <!--more-->
<p>A service in the cloud represents a service that is hosted on the Internet, available to you through an API, so that you have no idea how it is physically implemented. This makes things simple for you since you don&#8217;t have to worry about writing implementation code for the exception logging and reporting framework. You only need to call it.</p>
<p>The service that I am discussing is called <a href="http://www.hoptoadapp.com/" target="_blank">HopToad</a>. The service offers a simple to use API which allow you to log exceptions from your application. The exceptions are stored in the cloud and are available to you from a central web-based console. All the logged exceptions are presented in easy to understand and navigable way. For example, you can see which errors are occurring most often, or which one is the latest error that came up and from where. You can look at error details and stack traces.</p>
<p>The service developed to be used from within RubyOnRails applications. However, they have an open API, and can be accessed through any technology stack. K. Robertson has made a .Net wrapper available for logging to HopToad. It&#8217;s called <a href="http://github.com/krobertson/hopsharp/tree/master" target="_blank">HopSharp</a>. It is fairly straight forward to use (just drop the DLL in your application and you are good to go). I can imagine that it would be straight forward to write a Log4Net extension for this service as well.</p>
<p><strong>When to use this?</strong></p>
<p>So, when would you use something like this. While the final decision to use this would vary from project to project and client to client, I can think of the following scenarios:</p>
<ul>
<li>The application is a work in progress and you are expected to release a number of updates. Typically, in such scenarios, a lot of testing happens while the application is in deployed state. A logging framework such as this will allow you to monitor the application as it is being used, and priorities on bugs can be assigned based on frequency and severity. </li>
<li>You have an application deployed at multiple locations and you would like to see a consolidated view of the exceptions being reported. </li>
<li>As a way to save time and effort. This is a ready made framework where you don&#8217;t need to impart any effort for implementing an exception logging and notification system. </li>
</ul>
<p>I am pretty sure that there are other such services out there.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.nagarro.com/blog/an-alternative-way-to-do-exception-logging/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
