0

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?

BobDidley
  • 53
  • 6

1 Answers1

0

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.

jaco0646
  • 15,303
  • 7
  • 59
  • 83
  • Mind sharing some examples or clarification of this _factory_ category, I've not heard of this in my research. – BobDidley Nov 10 '22 at 04:11
  • If you're reading the GoF book, you will see that it defines two separate factory patterns. So you will never see the book use the phrase, "_the Factory pattern_" because that would be ambiguous even within one book. In addition, more recent books (such as Head First Design Patterns and Effective Java) have published even more factory patterns, making the phrase, "_the Factory pattern_" even more ambiguous. Ask five developers what a Factory is and you'll get ten answers. The word by itself is so ambiguous that it's virtually meaningless. Which factory pattern are you talking about? – jaco0646 Nov 10 '22 at 14:44
  • Excuse me for the confusion. I'm referring to the Factory Method pattern the simpler version of the Abstract Factory pattern. I've edited the original post to reflect this. – BobDidley Nov 11 '22 at 04:35
  • For the purpose of this question, the particular factory design doesn't matter as much; but for general knowledge purposes, the GoF Factory Method is absolutely _not_ any kind of version of an Abstract Factory. The two are wildly [different](https://stackoverflow.com/a/50786084/1371329) patterns, not to mention the fact that Factory Method has numerous [implementations](https://stackoverflow.com/q/61214535/1371329) which are different as well. – jaco0646 Nov 11 '22 at 13:54