In the following scenario:
A factory returns an object of a logic class:
ILogicClass object = factory.GetByRequirements(reqs);
I then want to invoke a method and get some results which are in the same shape for all concrete logic classes:
output = object.GetResults(...)
and then use the result.
Imagine the concrete implementations need different options to produce the result:
GetResult(integer, integer) for one logic class GetResult(integer, string) for another logic class implementation
Options to skin this particular cat I can come up with are:
GetResult(integer, integer, integer, string)
Which is passing ALL the arguments to the method so each concrete implementation can use the required data and ignore the rest
Pros: Strongly typed
Cons: Every time you add a new parameter, that needs to be implemented on ALL the ILogicClass implementations and most of them won't even use it which is a waste and not elegant.
Another option is:
Pros: Strongly typed, no need to redefine the interface and change the concrete types every time something new is required
Cons: Allocation of an extra object and most of its content will be irrelevant for other implementations.
A third option would be:
Pro: you can pass whatever you like without creating extra object or passing irrelevant data
Cons: error prone to runtime exceptions
I appreciate there may be no other solution to this problem, but is there another pattern I have not considered or a better approach to this problem?