Hello,

I would like to propose a small change to the Django signals documentation:

https://docs.djangoproject.com/en/2.2/topics/signals/

According to the documentation:

> Django includes a “signal dispatcher” which helps allow decoupled 
applications get notified when actions occur elsewhere in the framework.
> In a nutshell, signals allow certain senders to notify a set of receivers 
that some action has taken place. They’re especially useful when many
> pieces of code may be interested in the same events.

I have been using Django professionally for around 10 years and worked in 
several big projects so far. One very common
mistake that I see is people abusing the signal system as a way to 
"decouple" their application. Developers usually try to design
their apps to be uncoupled and independent or at least having a proper 
tree-like dependency without circular links. But what usually
happens is that somewhere in the middle of the road their initial design 
proves to be flawed and they need to introduce an unwanted
dependency to another app.

This is usually where people fire a signal to call the other app instead of 
importing it.

These signals can make a big Django project a nightmare to work on, as they 
are extremely hard to debug and to understand what's
going on. There are very fell places where I can think of that the signal 
system should be used instead of a simple function call. Reusable apps
is a good example of a place where you might want to use signals.

I usually try to prevent my colleges from resorting to signals during our 
sprint reviews and meetings. I explain my reasoning, send them
blog posts, etc but we are humans and sometimes these discussions can get a 
bit tiring and emotional. The Django documentation is
the most *authoritative* source I can think of, so if the signals 
documentation included a warning about the signal abuse and when it should
be used and when it shouldn’t I could then refer people to the 
documentation. That would help a lot as I believe fewer people would
be more likely to abuse the signal system

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/c953406d-03bf-4918-9519-8247fd8af2a7%40googlegroups.com.

Reply via email to