mercredi 8 mai 2019

Breaking class interdependence

I want to design an application that fetch some configuration from the service. This needs to be done periodically like once in a day. The periodic interval value is also stored inside the configuration.

I have two classes A & B. A is responsible for syncing the configuration from the service and stored the latest configuration in the memory. B is responsible for serving other clients inside the application. Any client who wants to read value will contact B. B will use the latest configuration stored in memory from A.

Here, inside A, I am trying to fetch the refresh interval from B and schedule it periodically. This creating inter-dependency between two class. B is dependent on A for latest cached configuration and A is dependent on B for retrieving the refresh interval. I am not sure how we can break this inter-dependency. Can someone please help?

Aucun commentaire:

Enregistrer un commentaire