#Why do we need decoration?

1 messages · Page 1 of 1 (latest)

mint burrow
#

Couldn't we just use a list of extensions in the base class, then use these extensions in the method we want to call?
For example, just have a field that is a list of extensions and whenever you call a given method a foreach loop is used to call all extensions.

gleaming wigeonBOT
#

<@&987246399047479336> please have a look, thanks.

sonic cave
#

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

torpid flume
#

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

empty vessel
#

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