On 15-09-11 23:27, Donald Stufft wrote:
tl;dr; Using Mixins to add in functionality to a CBV makes way more
sense then using a decorator which is essentially going to be doing the
same thing as a mixing would, it just makes finding what is going on
harder, makes customizing the decorator harder and/or uglier, and goes
against the way functionality is currently added to a CBV.
Watch out, in general, with adding more and more mixins.
I explained just the most basic template CBV to a colleague: there are
just two mixins and a base class there, but his eyes already started to
glaze over because I had to jump from class to class to class to explain
how it all hung together.
Throw in a LoginRequiredMixin and SomeOtherMixin and you have the risk
that it turns into a big pile of un-debuggable code. Too many places to
look. Your mind's main working memory has a stack size between 6 and 8:
you just cannot juggle 3 base classes, 4 mixins and 2 method names at
the same time.
=> A mixin isn't necessarily clearer than a decorator.
Reinout
--
Reinout van Rees http://reinout.vanrees.org/
rein...@vanrees.org http://www.nelen-schuurmans.nl/
"If you're not sure what to do, make something. -- Paul Graham"
--
You received this message because you are subscribed to the Google Groups "Django
developers" group.
To post to this group, send email to django-developers@googlegroups.com.
To unsubscribe from this group, send email to
django-developers+unsubscr...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/django-developers?hl=en.