Hello Jay! I have been using ImpromptuInterface for some months. I’m making a PCL in .NET and it happens that, when trying to abstract any behavior, I face the very common annoyance that .NET Framework is very possessive with its types and interfaces. Sometimes a type doesn’t implement any interface, or when it does, the interface is internal.
So this is the problem: I have an interface with the same exact methods, with the same return types and method signatures. This is really easy. I just call the extension method
and I get exactly what I want. Transparent and handy.
But, what to do when some methods are slightly different?
- Different names
- Different call site: one is a property getter and the other is a method
- Some methods that are different
Normally, they take a pure OOP approach and recommend the creation of Adapters. But when you have a complex hierarchy of types, this can be really tedious and complex as well, even more when you have HUGE classes like UIElement, Control, FrameworkElement…
What do you think it’s the best approach?