...

/

Adding New Functionality to Existing Objects

Adding New Functionality to Existing Objects

Learn which design patterns to use when adding new functionality to existing objects that can’t be modified.

Problem statement

Let’s imagine we have a situation where there’s either some third-party library or our own legacy code that we need to use. We need to make some changes to its functionality. We’d either need to modify the existing behavior or add some new behavior. However, we can’t change the components that we’re about to use. This is because we either don’t have access to the internal code of those components or simply aren’t allowed to make this ...