views:

265

answers:

2

Hello,

So i decide to to develop my asp.net site into Silverlight.

I today start to search articles about MVVM pattern which i want use in my Silverlight app, and i am confused :/ It's hart to me understand how works this pattern. I am find 3 frameworks which supports MVVM pattern in Silverlight - Caliburn, MVVM Light Toolkit and GoodLight.

  • Should i start from own implementation of pattern or use framework?
  • Is this frameworks only a project solutions in which i can insert my code?
  • Which framework is the best for novice and which for professional?

I ask for this, cause i must start to rewrite my app from asp.net to Silverlight and i don't know that i can do it first and later (when i understand MVVM pattern and framework) implement this pattern in finished app ? Or from begining rewrite project to MVVM framework?

+5  A: 

Going from ASP.NET to Silverlight is likely to require a (nearly) complete rewrite. The usage scenario is quite different. Silverlight is all about providing a client-side like development environment - it makes it so you can write an application the same way you'd write a client-side, desktop application, but execute this within the context of a browser.

This has fairly broad implications on how you'd use and develop your software.

That being said - for frameworks... Personally, I'd recommend getting a good grasp of MVVM first, then choose a framework (if any). MVVM is really a simple architectural design pattern. Once you understand it, the frameworks will make more sense. It's difficult to suggest "pick this framework", since they all add their own, valuable, additions and ways of working.

There are many good sources for learning about MVVM. Personally, (I'm being biased here), I like the intro I wrote (even if it's WPF oriented instead of SL oriented, the concepts are the same). That being said, Jerimiah Morrill's MVVM for Tards is also very good to get a basic understanding of what, exactly, it means when you say MVVM.

Once you understand this, the frameworks will be much more approachable (or avoidable, if you don't want them).

Reed Copsey
OK, so I start from learning MVVM. But can I implement MVVM in finish project? It's possible that "refactoring"?Tnx for links! It will useful :)
netmajor
You can slowly refactor SL/WPF code to use MVVM patterns, one "View" at a time. That is possible to do...
Reed Copsey
I wish I could vote this answer up 100 times. People leaping to frameworks without knowing what they need is the biggest problem I've seen as a WPF/Silverlight guy. Too many projects out there are totally based around PRISM (and generally the nastier bits like EventAggregator because the original developers didn't understand commanding or IoC) when they really won't demand it - utter architecture astronautism.
Alun Harford
Tnx for this answer! I now realized that i too much focused on choosing a framework than understanding pattern MVVM! I fix my fault!p.s. View is the XAML code, Model is a LINQ queries to db ?I am correct? What part of Silverlight project can I name as ViewModel and Controler?
netmajor
Model is the data itself - typically via LINQ or whatever. ViewModel is the "glue" that ties the model together,allowing it to be data bound to the View.
Reed Copsey
Basing at my asp.net website, all data from mssql db was strage in DataContext(creating by using visual studio orm tools) from I was querying it by LINQ. So ViewModel was codebehind LINQ queries and Model was this DataContext? Maybe it will be simpler for me when i understand how can i works with mssql db with Silverlight ... :/
netmajor
+1  A: 

I recently posted an article that discusses MVVM in details which includes a 3D illustration that describes the basic principles in MVVM pattern. Check out http://tinyurl.com/383odnm for more details.

Hope this help.

James