Hi all,
Within our sample app we have a class of DelegateCommand, I just discovered in the Microsoft/Windows-universal-samples there is another similar thing called RelayCommand, e.g. here:
https://github.com/Microsoft/Windows-universal-samples/blob/master/Samples/XamlUIBasics/cs/AppUIBasics/Common/RelayCommand.cs
These two almost look identical except the name. And RelayCommand seems having a longer history, e.g. here in the answer:
http://stackoverflow.com/questions/26816264/page-navigation-using-mvvm-in-store-app
I wonder shall we follow the history and also make this into the lib rather than in sample app only.
This got discussed in #556
Yes, moving is discussed there, but I was talking more about the naming history.
"I wonder shall we follow the history and also make this into the lib rather than in sample app only." That sounds like the previously had discussion :) As for the naming of it, I'm not sure that really matters to be honest.
Well if history is not important then there will never be Gang of Four or any patterns exist.
@xied75 I think that was done for the sample app but it is not intended to be replicated/reused in other project. MVVM Frameworks already have their own implementation of Command like MVVMLight or Prism.
@Odonno But I'm using neither you mentioned here as those are too heavy for me even one called Light. Same goes for the Sample App, compared with lots of current Apps in store, the Sample App is much useful (to me at least) and well written yet without using these frameworks. So why do we assume any UWP app will definitely use some kind of cool fx?
If you check my link pointing to Microsoft/Windows-universal-samples RelayCommand is used there multiple times. And that's a huge project I would say. If this does not qualify a type to be common, I doubt what can be.
And as I mentioned before, I'm including DelegateCommand in my App since I need that for the SlidableListItem control in the toolkit.
@xied75 I understand your need of the minimum code for your app, like having a Command and nothing more.
The fact is that other libraries already implemented the Command pattern and I don't think it will be valuable to create duplicates of existing code, mostly to avoid conflicts between libraries.
I am not against adding a Command-like class in the toolkit but maybe @ScottIsAFool has a good reason. Otherwise, I think that it can be done if we choose the right name.
I renamed the issue to suit the subject of the topic.
Nah, my concern really is on the naming, to respect history and pattern. I almost started to include RelayCommand source in my app before I realized I already got it in another name. :)
If the command only appears in the sample app code, what difference does the name make?
@odonno Have a look who opened my originally referenced PR :)
The DelegateCommand originated from the original Prism framework for WPF. This framework was written by the Microsoft Patterns and Practices team somewhere around 2007. The DelegateCommand has a lot more history behind it than the class you linked to.
The sample app is simple a sample. It is not meant to imply best practices. It's just a sample to showcase the controls/animates/services/etc.
@skendrot Thanks for clarify this, as I said I was trying to follow the history, if the history turns out that DelegateCommand is much older than RelayCommand, then apparently it's the other team not following the pattern, therefore I'm happily accepting DelegateCommand as the right name.
Besides, someone else google search later might land here and find useful.
Closing it (see @skendrot comment)
Most helpful comment
If the command only appears in the sample app code, what difference does the name make?
@odonno Have a look who opened my originally referenced PR :)