Skip to content

Instantly share code, notes, and snippets.

@rbwestmoreland
Created December 29, 2011 14:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rbwestmoreland/1534449 to your computer and use it in GitHub Desktop.
Save rbwestmoreland/1534449 to your computer and use it in GitHub Desktop.
Properly Implementing the Abstracy Factory Pattern
using System;
/// <summary>
/// An example abstract factory interface.
/// <para>The Abstract Factory pattern is a creational
/// pattern, whose purpose is to provide an interface
/// for creating families of related or dependent
/// objects, without specifying their concrete
/// classes.</para>
/// </summary>
public interface IAbstractFactory
{
/// <summary>
/// Creates an instance of IObjectA.
/// </summary>
/// <returns>An instance of IObjectA.</returns>
IObjectA CreateInstanceA();
/// <summary>
/// Creates an instance of IObjectB.
/// </summary>
/// <returns>An instance of IObjectB.</returns>
IObjectB CreateInstanceB();
}
using System;
public interface IObjectA
{
void DoWork();
}
using System;
public interface IObjectB
{
void DoWork();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment