Adapter Pattern vs Decorator Pattern
- main difference is that:
- the decorator pattern is used to add functionality to an object at run-time without changing the object’s method signature(s)
- the adapter pattern is used to change the interface of an object to adapt it to another interface (i.e. different method signature(s))
- The decorator pattern is similar to the adapter pattern in that one service “wraps” another. However, in contrast to adapters, decorators expose the same service as what they’re decorating.