Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

13
  • Is the IWorker interface listed the old version, or is that a new version with an added parameter? Commented Mar 28, 2017 at 1:08
  • Are the places in your code base that are currently using IWorker with 2 parameters going to need to plug the 3rd parameter in, or are only new call sites going to use the 3rd parameter? Commented Mar 28, 2017 at 1:11
  • 2
    Instead of going shopping for a pattern, try focusing on the overall design regardless of whether or not a pattern applies. Recommended reading: How bad are “Shopping for Patterns”-type questions? Commented Mar 28, 2017 at 14:18
  • 1
    According to your code, you already know all the parameters needed before the IWorker instance is created. Thus, you should have passed those arguments to the constructor and not the DoWork method. IOW, make use of your factory class. Hiding the details of constructing the instance is pretty much the main reason for the factory class's existence. If you took that approach then the solution is trivial. Also, what you are trying to accomplish in the way you are trying to accomplish it is bad OO. It violates the Liskov Substitution Principle. Commented Mar 28, 2017 at 19:48
  • 1
    I think you must go back another level. Coordinator already had to be changed to accommodate that extra parameter in its GetWorkerResult function - that means that the Open-Closed-Principle of SOLID is violated. As a consequence, all the code calling Coordinator.GetWorkerResult had to be changed also. So look at the place where you call that function: how do you decide which IWorker to request? That may lead to a better solution. Commented Mar 29, 2017 at 8:00