Silverlight 2 for Mobile - Why you should start using a MVC pattern
Silverlight 2 for Mobiles was announced at the PDC. I wasn't there, but I read about it on Chris Hayuk's blog here. The real cool part of the announcement is what they announced that there will be no changes required to your code. So, this is not some Silverlight-type Compact Framework step child subset of .NET. To quote Chris exactly:
"YOU DO NOT HAVE TO DO ANYTHING
TO MAKE YOUR SILVERLIGHT APPLICATION TO MAKE IT WORK ON THE MOBILE,
NO RECOMPILING, NOTHING."
That is a pretty cool goal if Microsoft achieves this kind of transparency with the Silverlight 2 plug-in on mobile handhelds. However, to think that your 1280x1024 site with huge graphics and animations is going to automatically scale properly is ludacris. However, this is what software design/architecture patterns were made for.
You have problaby heard of the ASP.NET MVC Beta out there that has all the no postback and no viestate fluff etc. However, the MVC pattern at its core seperates the business logic from the UI. For example, in your web form you have a button and then you write a click handler to print "Hello". In ASP.NET this would be handled all in your codebehind cs file. With the MVC pattern changes this where the user click is handled by the controller and then sent to the model. I am not going to go over MVC in any kind of detail. However, the main thing to understand is that the UI code is seperated from the business logic properly and other UIs can simply be plugged in with a different View component. This lends itself very nicely to the Silverlight MVC pattern. Imagine writing an application in Silvrerlight 2 and simply swapping out the View for Silverlight 2 Mobile and the entire application just works. No code changes just that inside a regular browser you will load a normal View object and for Silverlight 2 Mobile you will use your Mobile View. This mobile view might be: simpler in scale, use a simpler/clearer theme, use less animations in order to fit nicely inside the smaller resolution screens. Depending on how your app is designed this might be all enclosed inside your XAML.
I had my "oh that makes sense now" moment with MVC several months ago, after seeing an example similar to this. Hopefully Silverlight developers can see that using a pattern like MVC (or MVP etc) is really powerful and not just some loosely thrown around "best practice". Furthermore, hopefully this example with Silverlight 2 Mobile helped. If Microsoft achieves its goal of being able to have one single runtime for the web and mobile; investing in the MVC pattern can potentially save you a ton of work in the future if you are thinking about targeting the mobile market.