I am using the chain of responsibility design pattern for my pipeline. One problem I discovered is that the configuration object becomes larger and larger as I add more chains. Essentially, my config object is becoming a massive singleton. Is there an effective way to handle this situation?
Details:
My current set up is
handler.next = handler2
handler2.next = handler3
...
and I use the chain by passing a config object to it.
handler.HandleRequest(config)
the config object has all the config information required for the handlers thus becomes larger and larger as I add more chains.
Possible solution:
In this post the best answer is to use dependency injection.
Which design patterns can be applied to the configuration settings problem?
However, I am not sure how to use dependency injection on the chain of responsibility design without substantially changing the design.
Could someone help me on this issue? Thanks!