Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.