Skip to content

Instantly share code, notes, and snippets.

@rbwestmoreland
Created December 11, 2011 16:30
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rbwestmoreland/1461409 to your computer and use it in GitHub Desktop.
Save rbwestmoreland/1461409 to your computer and use it in GitHub Desktop.
Properly Implementing the Factory Pattern
using System;
/// <summary>
/// A generic factory pattern.
/// <para>The Factory pattern is a creational pattern,
/// whose purpose is to define an interface for
/// creating an object, but let subclasses decide
/// which class to instantiate.</para>
/// </summary>
/// <typeparam name="T">The type created by the factory.</typeparam>
public interface IFactory<T> : IDisposable
where T : IDisposable
{
/// <summary>
/// Create a new instance of the generic type.
/// </summary>
/// <returns>A new instance of the generic type.</returns>
T CreateInstance();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment