What's the difference between an Adapter and a Converter? Are all converters Adapters?
(In terms of design patterns)
No, I wouldn't consider them the same thing. An adapter is something that generally adapts one interface for another. For example, I might create an adapter interface for my application to send an email. One adapter would do all the work involved in interfacing with SMTP, another adapter might do all the work involved in interfacing with Exchange. The the code using either of the adapters, they would be used in the same way (maybe both implementing the same interface). The adapters adapt one interface for another. The idea is that I could swap them out as needed.
A converter is something that changes one or more values to one or more different values. e.g. I may need to convert Unicode text into ASCII text. That's not adapting an interface so that something else that expects a different interface can use it, that's converting values so that the single interface that expected ASCII text can be used.
Now, an adapter might need to do some conversion in order to adapt an interface; but that's not always the case.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With