Design Pattern for using different implementations of a class/method
design-patterns, oop
Solution
I suggest you checking the Bridge pattern. It intent is to decouple an abstraction from its implementation so that the two can vary independently.
The collections class framework in the Java API provides several examples of use of the bridge pattern. Both the ArrayList and LinkedList concrete classes implement the List interface. The List interface provides common, abstract concepts, such as the abilities to add to a list and to ask for its size. The implementation details vary between ArrayList and LinkedList, mostly with respect to when memory is allocated for elements in the list.
Using the Bridge pattern with a Factory to obtain the concrete implementation your client is interested in seems like a suitable approach to your problem.
Problem
Sometimes we design more than one algorithm to get the same results. For instance, I have written a class which stores my data in trees, and another class that stores roughly the same data in, say, linked lists. I will publish an interface (abstract class) called ThingStore, and I'll subclass it to TreeThingStore and ListThingStore, each respectively using trees or linked lists. However, since I'm publishing an abstract class, I have to have someone to decide which implementation to use (EDIT: so the caller won't care about this), and I have no problem in having this hardcoded. I have needed this more than once, but I have looked at GoF and other Design Patterns catalogues unsuccesfully. The most similar pattern is the "Strategy" one, but it achieves diverse goals. So, is there a Design Pattern for this intent? If not, someone can create one or tell me why this should not be done (or better ways to achieve the same results)?