I have two classes in my project: first do something with comments, second with alerts: AlertFilterService and CommentFilterService
They have almost identical constructors and exactly the same methods signature, like do_somethig_for_alerts(self) and do_something_for_comments(self).
do_somethig_for_alerts(self):
some_code
if
code
else:
message['status'] = AlertStatus.NEW.value
await self.db.store_alert(message)
do_somethig_for_comments(self):
some_code
if
code
else:
message['status'] = CommentStatus.NEW.value
await self.db.store_comment(message)
How to avoid code duplication? What is the best way to do this?
Aucun commentaire:
Enregistrer un commentaire