Skip to content
Sharp

Design patterns · interview question

When using the Decorator pattern, how can you ensure that new functionality does not break existing behavior?

Multiple choiceHardchapter-13-curatedpremiumdesign-patternsdecorator-pattern
Choose one answer
Answer and explanation

Correct answer

C. By thoroughly testing wrapped instances

Why

Thorough testing of wrapped instances ensures that new functionality does not inadvertently alter existing behavior. This practice helps maintain the integrity and expected performance of the original object.

Test yourself on Design patterns

A free test with instant, explained results. No account needed.

Start free test
All Design patterns questions →