class Handler
def handle(objects)
unhandled_objects = Handler1.new(objects).handle
unhandled_objects = Handler2.new(objects).handle
unhandled_objects = Handler3.new(objects).handle
unhandled_objects = Handler4.new(objects).handle
unhandled_objects = Handler5.new(objects).handle
unhandled_objects
end
end
I have a bunch of handlers that handle very different business logic and I have a dedicated class that passes off a collection of objects from one handler to another. Each handler swallows processed objects that meet the business criteria but rejects and returns unhandled ones.
I know I can also apply the chain of responsibility pattern here but I would want to know if I can refactor this piece of code where I don't have to mutate the local variable or any suggestion to make this piece of code more loosely coupled.
Aucun commentaire:
Enregistrer un commentaire