samedi 15 septembre 2018

Calling a service layer method whenever an entity property gets updated

I want a certain method from my service layer to be called whenever the property of an entity(in db layer) changes. How should I approach this is the best possible manner?

Options that I'm currently considering:

  1. I first considered using the Observer design pattern for a while but then I'm still not sure if this is the best possible way out for a use case where I know I wont have many observers for the property change.

  2. Calling the service layer method directly in a setter. But then I doubt if this is a good practice to call up service layer method directly from a setter and I'll also have to play for resolving the cyclic dependency in this case.

Any suggestion will be appreciated!

Aucun commentaire:

Enregistrer un commentaire