MVVM Silverlight Framework Choices - wpf

Which Silverlight MVVM Frameworks should I look at - taking into account these areas of functionality.
1) IoC - can I choose my own? I would like to avoid using MEF w/ Attributes.
2) Navigation
3) Callback simplification
4) "IMessageBox" type abstractions
5) Testability
6) Logging
Note: mitigating a conversion to full-blown WPF is not a concern. This app will always be only Silverlight.
What other things haven't I thought of?
Any good online references that compare and contrast the current frameworks?

I personally like Prism, but you can find a comprehensive list of many frameworks/libraries with features comparison here.
I hope this helps.
Thanks,
Damian

PRISM (this is the mainpage). Here is some information about what it offers. Here is what Microsoft has to say about it.

Just a quick side note, I know this doesn't answer your question and so on.
Someone (Josh Smith) once said that MVVM has nothing to do with IoC; so any MVVM framework that forces you to use a specific IoC framework does something wrong in my opinion.
Also, testability is innate to MVVM but only if you do your job of structuring your Model and ViewModel accordingly. So a MVVM framework should never restrict this, it's all up to you.

Related

Silverlight 5 MVVM Best Practices

Seeing as how MVVM is being highly regarded as a good system design pattern, I thought I might just jump aboard and give MVVM a shot.
Just a little background about myself before I begin with questions:
I have done a few years of development with ASP.NET Webforms. I have also done a fair bit of development in ASP.NET MVC, which I am quite comfortable with.
Currently, we have a number of "backbone" applications written using ASP.NET MVC 3 which we customize and sell to our clients whenever we're approached. These applications are all meant for internal use, hence plug-ins wouldn't be much of a problem.
The real problem with development is that for large scale business applications with complex business rules, ASP.NET MVC tends to slow us down (writing jQuery / javascript > server side processing > return result, use jQuery to notify > alter view, something along this line).
Then I began looking for answers that will help us improve our time to delivery and also responsiveness (well, we all know how JavaScript is capable of killing us) and my search brought me to Silverlight (we have the time to change, no worries there).
So here comes the questions:
I have come across many Silverlight MVVM samples online, but all of them show applications as simple as interacting with only one Database table. Is MVVM pattern well suited for large applications?
In MVC, I'm used to Dependency Injection from Ninject to pass an implementation of UnitOfWork to my Controller. In all samples I found online, none of them use any form of DI. Is it really unnecessary? Since the idea of MVVM is to decouple, so why not also decouple ViewModel from Model?
I've gone through a book published by Jeremy Likness called Designing Silverlight Business Applications. He used MEF to do the decoupling, which I think doesn't really fit into our application. We do not really need to do "hot-plugging". What's your take on this?
MVVM is all about Commands, Databindings and No Code-behinds. What if I want to interact with UIs that do not expose to commands? (I'm not too sure about this, I'm guessing ListView OnSelectionChange?)
To add to the previous answer:
We are developing a large corporate-wide Silverlight platform and a set of applications using MVVM. Seems to be working pretty well.
We are using DI extensively. Our system is built on top of Prism. Prism contains a large amount of sample applications of various complexity illustrating the use of DI in MVVM.
We use Unity as our IoC container. Prism contains guidance for both MEF and Unity. Unity seems to be a more traditional IoC approach.
In the vast majority of cases using Bindings and Commands covered our needs. For the others we use Expression Triggers and Actions. You can also create custom Triggers/Actions if necessary.
I have no answers for all your answers (never used MEF) but I can tell you my experience:
1- I've been in the development of a quite-large silverlight application and MVVM fits perfect to have a maintainable application. The bigger problems we had because of application size were because of Silverlight, not MVVM 8-)
2- I haven't used it too much but it's useful in many cases. There are several toolkits to use DI with Silverlight like MVVM Light Toolkit:
http://compiledexperience.com/blog/posts/blendable-mvvm-dependency-injection-and-unit-testing
4- For interaction between UIs you can use the Mediator pattern. The same MVVM Light Toolkit has a Messenger to subscribe, send and receive messages and maitain every layer decoupled.
Hope this helps you ;-)

WPF + MVVM + Nhibernate : A simple example?

I'ma rookie and MVVM NHibernate. No I'm doing a project with MVVM and NHibernate. I need an example to facilitate studying.
Thank you very much!
There are plenty of examples around for using both, they should be easy to find with [your favorite search engine]. It is better to ask specific questions rather than asking for beginner tutorials (which there are, as i said, plenty to be found).
For starters:
Good MVVM Introduction
http://msdn.microsoft.com/en-us/magazine/dd419663.aspx
NHibernate Article by the makers
http://msdn.microsoft.com/en-us/magazine/ee819139.aspx
Another article on codeplex that might be useful (WPF + NHibernate)
http://www.codeproject.com/KB/WPF/WpfNhibernateToolkit.aspx
Another SO discussing about Nhibernate, MVVM, WPF, aso
Using Unit of Work design pattern / NHibernate Sessions in an MVVM WPF
There is a very nice article (with sample code) using WPF.
Building a Desktop To-Do Application with NHibernate
It does not use MVVM however, but MVVM relies heavily on DataBinding and the approach followed in the article is quite similar (I could say, even better).

What MVVM Framework (Silverlight) should I use?

I'm working on Silverlight, of course I use MVVM. I found many problems but I can create work-around solution for them (some of these solution is not elegant at all), now I think it's time to bring some framework to help me.
I need functions that listed below.
Dependency Injection
Navigation
Callback
Messaging
Bind event to Command
Testability
As I know, there are many Framework out there, such as, Jounce, MVVMLight and Prism. I want to know which framework is suitable for my need?
When it comes to dependency injection I'd rather use MEF
which greatly simplifies code. As for the rest of the functions , currently I'm working with MVVMLight and I haven't faced any problem (although I'm not familiar with Jounce and Prism)
I think that you should consider the scale of the application. If it is a relatively small application that is unlikely to grow I would choose MVVMLight.
For a larger LOB application I would consider PRISM or Caliburn. I would also recommend reading blog posts by John Papa and Jeremy MIller on MVVM, Screens and Coordinators. Their ideas and insights helped enormously in a large scale Silverlight project I've built.
In WPF Prism is great, in Silverlight Jounce is the best by far. Its is very well integrated with MEF , very lightweight, elegant and stable. It also provides nice implementation to support complex events workflow scenarios, VisualStateManager in ViewModel (love that one), validation, debugging and unit testing; Used it in some quite complex projects and was happy I chose it.

Silverlight - Prism, Unity, and the Managed Extensibility Framework,

I'm trying to build a line of business application using Silverlight. I felt like I was doing good then someone asked some questions. Immediately, I became really confused. I see discussions around Prism, Unity, and the Managed Extensibility Framework. However, they all look like they are trying to solve the same problem. Am I nuts? How do these three items compare / contrast with one another?
Thank you!
I recommend listening to the Herding Code podcasts with Glenn Block. (Part 1 and Part 2). He goes into this exactly subject, in much more detail than we can answer here.
That being said -
MEF and Unity are the two things that have quite a bit of overlap. Prism, in its default form, uses Unity for its dependency injection. You can use Prism with MEF, if you like, instead.
Prism is designed more for building composite applications. MEF, on the other hand, is about extensibility. There is definitely some overlap in goals here, but the basic driving factor is different.
In Prism's case, it's all about organizing known code.
MEF, on the other hand, is about discovering new code, and injecting it appropriately.
The newest guidance I've seen, which I fully agree with, was just posted on Glenn Block's blog: "If you are starting fresh you can use MEF for modularity, and general aspects of your composite app. Where appropriate you can pull in Prism bits."
http://blogs.msdn.com/gblock/archive/2009/12/02/mef-and-prism-to-be-or-not-to-be.aspx
There was this post today that discusses two scenarios where MEF and Prism work together to provide solutions. Each scenario leverages features that are not found in each, with 80/20 rules for those features that they do share.
Although there is overlap, the essential differences from a 30,000 view are
Unity is a IOC container. Use it to make your app more loosely coupled
Prism is gear toward making your UI more loosely coupled. As Reed mentioned, it uses Unity to help do this.
MEF is meant to make your code extensible. This helpful when having to interoperate with code that will be written by someone else. An example is if your application will support plugins.

Do you know any real-world, useful WPF/Silverlight applications using MVVM?

I'm looking for code of full applications that (1) use the MVVM pattern and (2) are approachable for WPF/Silverlight/MVVM beginners. So far I have only found:
Crack.NET - A runtime debugging and scripting tool (useful but quite complicated)
CipherText - WPF Password Manager (perfect but written in VB.NET)
What are some others?
preferably smaller helper apps or tools that use MVVM but that have a completed feel, perhaps with WPF/Silverlight graphic/animation goodness, etc. which show not only the MVVM concepts being used but in a context of a real-world, completed application
My Contribution
Thanks for all the tips, I collected together a list of 15+ MVVM code examples and posted the here:
Overview of WPF/Silverlight code examples that help you learn MVVM.
I too class myself as a beginner in MVVM developing a large scale application for about a month now. I'm over most of the main hurdles, but keep getting confused up by a few things.
Be careful with the suggestions from Kent. They'll get you started, but the subtle differences in Silverlight and WPF will trip you up occasionally (triggers are one).
I don't know of any full sites, but I started with the Composite Application Guidance and PRISM libraries. These a little too cumbersome for a 'beginner' and just MVVM, but some of the concepts are very useful (event aggregator for example).
I suggest that you read blogs by Josh Twist, Josh Smith, Shaun Wildermuth and Nikhil Kothari. These guys are very knowledgeable. They are also very open to answering questions too.
What is your development background? Some of the concepts surrounding method calls, responses and delegation are a real break from "traditional sequential" coding techniques.
Given the question, you may be interested in the current effort going on to create a "Pet Shop" type reference implementation for M-V-VM. You can join the conversation or follow progress here.
I've been using MVVM for the last couple of months on a project and it's been fantastic. I've been doing UI work for over 12 years and it's the best thing I've come across.
I have been using MVVM for about 2 years now, and I can say that it is a resounding success. I have shipped one large-scale medical imaging solution using MVVM in Silverlight. I am also about to ship a complicated WPF application using Prism and MVVM extensively. In fact, I don't know how I'd achieve some of my problems elegantly without MVVM in this more recent application.
+1 on MVVM. It works. It is testable. It is extensible. It facilitates developer-designer workflows. It ALSO doesn't have to be messy and plumbing-heavy.
In addition, I created a medium-sized Silverlight application using MVVM for the CodeMash conference in January. You can see it and get the source code here.
Try this one. Also, Family.Show may be useful.
The WPF Disciples group has decided to create a real-world MVVM + Mediator reference application similar to the Pet Shop refence application for Web Apps. Your can follow the development on codeplex here

Resources