Thursday, August 28, 2008

ViewModel Pattern extended with the Dynamic Language Runtime

Nikhil Kothari has been exploring design patterns for Silverlight applications. He ended up with verbose XAML and nearly recreating his own expression language. He solved this problem by embedding the Dynamic Language Runtime in his Silverlight application - with an 'InvokeScript' action that he could use with a dynamic language (in his case managed JScript) to simplify his view-model pattern.
"In my last post, I posted an implementation of the ViewModel or M-V-VM pattern for use in Silverlight applications. This pattern allows you to decouple your view presentation logic and data from the view, thereby facilitating independent development/design of your app as well as easier unit testing of your application code."

"I realized the Dynamic Language Runtime (DLR) would be a perfect fit. It is just the right designer-friendly glue that can be used to call into the bulk of the logic that is itself developed using statically compiled code that exists in the view model and the rest of the app. I could scope the use of the script down to a minimum by hosting the DLR to execute just script expressions. The DLR would also give me the benefit of using something like JavaScript, and potentially on any another scripting engine created to run on the DLR."

His blog entry has an example project to download and experiment with.

(Via DevHawk.)

No comments:

Post a Comment

Note: only a member of this blog may post a comment.