Design patterns – Adapter
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.
- 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.
- Class LEGACY_CLASS
function UPDATE(int, bool)
- Class INTERFACE
function UPDATE(struct X)
- 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: