I have a situation, where I have to call my methods in particular order. This came up in multiple places, so I wonder if there's some pattern I can't see.
Right now in every such case, I have prepare stage where I execute some code based on preconditions, an act stage (where I modify my data) and save stage where I save it to the db. I now have this:
accessRightsService.Shift(document, userRole);
updateService.ApplyChanges(document, newData);
documentRepository.Update(document);
I was thinking about something like myService.WrapOperation(doc, d => {})
that would call prepare first, then execute the action, then save results to the database.
So, is it a pattern - and if it is, which one?
Doesn't look like template method or decorator to me
Aucun commentaire:
Enregistrer un commentaire