C# 8.0: Default interface method implementation - forget what you've ever learn about interfaces and object oriented design
Default interface method implementation is announced as one of the "hot" upcoming C# 8.0 features.
As a "cool" thing, many community members wrote that it would solve "problem" that new interface versions with new methods need implementations in each class which implements that interface.
And now, with method implementation in interface itself, there will be no code duplicating and no need for implement the same method on the same way in different classes.
I am really not fun of being rude and I never use dirty words, specially not in blog, but the only thing we can say about this is WTF.
By adding implementation to interface, .NET will abandon base object oriented doctrine and concepts and will open door for many fails and wrong practices.
Interface would not be a contract anymore and nobody will no what interface would become.
Imagine, for example interface implementation by some third party company, which implements public interface published by other company, or development team. So, in the next version of the interface, some smart developer
add some methods and their default implementation in interface - so...all classes and libraries will have that, without knowing about it and without testing their libraries with new interface and implementation.
I understand colleagues are trying to improve .NET framework, but it is not a thing to make framework handsome, but to make it conceptually clear and good for enterprise solutions.
So, dear .NET developers, please don't make this really happen and don't publish this. It would kill your framework. Instead, think about working on some other concepts or patterns that follow object oriented principles.
Try with multi inheritance, it would also eliminate some code duplicating. Leave interfaces as they are!
Software Architect | .NET Senior Developer | .NET developer | open-source contributor
1 年Dejan Beciric da li ste posle ovog projekta razvijali jos neke u #aurelia i kako se pokazao upgrade (ukoliko ste i na odrzavanju istog) na nove verzije posebno u ovoj 2023 :)
Founder Of Cerebrum Interactive Agency
6 年"Leave Britney Alone" ??