0

I was reading Design Patterns by GOF and pluggable adapters caught my eye. I read up on this conversation https://coderanch.com/t/98662/engineering/pluggable-adapter and I like this answer Pluggable Adapter as mentioned in the GOF but still had a few questions:

  1. Why are pluggable adapters not used more often? They provide more flexibility but according to GOF an interface adaptation would have been built into the Target so I guess the Target is forgotten to be designed for possible future adaptations in this aspect?
  2. How is reflection used to implement pluggable adapters? And how is this not applying the Object style of the Adapter pattern?
BobDidley
  • 53
  • 6

1 Answers1

0
  1. Pluggable Adapters are more work. They require planning for the future, rather than just planning for the present. You could argue that Pluggable Adapters violate YAGNI.
  2. Reflection is an implementation detail. It is not a requirement for any GoF pattern. The book never mentions reflection, which makes sense, because that would limit the patterns to languages supporting reflection. Of course, you could implement an Adapter using reflection if you wanted to (you could implement anything using reflection if you wanted to). It likely would not be a Pluggable Adapter, because if the target had already gone to the trouble of making itself Pluggable, an Adapter should be simple enough without reflection.
jaco0646
  • 15,303
  • 7
  • 59
  • 83