I am trying to clean up some code, and I see there are three classes that so the very same thing except for all three some have more properties than others and need to save more or less properties than the other two.
I have something like
//class 1
public class GenerateQKey
{
public void DoSomething()
{
//this one uses a specific class with some parameters
var KeySet = new GenerateQSetOfK()
{
KeyName = "some key";
KeyChain = "Some key chain";
KeyManufacturer = "Manufacturer";
}
someCall.Save(KeySet);
}
}
ANd then i have another one:
//class 2
public class GenerateDifferentKey
{
public void DoSomething()
{
//this one uses a specific class with some parameters + more
var KeySet = new GenerateDifferenKey()
{
Name = "some key";
Chain = "Some key chain";
Manufacturer= "Manufacturer";
Price = 3.00m;
}
someOtherCall.Save(KeySet);
}
}
And there is another but the same principle.. they are all doing basically the same thing just using different API and saving to a different place. I would like to refactor this in a really nice way but i am not sure what it would be.
Maybe have like a manager class that receives either a GenerateQKey or a GenerateDifferentKey and upon determining the type of key call the specific api, but what about the parameters?, should i create a base class?.
I am trying to become a better developer and your input would really help towards that goal.