When and How Strategy pattern can be applied instead of decorator pattern?

I am learning design patterns and trying to follow Go4 book. On page:179, in the decorator pattern chapter, there is a line which says

"..by extending the number of strategies from just one to an open-ended list, we achieve the same effect as nesting decorators recursively."

I didn't quite get this statement.

Strategies focus on having independent algorithms, which can be set dynamically and don't know much about the client they are set in.

Whereas decorators are not quite independent of the clients they decorate. In fact, they are of same supertype as the object they decorate.

Am I missing a point here?

9
задан Josiah Yoder 13 January 2018 в 21:26
поделиться