I think you may not understand the concept of programming for interfaces. You should always use the new keyword in object-oriented languages โโto create new instances of objects. Just because you program on interfaces, this does not eliminate this requirement.
Programming on an interface simply means that all of your specific classes have their own behavior defined in the interface, and not in the particular class itself. Therefore, when you determine the type of a variable, you define it as an interface instead of a specific type.
In your case, just implement DoStuff in your specific classes, since each class needs to be implemented (whether it is simple or with 10 other initialized objects and settings). For example, if you have an IInterface interface and a class SomeClass that implements IInterface . You can declare an instance of SomeClass as such:
IInterface myInstance = new SomeClass();
This allows you to pass this instance to other functions without requiring these functions to worry about the implementation details of this instance class.
source share