Decorator pattern allows a user to add new functionality to an existing object without altering its structure.
This type of design pattern comes under structural pattern.
This pattern creates a decorator class which wraps the original class and provides additonal functionality keeping class methods signature intact.
Below diagram and code is an example of the Decorator Design Pattern.
原文地址:https://www.cnblogs.com/codingyangmao/p/11252131.html
时间: 2024-10-23 18:10:05