November 2006 - Posts

Many interesting projects are showing up on www.CodePlex.com such as the Best Practices Analyzer.  This tool is an engine for analyzing applications for Best Practices Compliance.  The tool is Shared Source and is architected using a "Plug-In" design.  This means the tool is easily extendible via new Plug-Ins and rules.

This tool reminds me of FxCop but seems to analyze more than .NET Framework best practices.  It seems the goal of the tool is to be more specific and review the application based on the type of application it is.  For example, the Best Practices Analyzer comes bundled with an ASP.NET 2.0 Plug-In.  Perhaps in the future we will see a Smart Client Plug-In, a WF Plug-In, and a WCF Plug-In?

 

Perhaps Garbage Collection is spoiling us as developers.  The Garbage Collector is like our own maid following us around picking up every mess we create.  Anway, .NET does a great job managing many resources for us including things like memory and conncetion pooling.  However, this doesn't mean we are completely off the hook.

As Dave Strommer recently posted http://drowningintechnicaldebt.com/blogs/davidstrommer/archive/2006/11/10/Connection-Pool-timeout-expired.aspx we experiecened the result of bad assumptions and just lazy coding. 

We learned that .NET 2.0 introduced a new counter called NumberOfReclaimedConnections.  This counter is very important b/c you can confirm an application is leaking connections by watching this counter increase.

Here are some tips to avoid drowning in the connection pool:

  • Close Connections as quick as possible. Get In and Get Out.
  • Do not increase the Max Pool Size Parameter.  The default setting of 100 can support 1000's and 1000's of connections.  If you're experiencing problems something is likely wrong and increasing the Max Pool Size is just a Band Aid that will increase your Technical Debt!
  • Enclose connections with using statements.

using (SqlConnection conn = new SqlConnection(myConnectionString))
{
  conn.open
  // do whatever
} // connection is wrapped in using so it is closed.

  • Enclose data readers with using statements or include try, catch, finally

Rob Conery created the SubSonic project on CodePlex which is an Active Record based DAL.  http://www.codeplex.com/Wiki/View.aspx?ProjectName=actionpack He includes an impressive webcast walking you through a sample implementation.  In a word. WOW! 

Brian Noyes, author of Smart Client Deployment with ClickOnce has authored the Smart Client ClickOnce Resource Kit.  The resource kit download includes a 70 page how-to with best practices for implementing ClickOnce.  The resource kit also provides utilities to help reduce the amount of manual procedures needed to create a Manifest.  Brian Noyes' book addresses some advanced topics such as On Demand Updates (Click Once API).  The sample code is available on his site http://www.softinsight.com/clickoncebook/

We have been working with the CAB and ClickOnce and are investigating On Demand Updates.  These two resources may make our smart client deployments much easier.