I'm trying to build a framework that allows people to extend our core functionality by implementing an interface. Below is a dumbed down example of this interface.
public interface MyInterface
{
IData GetData(string p1, char p2, double p3);
}
Recently, we've decided to modify this interface (I know I shouldn't break dependent code, but the truth is we don't have any 3rd parties implementing this interface yet, so we have a chance for a "do-over" to implement this interface correctly).
We need to add 2 more parameters to this interface for our software to work correctly. Two ways we're thinking of are just adding them to the signature like this:
public interface MyInterface
{
IData GetData(string p1, char p2, double p3, bool p4, DateTime p5);
}
or by creating a parameter object like this
public class MyParameters
{
public bool p4 { get; set; }
public DateTime p5 { get; set; }
}
and adding them to the end of the method like so:
public interface MyInterface
{
IData GetData(string p1, char p2, double p3, MyParameters p4);
}
I'm looking for some sort of guidance on which way is the "most" correct way to proceed. I can see pros and cons in both categories, but I don't want my biases to lead me down the wrong path.
Some of my main concerns are:
- Extensibility of the software - I want the user to be able to do things I haven't thought of yet by implementing the interface
- Maintainability - Ideally, I'd like to never have to touch the code that is responsible for calling GetData() again
- Clean API - I don't want the solution I arrive at to make a 3rd party developer cringe
I don't even know what question to ask online to get guidance for this issue. I have a feeling that the answer is "it depends" (on things like how related p1-p5 are to the purpose of the GetData() function), but can someone point me to a list of questions I should ask to help me evaluate whether one solution is better than the other?