SpecialistOff.NET / Вопросы / Статьи / Фрагменты кода / Резюме / Метки / Помощь / Файлы

Назад

Decorator: Dynamic Type Selection


Метки: python

Note

I think we can rewrite this chapter to use Python decorators as implementation (thus the decorators chapter should precede this one).

The use of layered objects to dynamically and transparently add responsibilities to individual objects is referred to as the decorator pattern.

Used when subclassing creates too many (& inflexible) classes

All decorators that wrap around the original object must have the same basic interface

Dynamic proxy/surrogate?

This accounts for the odd inheritance structure

Tradeoff: coding is more complicated when using decorators