Created
December 11, 2011 16:30
-
-
Save rbwestmoreland/1461409 to your computer and use it in GitHub Desktop.
Properly Implementing the Factory Pattern
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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