Here I am not going to re mentioned about the Chain of Responsibility (CoR) pattern definitions. However what I want to know is that, if there is a series of handlers in a chain, and if a request is handled by all handlers and the last handlers will not process the request if the beginning handlers are failed, is it against the pattern ?
I will explain with an example. Assume an online application which allows users to search books. When user submits a request, the system does the search and shows results. Assume, this functionality is implemented in a CoR pattern.
First handler takes the request parameters (book category, price,author etc), and adds additional parameters (such as users country,region,language which are picked from request) and does certain validations.
The second handler takes the output of first handler and look in the database and create a list of results. Those results are transferred into a third handler. Third handler will order the results, filter, change language. If any of preceding handler is failed, the following handlers will not do their job.
Is the usage of CoR against its concepts ? or any other good pattern for this ?
Aucun commentaire:
Enregistrer un commentaire