Decorator pattern vs List

I believe you have missed the point of Decorator.

Decorator aims to add behavior transparently. The classic example is InputStream in Java. You can chain like buffering, gzip feature to an input stream. However, the "user" of that decorated input stream do not need to know there is extra behavior added. The user simply use that decorated stream as a normal stream. Of course it will work if you have each "behavior" as a separate object, and store the chain as another list and invoke them explicitly and separately. However it lost the "transparency" in decorator.


With a list, you need some object to manage the list and to traverse and apply the objects. To be plug-compatible, the manager object has to be a subclass of the (usually abstract) base class of all the objects. It's just less flexible than having each object know what it's wrapping and that's it.