We can see that
WebPage
s would want to have different ways of being instantiated based on different interfaces they implement.
No, they wouldn’t. Interfaces define how types should look like to the outside. They provide no implementation detail and also no information about the constructor or the construction process. If you have an object of the type of an interface, all you know is that you can access the properties and methods that were defined in the interface.
The way you declare your WebPage
type, it is fixed to implement both ILogin
and ISignUp
. As such it is absolutely required to implement whatever these two interfaces specify. And every object of type WebPage
will always provide what both interfaces require.
It is not necessary to make the construction of an object based on the interfaces it is implementing, simply because the interfaces you are implementing is known at compile time and can’t be changed later. So for the type implementing an interface, you just specify directly how that is constructed.