I suggest you ...

Let interfaces be implemented by a field

This suggestion is migrated to Developer Community. Please use below link to view the current status.
https://developercommunity.visualstudio.com/content/idea/351762/let-interfaces-be-implemented-by-a-field.html
The sample:

interface IFoo {
void DoFoo();
}

class Bar : IFoo => _foo {
private IFoo _foo;
Bar(IFoo foo) { _foo = foo;}
}

Why:
- supports aggregation over inheritance
- implicit use of the GoF strategy pattern
- syntax fits property/method expressions

How:
- defines an explicit interface implementation
- the field is implicitly a non-nullable reference

Use:
- to modularize behavior and easily aggregate it
- to vary the implementation, for instance for testing
- to solve annoying things like INotifyPropertyChanged
- in conjunction with constructor injection

2 votes
Vote
Sign in
Check!
(thinking…)
Reset
or sign in with
  • facebook
  • google
    Password icon
    Signed in as (Sign out)
    You have left! (?) (thinking…)
    Marko Kirchhoff shared this idea  ·   ·  Flag idea as inappropriate…  ·  Admin →

    0 comments

    Sign in
    Check!
    (thinking…)
    Reset
    or sign in with
    • facebook
    • google
      Password icon
      Signed in as (Sign out)
      Submitting...

      Feedback and Knowledge Base