Singleton Pattern Added

Today’s design pattern is the Singleton pattern, which makes it impossible to have more than one instance of a class.

Perhaps you have multiple places in your codebase that attempt to open a connection to the database. Without some controls, your code could open multiple connections to the same database.

But with the Singleton pattern, if a connection is already open in an instance of the class, when you try to get an instance of the class, that same instance will always be used.

Posted on September 22, 2009 at 12:01 am by Eric B · Permalink
In: Design Patterns

Leave a Reply

You must be logged in to post a comment.