Design patterns – Adapter


Hello guys,

I’m back with the Adapter pattern.

I’ll just say a few words about it and the rest can be seen on the github page.

Adapter:

  • It is used to add a wrapper over an old class, to simplify the access to the end user, or to link with another class that is expecting different parameters / call different functions.
  1. Class LEGACY_CLASS
    function UPDATE(int, bool)
  2. Class INTERFACE
    function UPDATE(struct X)
  3. Class Adapter implements INTERFACE, LEGACY_CLASS
    INTERFACE.UPDATE(struct X) -> interpret X data, sends LEGACY_CLASS.UPDATE(int, bool)

 

The full code can be found at the following link:
https://github.com/badearobert/cplusplus

Leave a comment

Your email address will not be published.