I was looking for a pattern/solution that allows me call a method as a runtime exception in a group of different methods without using Reflection. I've recently become aware of the Abstract Factory Pattern.

To me, it looks so much like polymorphism, and I thought it could be a case of polymorphism but without the super class GUIFactory, as you can see in the example of the link above. Am I correct in this assumption?

  • What WidgetFactory?
    – yannis
    Commented Nov 29, 2011 at 1:23
  • Check this out: en.wikipedia.org/wiki/Abstract_factory_pattern
    – rogcg
    Commented Nov 29, 2011 at 14:09
  • Yes I've seen the article, there's no WidgetFactory class. Did you mean GUIFactory?
    – yannis
    Commented Nov 29, 2011 at 14:15
  • Correct, GUIFactory.
    – rogcg
    Commented Nov 30, 2011 at 19:36

1 Answer 1


I guess it depends on how it is used.

Essentially the Factory pattern is a reference to a set of objects. Normally combined with something else, possibly like the Strategy pattern (which is more likely to be defined as a type of polymorphism) to provide reference to an object to act on.

The Abstract Factory Pattern by itself is intended to be polymorphic as it is defined as an abstract class type. However the concrete implementation of the factory is the WidgetFactory in your type and is only polymorphic in reference to using a factory and providing an implementation of a factory.

In terms of what you are after, you certainly require a concrete factory, and presumably the actions you perform depend on the exception being caught. To that end you would use your factory implementation in a non-polymorphic way simply by passing it the exception caught, and have the factory pattern return a method to invoke a strategy or even a chain-of-command pattern to deal with how you would like to handle the exception.

Therefore, your factory would not necessarily be polymorphic, and your exception handlers would be polymorphic.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.