3 ms·
Decorators can be misused, but they can also succinctly express an aspect of the program that is repeated many times in different contexts. My own rule is that
by olefoo 15y ago
Decorators can be misused, but they can also succinctly express an aspect of the program that is repeated many times in different contexts.
My own rule is that a decorator should do one thing, and that thing should be described by it's name.
Being able to look at a method that has the @has_permission decorator on it and know that it is getting checked for against a package wide permission model is more clear than having boilerplate to check permissions on every method that needs that check.
Any language construct can be misused. And people can hide stupid things in decorators and name them in misleading ways.
That doesn't mean that it's the fault of the syntax.