#Why do we need decoration?
1 messages · Page 1 of 1 (latest)
<@&987246399047479336> please have a look, thanks.
well, you literally described decoration
except that you can't have a list of delegates
decoration works because the result of a previous step is passed into the next step
each decorator needs to have access to the previous one
Using decorators, the class using it doesn't need to know that all those decorators exist.
You still have the same interface e.g. FormattedText and using decorator UppercaseDecorator you can still pass that to any method with a FormattedText parameter
Without having to add logic to that method to loop a list of actions
because that list may consist of things that arent needed
you may decorate an object for different purposes. and not all of those decorations will be needed for every situation
so its not good to keep every possible type of decoration as a list in memory