1

With advent of WPF and MVVM Microsoft introduced DependencyProperties and INotifyPropertyChange interface to provide a way to implement the "reactive" approach used with those technologies.

Sadly both of these constructs are very verbose, require much boilerplate, are clumsy to use, also are not really that safe since they require much use of "magic strings".

So here come the question: why didn't they put these functionalities directly into the language - why didn't they create new kind of properties created with a simple keyword, providing useful stuff of DependencyProperties (like events on change and so on...).

What were stopping them?

2 Answers 2

2

Dependecy properties are very WPF-specific. As far as I know, even WinRT (which is XAML-based, just like WPF) doesn't use them. So, you are proposing adding a feature that wouldn't be at all useful for people who develop ASP.NET applications, Windows services, web services, WinRT applications, etc. That's points against this feature.

Also, it's not clear to me how exactly would this work. How would you set the default value of the property? Or PropertyChangedCallback? What about attached properties? If the feature you're proposing couldn't handle all this, it would make it much less useful. If it did, I have no idea how would the syntax look like, but I doubt it would fit well with the rest of C#.

And this feature doesn't actually add much, it just makes some code slightly more convenient.

This all says to me that such a feature wouldn't be worth it, considering that it would be relatively complicated change that would be useful only in a relatively small subset of programs and even in those wouldn't be actually useful that much.

1
  • 2
    +1: I agree. I think many modern languages tend to incorporate too many ad-hoc features that could be provided by libraries or tools. A programming language should just provide a clear simple programming metaphor and some constructs for building libraries (to produce a rich ecosystem around that language). Adding all kinds of features to a language makes it just more time-consuming for programmers to master it. A language construct should be general-purpose, a library should serve a specific purpose.
    – Giorgio
    Commented Apr 27, 2013 at 8:39
0

I'd guess their reason might be: Having to support that language support even long after WPF is dead.

ViewModels aren't supposed to contain any logic, so any implementation code pretty much is "write-only". And with snippet support in Visual Studio writing dependency properties isn't any harder than writing regular properties: propdp tab tab. Replace the snippet with one using a lambda instead of the magic string (like this one google found for me) and you are good to go.

Language support wouldn't improve much upon that, would it?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.