The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.
This is a useful feature. It lets you implement an interface change piecemeal, rather than forcing you to implement the change in one great steaming pile. You can even have the default implementation perform an assert to help ensure you've caught all cases.
Thanks for being the first to show a worthy use case for default implementations of interfaces.
he C++ folks would flagellate themselves for years over this, there would be dozens of half-baked implementations with wildly conflicting implementations, and when the standard was finally issued, no one would care.
This I suspect is largely, if not entirely, the result of C# being the responsibility of a single vendor, Microsoft, who has enough muscle to call the shots unequivocally. In contrast, the C++ standard is the work of a committee composed of people from competing vendors, who are motivated by those affiliations to say and do things that favor the people who pay their salaries. The result is compromises and endless delays.
David A. Gray
Delivering Solutions for the Ages, One Problem at a Time
Interpreting the Fundamental Principle of Tabular Reporting
he C++ standard is the work of a committee composed of people from competing vendors, who are motivated by those affiliations
While that is certainly true to some extent, it's not the whole issue. I knew a couple of people involved with the standards committee, and very smart folks. Both were very motivated by abstract principles, language esthetics, and compiler implementation concerns. Their assumption was that by satisfying these motivations, usefulness to their target audience (working stiffs like you and I) would just naturally fall out. Sometimes that has been true.
For me, C# on the other hand seems to acquire features that say "that just might be useful" on a frequent basis. Who cares if it's just syntactic sugar? If it makes it easier for me to write clean, quality code, then it's useful. If this happens because of the Microsoft monoculture, so be it. I'm a programmer to pay the bills, not to worship at the altar of someone's polytheistic dogma.
This is a useful feature. It lets you implement an interface change piecemeal, rather than forcing you to implement the change in one great steaming pile
You are right! Making a tiny mod to an existing interface means every use of the interface in dozens of locations needs to be updated. Having a default method would mean that no changes to existing code would be needed. Only code that wanted to exploit the new feature(s) need implement the new method(s). Of course, you can avoid this already by creating a new interface that inherits the old one and just converting occasions that need the new methods from the old interface name to the new interface name.
OK - whilst you amused yourselves with online chatter I just finished mowing my lawn.
I hate mowing the lawn. Even piling up all the glass clippings and knowing they'll be the compost of the future is little consolation. When we used to have someone come and do it every other week they mowed our flowers (even when told 3x not to). Their predecessor also had disdain for flora.
So take my warning as advice:
- Never Fertilize your lawn.
- Never Water your lawn.
Both of these will only make it grow faster and that will only cause you to have to mow it more often. WTF would you want to do that?