Assume you have a class Item with the attribute description and mutator methods for this attribute, and a class Registry keeping track of items. When Item#setDescription is called, I would like to be notified in the registry class because the registry might save the item update to other sources, such as a file.
Currently my Item#setDescription is accessing the registry through the static method Registry#updateDescription. I do not know if using a static method in this way is a good solution. I think an observer pattern would be overkill.
How should I approach this?
Aucun commentaire:
Enregistrer un commentaire