Due to a recent success story I've had with a very large Silverlight project I'm compelled to speak up about a topic that I consider exceedingly important to software development and in particular Silverlight and Windows Phone Development. I normally focus on design and interaction specific topics regarding Microsoft's UI and User Experience technology advancements but today I want to bring to light another topic, Design Patterns. I'm not talking about UI Patterns or specific User Experience Patterns that impacts Usability, accessibility and the overall success on your interactive application. I'm talking more specifically about Software Design Patterns. That subject you remember hearing about in College or University way back and forgot or think that it's something only engineers have to deal with. To recap, a design pattern is a general reusable solution to a commonly occurring problem in software design. This might sound a little juvenile but you'd be surprised how many developers I meet who just don't follow them and are totally oblivious to their importance. What is under the hood in Silverlight is packed with several design patterns, some old and a lot are new, but its these new ones that are important and really gives Silverlight it`s power. The result of these patterns is an unmatched level of productivity and robustness for both programmers and interaction designers when creating applications with Silverlight for the Web or Windows Phone. All of that Microsoft ingenuity goes to waste if there is ignorance of these patterns and how to use and implement them. I won't go into the details of these advantages because there is just too much here for a single article, but I will cover this soon.
In this specific example I was brought mid-way into the development of fairly large project using Silverlight as the Interactive Client for customers to use. After a few minutes I realized there was no resemblance of any standard Silverlight specific structural patterns being used and information was being directly referenced in Silverlight's UI controls without the use of the widely used Binding pattern. Every task was resolved with aggressive spaghetti code inside the code-behind files of the Silverlight application. And this had been going on for roughly a year, no joke. Oddly enough, this wasn't the only time I've experienced this. Three of the major projects I have been involved with have completely fumbled their projects in this manner. I suspect this is due to assumptions made about Silverlight that are based on previous experiences with other RIA technologies like Flash or web pages. What ended up happening was un-manageable code, a loss in a separation of concerns imposing development bureaucracy, code that wasn't compatible with Interaction Design tools like Expression Blend resulting in the Designers sitting on their hands while they wait for developers to implement their ideas, and a whole mess of other problems. Trust me, just reading the standards articles on Microsoft`s Patterns and Practices website will save you a whole lot of trouble and ensures all parties involved on the project can work in isolation. So do everyone a favour, go there right now!!
There is a happy ending to this story however. After roughly 4 months of intense work we implemented a very basic version of the MVVM software pattern and stripped out all direct references and code behind with Binding expressions. Once that was done the interaction designers were able to use Blend to implement their interactions without needing permission, Programmers were able to implement their business logic without interruptions, and managers became much less stressed with managing individual tasks to meet deadlines. And everyone has come out of the experience with a renewed appreciation of Silverlight and the experience needed to develop truly interactive applications. So in a sense, simply following the appropriate Silverlight Design Patterns had saved their application and quite possibly their business.
Here is a simple must know check list to set you on the right track with Silverlight and Windows Phone Development.
1. Learn about the Parts and States Model.
http://msdn.microsoft.com/en-us/library/cc278064%28v=vs.95%29.aspx
http://www.vsj.co.uk/articles/display.asp?id=814
2. Learn about the Dependency Property Model as it relates to Data Binding.
http://msdn.microsoft.com/en-us/library/cc221408%28v=vs.95%29.aspx
http://dotnetslackers.com/articles/silverlight/Dependency-properties-in-Silverlight.aspx#s1-1
3. Inform yourself on the various Structural Patterns recommended by Microsoft.
http://msdn.microsoft.com/en-us/practices/cc305074
4. Get up to date with MVVM and Prism Development Patterns.
http://www.galasoft.ch/mvvm/
http://mvvmlight.codeplex.com/
http://compositewpf.codeplex.com/
5. Practice with tutorials and labs.
http://www.silverlight.net/learn/