dimanche 17 janvier 2021

Design pattern of coupling/decoupling two apps in Django

I have two apps: app1 and app2.

=>app1 has model A gets data with timestamps.
=>app2 has model B with some computations that have to be made on the data that model A gets

Usecase:.
Every time we create model B, it has to check if we have enough data in model A => do an update. This same update is triggered every time we add data to model A.

=> My design is: since updates are having a place in model B then I import my model A in it and check if I have enough data while creating model B.

on the other way around, if I add data to model A I prefer not importing model B in model A to avoid app circular dependencies and coupling. So my idea here is to send a signal from model A to model B and proceeds to the update, is it the best way to do it or you would think of some different design patterns?

=> I also read on some blogs that using signals is not always suggested, what's your take on this?

Aucun commentaire:

Enregistrer un commentaire