<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Some thoughts on the RoutedCommand design</title><link>http://blogs.msdn.com/johngossman/archive/2008/11/01/some-thoughts-on-the-routedcommand-design.aspx</link><description>I think we have conflated several concepts with RoutedCommands: 1) The ICommand part with it's Execute/CanExecute methods ... basically this is just a form of method dispatch that lends itself to declarative systems 2) Common Verbs or Actions -- these</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>Some thoughts on the RoutedCommand design | MS Tech News</title><link>http://blogs.msdn.com/johngossman/archive/2008/11/01/some-thoughts-on-the-routedcommand-design.aspx#9028734</link><pubDate>Sun, 02 Nov 2008 03:59:58 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9028734</guid><dc:creator>Some thoughts on the RoutedCommand design | MS Tech News</dc:creator><description>&lt;p&gt;PingBack from &lt;a rel="nofollow" target="_new" href="http://mstechnews.info/2008/11/some-thoughts-on-the-routedcommand-design/"&gt;http://mstechnews.info/2008/11/some-thoughts-on-the-routedcommand-design/&lt;/a&gt;&lt;/p&gt;
</description></item><item><title>re: Some thoughts on the RoutedCommand design</title><link>http://blogs.msdn.com/johngossman/archive/2008/11/01/some-thoughts-on-the-routedcommand-design.aspx#9029473</link><pubDate>Sun, 02 Nov 2008 22:23:17 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9029473</guid><dc:creator>Rob</dc:creator><description>&lt;p&gt;John, can you provide some mocked up code and talk in more detail about what types of problems this would solve - aside from mapping of multiple gestures to a &amp;quot;concept.&amp;quot;&lt;/p&gt;</description></item><item><title>re: Some thoughts on the RoutedCommand design</title><link>http://blogs.msdn.com/johngossman/archive/2008/11/01/some-thoughts-on-the-routedcommand-design.aspx#9029859</link><pubDate>Mon, 03 Nov 2008 02:42:42 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9029859</guid><dc:creator>Neil Mosafi</dc:creator><description>&lt;p&gt;I like this idea. &amp;nbsp;When you write a ViewModel and you expose an ICommand, it would be nice to be able to natively wire up the input event to the command and still have the benefits of the existing RoutedCommand framework. &amp;nbsp;Your proposal seems to solve that problem by segmenting the command behaviour from the command execution. &amp;nbsp;Whilst RoutedCommand uses inheritance to solve this, verbs would use composition to do it meaning you could get the routing of commands with any ICommand implementation.&lt;/p&gt;
&lt;p&gt;I think this simplifies things - as you said commands are just a special type of input gesture so why treat them differently?&lt;/p&gt;</description></item><item><title>re: Some thoughts on the RoutedCommand design</title><link>http://blogs.msdn.com/johngossman/archive/2008/11/01/some-thoughts-on-the-routedcommand-design.aspx#9030729</link><pubDate>Mon, 03 Nov 2008 06:22:15 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9030729</guid><dc:creator>Stefan Olson</dc:creator><description>&lt;p&gt;John,&lt;/p&gt;
&lt;p&gt;I agree with Rob that it would be good to have some example code to try and work through in my head exactly how this works.&lt;/p&gt;
&lt;p&gt;Your post inspired me to write up on my blog some of the issues that I had with routed commands and how I solved them by creating what would what I've called targeted commands, which is similar to what is in blend but on a much more simplified scale: &lt;a rel="nofollow" target="_new" href="http://www.olsonsoft.com/blogs/stefanolson/post/Targeted-commands-in-WPF-in-Silverlight.aspx"&gt;http://www.olsonsoft.com/blogs/stefanolson/post/Targeted-commands-in-WPF-in-Silverlight.aspx&lt;/a&gt;. &amp;nbsp;I will be making the source code to this system available in the near future, but it is just another in the many different ways of handling commands that are out there in the community.&lt;/p&gt;
&lt;p&gt;Your indication this post is that it would still continue to route the same way routed commands do, which as I described my article is not always suitable.&lt;/p&gt;
&lt;p&gt;One thing I'd really like to see solved with commands is the issue of indicating your checked state. &amp;nbsp;Right now there is no easy way to check a toggle button from your CanExecute, if the text selected is bold. &amp;nbsp;Are there some plans to improve that? &amp;nbsp;I haven't yet checked out the ribbon control to see if they have come up with a solution in their code.&lt;/p&gt;
&lt;p&gt;I do have to add how nice it was in WPF that the CommandManager works with ICommands, so with my TargetedCommand class I get the same CanExecute behaviour as routed commands. &amp;nbsp;I had not expected it to be quite so simple!&lt;/p&gt;
&lt;p&gt;...Stefan&lt;/p&gt;</description></item><item><title>re: Some thoughts on the RoutedCommand design</title><link>http://blogs.msdn.com/johngossman/archive/2008/11/01/some-thoughts-on-the-routedcommand-design.aspx#9068663</link><pubDate>Fri, 14 Nov 2008 10:28:22 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9068663</guid><dc:creator>John "Z-Bo" Zabroski</dc:creator><description>&lt;p&gt;There's a lot to be said for allowing failure if one wants to have a high probability of success. &amp;nbsp;The problem with the WPF Command subsystem is the same as the problem with the man who is 200 lbs overweight with broken health -- there may not be any good solutions today, only &amp;nbsp;some that are worse than others. &amp;nbsp;The good solutions were only available 5, 10, 20, and 30 years ago.&lt;/p&gt;
&lt;p&gt;Be careful. &amp;nbsp;WPF's biggest flaw is that it's not purely OO, but rather some hybrid of OO and architect's-kitchen-sink. &amp;nbsp;You want to get rid of RoutedCommand, but fail to explain to the layman why RoutedCommand is a poor idea for a public API, and an especially poor API for a supposedly OO UI framework.&lt;/p&gt;
&lt;p&gt;RoutedCommands fundamental flaw is that it doesn't allow a delegation model: Any external information the object needs to get the task done is passed to it. &amp;nbsp;RoutedCommand doesn't do this. &amp;nbsp;Rather than being given routing instructions, it routes the object. &amp;nbsp;You also can't pass additional details, such as whether this command gets logged (perhaps to more easily implement Undo stack. &amp;nbsp;OO systems should feature objects that never ask other objects for information to do something; instead, the object should ask the peer object that already has the information to do the work. &amp;nbsp;&lt;/p&gt;
&lt;p&gt;It turns out that my comments are correct both in theory and in practice. &amp;nbsp;It turns out OO principles is a really common concept, as Stefan has roughly created such a solution with his ICommandReporter argument to his TargetedCommandManager. &lt;/p&gt;
&lt;p&gt;But how much more theoretical can I make my argument and still be attached to sound practice? &amp;nbsp;It turns out routing is a general concept in distributed, real-time systems. &amp;nbsp;In particular, you want a distributed event bus with subscription-based routing and policy-driven management of discovery and federation. &amp;nbsp;A TargetedCommand, and even Josh Smith's RelayCommand, are just different routing protocols for building distributed, discoverable, federated systems. &amp;nbsp;The interfaces for these commands also create adapters to stabilize what kind of subscription you want: Pruning what objects or sub-tree of objects to send commands to is also theoretical, and known as quenching (activation/deactivation of event sources). &amp;nbsp;A command by itself should never know its routing protocol. &amp;nbsp;That's the job of the sender: picking first class mail over 27th class mail, etc. &amp;nbsp;Delegate the routing protocol, and also have CommandManager keep several journals, allowing journaling to be delegated to various journaling algorithms. &amp;nbsp;The journaling algorithms can also, in turn, be event-based and give birth to event monitoring tools.&lt;/p&gt;
&lt;p&gt;Similar stuff could be done to fix the silly design of the journaling system for page navigation, which is also non-OO, and completely architect's-kitchen-sink.. &amp;nbsp;All my comments are backed up by theory, and not from-the-gut thought as to ideal abstractions. &amp;nbsp;Your Verb concept didn't lose me, I've done similar designs in Swing based on Swing guidance, though your design seems iffy and non-OO. &amp;nbsp;It seems very inheritance-based, underutilizing delegation? &amp;nbsp;Verbs also need semantics, not syntax. &amp;nbsp;Am I cutting on a dime, escaping a linebacker, or am I cutting text from a buffer? &amp;nbsp;Seems like what you really want support for is Multi-Events, the event analog to multi-methods. &amp;nbsp;And I'd agree. &amp;nbsp;Writing tk code in lisp is far more expressive than other languages for this reason. &amp;nbsp;Unfortunately, .net languages don't support multi-methods or multi-events; it is based on the type binding system of the CTS. &amp;nbsp;To do what you seem to truly want, you'd need to talk to the CLR folks about changing the design of type binding. &amp;nbsp;Sounds like a problem for MS Research? &amp;nbsp;Even then, as a MS Architect, you need to expose an API usable from all .NET languages...&lt;/p&gt;
&lt;p&gt;Also, I feel I've had a hard time convincing other programmers of sane design in my life, so I'll settle for a religious victory: FrameworkGesture fits better. &amp;nbsp;AbstractGesture is a little too artistic for me, and also seems to go against WPF naming convention for ABC's.&lt;/p&gt;</description></item><item><title>re: Some thoughts on the RoutedCommand design</title><link>http://blogs.msdn.com/johngossman/archive/2008/11/01/some-thoughts-on-the-routedcommand-design.aspx#9068707</link><pubDate>Fri, 14 Nov 2008 10:56:24 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9068707</guid><dc:creator>John "Z-Bo" Zabroski</dc:creator><description>&lt;p&gt;@Verbs in turn act like input and route through the visual tree until they find a Binding that maps them to a ICommand on the ViewModel.&lt;/p&gt;
&lt;p&gt;I'm not 100% sure how you'd do this, but my reaction is, Why make Binding decide? &amp;nbsp;Does DataContext's separation from Binding guarantee a Binding+DataContext will map correctly? Probably not... Sometimes you want to tightly bind these together, which explains all the cruft on the Binding/MultiBinding interfaces, such as ElementName. Something I'd have to think further about, as standalone Binding could create a nasty schroedinbug. &amp;nbsp;I suspect most bugs in WPF apps to be schroedinbugs from the inheritance context mechanism.&lt;/p&gt;</description></item><item><title>re: Some thoughts on the RoutedCommand design</title><link>http://blogs.msdn.com/johngossman/archive/2008/11/01/some-thoughts-on-the-routedcommand-design.aspx#9077451</link><pubDate>Fri, 14 Nov 2008 23:06:29 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9077451</guid><dc:creator>johnzabroski</dc:creator><description>&lt;p&gt;@Neil&lt;/p&gt;
&lt;p&gt;@Whilst RoutedCommand uses inheritance to solve this, verbs would use composition to do it meaning you could get the routing of commands with any ICommand implementation.&lt;/p&gt;
&lt;p&gt;Using composition still doesn't solve the underlying problem that the design is non-OO.&lt;/p&gt;
&lt;p&gt;Composition (through interfaces) doesn't equal OO. &amp;nbsp;What composition gives you is resiliency to bugs resulting from &amp;quot;fragile base classes&amp;quot;, or, as recent research points out, fragile middle classes. &amp;nbsp;In a nutshell, good use of composition frees you from making assumptions about implementation details. &amp;nbsp;However, good use of composition can be done with structured programming and functional programming.&lt;/p&gt;
&lt;p&gt;It's delegation that is missing, in many places, from WPF. &amp;nbsp;Examples include navigation and controltemplates. &amp;nbsp;Without delegation, WPF apps still feel very much like VB6. &amp;nbsp;RoutedCommands actually map directly to the VB6 way to do things: Frame/Controller paradigm, where the controller ends up knowing too much.&lt;/p&gt;</description></item><item><title>re: Some thoughts on the RoutedCommand design</title><link>http://blogs.msdn.com/johngossman/archive/2008/11/01/some-thoughts-on-the-routedcommand-design.aspx#9079917</link><pubDate>Sat, 15 Nov 2008 01:03:35 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9079917</guid><dc:creator>Karl</dc:creator><description>&lt;p&gt;Sounds interesting. A number people have been critical of RoutedCommands as they are implemented. &lt;/p&gt;
&lt;p&gt;You may want to check out the Composite Command concept over in the Prism project&lt;/p&gt;
&lt;p&gt;&lt;a rel="nofollow" target="_new" href="http://hirentechie.wordpress.com/2008/08/27/microsoft-prism-composite-wpf/"&gt;http://hirentechie.wordpress.com/2008/08/27/microsoft-prism-composite-wpf/&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;and&lt;/p&gt;
&lt;p&gt;&lt;a rel="nofollow" target="_new" href="http://www.sitechno.com/Blog/SpikesWithPrismCouplingCommandsToViews.aspx"&gt;http://www.sitechno.com/Blog/SpikesWithPrismCouplingCommandsToViews.aspx&lt;/a&gt;&lt;/p&gt;</description></item></channel></rss>