It may seem as if this is question is a dupe, but please bear with me - I promise I\'ve read the related posts (and the GOF book).
After everything I\'ve read, I still
Abstract Factory is particularly helpful for test driven development and reducing coupling.
For example, in C#:
public class Worker
{
public IConsumerFactory Factory { get; set; }
private IResource resource;
public DoWork()
{
IConsumer consumer = Factory.CreateConsumer();
consumer.Consume(resource);
}
}
public interface IConsumerFactory
{
IConsumer CreateConsumer();
}
public interface IConsumer
{
void Consume(IResource resource);
}
public class DefaultConsumerFactory : IConsumerFactory
{
public IConsumer CreateConsumer()
{
return new DefaultConsumer();
}
}
public class DefaultConsumer : IConsumer
{
public void Consume(IResource resource)
{
... Do Work ...
}
}
This way, you can use dependency injection to inject the default implementations for production code, and then you can easily mock the factory and the objects it creates.