Imagine that we have classes as such:
public abstract class WebPage
{
public WebPage()
{ ... }
}
public class LoginOrSignUpWebPage : WebPage, ILogin, ISignUp
{
private Info _loginInfo;
private Info _signUpInfo;
public readonly Info LoginInfo { get { return _meats; } }
public readonly Info SignUpInfo { get { return _legs; } }
public class LoginOrSignUpWebPage(Info loginInfo, Info signUpInfo) : base()
{ ... }
}
We can see that WebPages would want to have different ways of being instantiated based on different interfaces they implement.
Whilst it'd feel okay implementing individual constructions for each class, I would prefer to use inheritance to base the object construction upon. The reason for this is because another object may implement the same interfaces and would have the same way of being instantiated.
I have thought about using some sort of (abstract?) Factory method, but I'm not sure how this would work.
Question:
Right to the point, what do you think would be the best way to base construction of an object based upon what interfaces it inherits? This would include (potentially) different parameters, and at minimum different data passed depending on the implemented interface.
LoginWebPageand aSignUpWebPage. You are really selling the design short if you try to have an "either/or" object. What if tomorrow you decide to have other 'sign-up types':RequestInfoWebPage,GetEmailsWebPage, etc.