Back to list
Views:   8.1K
Replies:  1
Archived

Abstract Factory pattern -- Structural example with interface

Hi,

Can someone show me how to do the sample example of abstract factory:  "Abstract Factory Pattern - Structural Example" as outlined in this site, but with using an Interface?

Regards,
Amees

Amees Bai, Jul 16, 2011
Reply 1
You could replace the AbstractFactory class with this:

public interface AbstractFactory
{
    AbstractProductA CreateProductA();
    AbstractProductB CreateProductB();
}

You could also replace the abstract Product base classes (AbstractProductA and AbstractProductB) with this:

public interface AbstractProductA
{
}

public interface AbstractProductB
{
    void Interact(AbstractProductA a);
}
You'll then have to remove all "override" keywords, because now your classes implement the interface instead of overriding the base class.

Hope this helps.
 
Mathieu Lavigne, Aug 01, 2011


Stay Inspired!
Join other developers and designers who have already signed up for our mailing list.
Terms     Privacy     Licensing       EULA       Sitemap      
© Data & Object Factory, LLC.
Made with    in Austin, Texas.      Vsn 1.2.2