[Bf-committers] Decorator Pattern

Toni Alatalo toni at playsign.net
Mon Mar 12 12:31:16 CET 2018


Python decorators do not implement the Decorator Pattern, they are
different things. Wikipedia explains it like this:

""" https://en.wikipedia.org/wiki/Decorator_pattern#Python
Please do not confuse the Decorator Pattern (or an implementation of
this design pattern in Python - as the above example) with Python
Decorators, a Python language feature. They are different things.

Second to the Python Wiki:

The Decorator Pattern is a pattern described in the Design Patterns
Book. It is a way of apparently modifying an object's behavior, by
enclosing it inside a decorating object with a similar interface. This
is not to be confused with Python Decorators, which is a language
feature for dynamically modifying a function or class.[7]"""

I'm not surprised if that pattern, nor other from the OO patterns
movement, is not used in Blender at all. Curious to hear if it is,
though :)

-Toni

On Mon, Mar 12, 2018 at 7:25 AM, Campbell Barton <ideasman42 at gmail.com> wrote:
> Hi, Blender's built in scripts don't make much use of decorators
> they are used here though:
> https://docs.blender.org/api/2.79/bpy.app.handlers.html#persistent-handler-example
>
> On Mon, Mar 12, 2018 at 11:33 AM, Brad Eric hollister
> <behollis at soe.ucsc.edu> wrote:
>> Hi,
>>
>> I’m preparing a short talk on the decorator pattern for classroom instruction.
>>
>> I’d like to use an example from Blender. Are there any such examples in the codebase?
>>
>> Regards,
>> Brad
>> _______________________________________________
>> Bf-committers mailing list
>> Bf-committers at blender.org
>> https://lists.blender.org/mailman/listinfo/bf-committers
>
>
>
> --
> - Campbell
> _______________________________________________
> Bf-committers mailing list
> Bf-committers at blender.org
> https://lists.blender.org/mailman/listinfo/bf-committers


More information about the Bf-committers mailing list