Let's say I have a Web Service that manages Books. So I have Web Methods like createBook
,readBook
,editBook
, etc. For each Web Method, I'm looking for a design that requires calling some functions in a specific order, something like checkPermissions
, then validateInput
, then execute
and so on. The problem is, since they are Web Methods, I don't know if any design pattern could be applied to them - I know I could quite solve it using classes and the Template Pattern, but it would look very strange having a whole class to implement just one Web Method.
I'm trying to do this in order to refactor correctly my Web Methods. Currently, each Web Method implementation must ensure - manually and not by design - that is following the sequence, also some lines of code are repeated in all Web Methods, and some methods are executing the verification process inside the method code, resulting in quite long methods with more lines doing checks than doing the real work, and looks quite ugly and messy.
Maybe my only solution is try to identify the repeated code and move it away from my Web Method code (no way to enforce a structure on them).
Is there a way to reorganize my Web Methods?
Thnak you in advance.
Aucun commentaire:
Enregistrer un commentaire