So I have the following situation:
class Child : Base, IBase
{
Response OnOperationResponse(Base base, Parameters params)
{
// Code code code
}
}
public class Base
{
protected void OnOperationResponse(Parameters params);
}
public interface IBase
{
Response OnOperationResponse(Base base, Parameters params);
}
I am leaving a lot out, but I’ve put in the parts that are confusing me.
So, the Base class and the IBase interface both contain the same function name, but I want to use the interface’s OnOperationResponse call. Where I am getting confused, is why the developer of the library added the Base parameter into the interface? Shouldn’t the interface realize that the function is suppose to refer to this?
Am I missing something here? Or is there something further under the hood that this library is hiding?
The parameter of type
Basebeing passed inOnOperationResponsecould be any instance of type Base – why do you make the assumption that it should be the same as theIBaseinstance it is being called on?A use case (totally made up admittedly) could be augmenting or modifying a
Responsesimilar to a decorator: