DEV Community

Discussion on: Refactoring an Overgrown Notifications Class in Django

Collapse
 
danidee10 profile image
Osaetin Daniel • Edited
  • I still think there's a major issue with your code, The view code is
    too coupled with the notification functionality. You shouldn't be using
    a Mixin (at least in the context of a view). A view's major purpose is
    to receive a request and return a response.

  • Also, the SendNotificationMixin class is too huge, if you use a
    service like codeclimate it should flag it
    as a "Code smell".

Shameless plug here: I created a django library that might be of help it uses django signals to decouple the notification functionality from your application. The various types of notifications can easily be written as "delivery channels" instead of mixins.

It also processes notifications asynchronously using Celery which IMO is better than django-channels because you can monitor tasks, retry them if they fail etc.

github.com/danidee10/django-notifs