C# 8: Default interface methods implementation
-
Today we are taking a look at a bit controversial one. It’s a possibility to provide default interface methods implementation.
So... a base class?
-
Today we are taking a look at a bit controversial one. It’s a possibility to provide default interface methods implementation.
So... a base class?
Quote:
... this feature will not work with .NET Framework! Only CoreCLR and Mono stack runtimes are going to receive these new updates.
Possibly the most important line from the article. It's not yet clear whether this will be added to a future version of dNF, or whether dNF is now in "maintenance mode" and everyone's being dragged kicking and screaming nudged towards CoreCLR.
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
-
Today we are taking a look at a bit controversial one. It’s a possibility to provide default interface methods implementation.
So... a base class?
What a PFF (pointless f*ckin feature). Like you said... base class. Another (better) solution is to simply create another interface that ionherits the old interface:
// original interface that a lot of classes use
public interface IOne
{
void Method1();
}// addition methods that enhance IOne's interfacinality
public interface ITwo : IOne
{
void Method2();
}// derives from old IOne interface and keeps on working
public class OldClass : IOne
{
public void Method1() {}
}// The programmer is ready to implement the new method in his class, so
// he simply inherits ITwo (which inherits from IOne)
public class MyClass : ITwo
{
public void Method1() {}
public void Method2() {}
}The dowwnstream classes can be modified as needed. There's absolutely no need for this kinda crap/fluff. Let core keep that crap.
".45 ACP - because shooting twice is just silly" - JSOP, 2010
-----
You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
-----
When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013 -
Today we are taking a look at a bit controversial one. It’s a possibility to provide default interface methods implementation.
So... a base class?
-
Today we are taking a look at a bit controversial one. It’s a possibility to provide default interface methods implementation.
So... a base class?
Isn't that an old Java feature?
Oh sanctissimi Wilhelmus, Theodorus, et Fredericus!