Dave Burke : Freelance .NET Web Developer specializing in Online Communities

DAAB and a private SqlHelper constructor sidetrack

I spent more time with the DAAB today and got sidetracked on the SqlHelper Class being sealed, its methods static, and thus its constructor being private.  Like so:

public sealed class SQLHelper
{
#region private utility methods & constructors

    // Since this class provides only static methods, make the default constructor private to prevent
    // instances from being created with "new SQLHelper()"

    private SQLHelper() {}

As mostly an asp.net guy I don't refer to sealed classes or static methods very often, so I had to dig into why I didn't invoke the default constructor for the class as I normally would with (long version):

Microsoft.ApplicationBlocks.Data.SqlHelper oSqlHelper = new Microsoft.ApplicationBlocks.Data.SqlHelper();

For starters, I want to thank the people who provided this Application Block for doing such an excellent job and for providing such excellent documentation in the SqlHelper.cs code  The "Since this class provides only static methods...private to prevent instances from being created with 'new SqlHelper()'" was a very valuable comment for me.

Comments (0) | Post RSS RSS comment feed

Posted on 9/7/2003 7:55:00 PM by Dave Burke
Categories:
Tags:

Related posts


Powered by BlogEngine.NET 2.0.0.36
Theme by Dave Burke