This is Where C# Falls Short
I've enjoyed coding with C# for some time now. It's elegant code fills my heart with Christmas jolly every single day. But, then again, nothing compares to VB when you need a very quick code.
C# fails to show it's ease-of-use when hit by several Interface implementations. As most of you know already, 2.0 brings us the great-goodness of Generics. This feature leads to very flexible structure without losing the strong typedness of the code. FYI, Generics is a foundation for from Generic Strategy Pattern to LINQ!
Imagine there's a Generic Interface like this:
interface SomeInterface<T> {
event SomeDelegate<T> ObjectChanged;
}and there's also a Generic Delegate for the above code like this:
delegate SomeDelegate<T>(List<T> e);
When you implement that Interface in a concrete Class, say like this:
class GenericA {}
class GenericB {}
class SomeClass: SomeInterface<GenericA>, SomeInterface<GenericB> {
...
}
You will need to replace the "..." with explicit interface implementation for the event. Each and every implementation will have it's own explicit interface implementation. Compare with VB (which, I would love to write here), like this:
Class SomeClass
Implements SomeInterface(Of GenericA)
Implements SomeInterface(Of GenericB)
Public Event GenericAChanged(e As List(Of GenericA)) Implements SomeInterface(Of GenericB).ObjectChanged
Public Event GenericBChanged(e As List(Of GenericB)) Implements SomeInterface(Of GenericB).ObjectChanged
End Class
No other code necessary! Phew...