Search code examples
design-patternsadapterfactory-pattern

Two Way Adapter or Adapter with Factory?


Two-way or n-way adapters improve transparency by allowing clients to use the adapter in different ways but why not combine the Factory Method pattern with the Adapter pattern and let the client ask the AdapterFactory the concrete adaptation class they need?

I imagine the Factory Method would simplify the process and still achieve the same effect as a n-way adapter, right?


Solution

  • A two-way Adapter is a single concrete implementation used by multiple clients. There is no selection for any factory to make.

    Do note as well, there is no such thing as "the Factory pattern". The word factory describes a category of many (wildly different) creational patterns, both inside and outside the GoF book.