I thought a lot before decided to write this post…
First – I’d like to thanks Ariel Ben Horesh for “inspiring” me to write this post and for dedicating so much time to write his post!
After reading his post I thought a lot and my thoughts about the post are the follows:
1. First, I thought about the applications and the way to provide user with best experience while loading those applications… The users shouldn’t wait minutes for application to download… While authoring large Silverlight applications (MVVM or not) the author should consider to split package (XAP file) into multiple packages to improve loading time, memory footprint, etc. This will enable your application to only use what it needs, when it needs it but also provide an experience to the user and improve overall download times for your application. It is wrong to assume, that all applications are being used in company intranet on 100Mbps-1Gbps bandwidth like connection between developers workstation and internal test webserver. The best practice is very clear about it; for more information I suggest learn about it here; the specific lab named “Partitioning Your Silverlight Application for Deployment” and could be downloaded from here.
Generally, the practice when developer have to re-build the whole application package (let’s say 20+ projects) every time single DLL changes is not optimal for real LOB applications and to the real projects. Much easier to recreate a specific XAP package. I think Microsoft was very clear on this while introduced MEF and added it to Silverlight as well.
2. My second thought was about a resources… I realize, that many of developers uses a resources, but never thought about them in-depth.
To load resource from assembly in the same XAP package, the assembly should be loaded first and then get manifested resource stream from it (and load/add it to merged dictionaries).
To load an embedded resource from assembly packaged into external XAP (according to the technique described in my first point) the application should use a ResourceManager. The external XAP file need to be downloaded to the client machine first. Once downloaded, the assemblies from this package should be loaded and only then embedded resources could be used.
Last thing is about referenced assemblies in same XAP package. The referenced assemblies are not loaded if the types manifested in them are not used. In such case assembly should be loaded first (like in my first example) and the could be used.
I created a small, but very self-explaining sample (not prism-based ) which introduces how to use resources from external assemblies. It could be found at the following location.
3. My last thought was about MVVM and Prism… As a consultant I see too many confusion between those two…
To put is very simple – Prism is not MVVM and MVVM is not Prism.
MVVM pattern is an adaptation of the MVC and MVP patterns in which the view model provides a data model and behavior to the view but allows the view to declaratively bind to the view model. The view becomes a mix of XAML and C#, the model represents the data available to the application, and the view model prepares the model in order to bind it to the view.
Prism is designed to help building modular WPF and Silverlight client applications. These types of applications typically feature multiple screens, rich, flexible user interaction and data visualization, and role-determined behavior.
Prism enable/supports MVVM, but MVVM itself is an architecture that much bigger than Prism. To learn more about Prism and MVVM please refer to the following links:
That’s it for now… I’d love to hear professional opinions about my thoughts – the professional discussion is always good!