Skip to main content
Microsoft Silverlight
Home Forums General Silverlight Programming Programming with .NET - General Silverlight MVVM Purist Style - are we ready yet?
5 replies. Latest Post by nasiraziz on October 12, 2009.
(0)
nasiraziz
Member
301 points
97 Posts
10-04-2009 10:02 AM |
I am to the point where I think MVVM and Silverlight are still not very happy together. There are way too many theories and opinions on its implementation but I haven't yet seen any concrete examples that cover not just DataBindings related issues but also complex UI interactions. And yes I have read blogs after blogs and concpets but now its a make or break moment for me. For a full fledged graphically complex SL application that depends on lots of data; how does this whole thing glue together (or not)?
In purist sense here is what I understand so far with random thoughts and in no particular order:
I'd like opinions and hopefully some concrete solutions to the above random points if possible. You may pick and chose any or all of the bullets if you feel like answering or commenting. My goal is to write a SL MVVM application with a purist mindset and be successful at that. I have developed MVVM phobia at this point cuz everytime I sit down to test out use-cases, in the most simplistic ones I win but when I jump into more realistic and complex application design, things start going downhill from there and MVVM cops start dancing infront of me...
I'd like to eventually put this case to rest and blog about it based on my findings from fine people like yourselves and ofcourse with due credit and references. Once all is said and done I'll probably decide for myself whether MVVM will be able to satisy all of my application's complex needs under purist terms or not. If not then oh well..., I guess I will have to break some rules. And far and foremost is SL really ready to adapt this pattern even with the help of Prism or similar libraries?
swilder...
Star
8436 points
1,546 Posts
10-05-2009 4:18 AM |
As an author of some of those blogs/articles, I'll say that if you're worrying about a purist view, you're being dogmatic. The reality is a pattern is there to serve you.
I can't answer all the questions, but for #4, I think that the marriage idea I propose in my Prism MSDN article does what you want. I use a marriage to mix them.
10-06-2009 1:46 PM |
Thanks Shawn. And yes I have read your articles too, great stuff and good pointers. I guess the question is where do you draw the line and how do you determine at what point you have broken the rules. Just like FxCop, there should be a MVVM Cop tool also ;)
It took a little time to get my head around MVVM for Silverlight, but having said that there are many approaches and methodologies available through SL Toolbox which can be used to satisfy the pattern, just like what you said "the pattern is there to serve you" and then you have to find the right tools to make it happen.
I am taking your advise and will try not to be dogmatic about it. If there is something I don't know today, I am sure I'll learn it in the future or can always refactor it to get closer and closer to the purist version but without intent.
Cheers!
isheeple
355 points
93 Posts
10-06-2009 10:13 PM |
This may not be of any help but when my team and I sat down and researched everything about MVVM in Silverlight, Prism, and MFC we started our application knowing exactly how everything worked together. There was no question in our minds where each bit of code would live and function and how perfect of a framework we would create. It would be perfect and pure. It would be so clean and easy.
It was a pretty cuddly dream and then the reality of the gray areas jumped out and scratched our eyes out. Simply put if the pattern is not understood, followed, and embraced by your team then it is an anti-pattern. So once we were in the face of reality writing a large complex LOB application with all these pretty patterns being evangelized all around us we sat down and decided what was real, usable, and applicable for us.
I am not a purist anymore so I wont express my opinions further as you want Purist Style.
I can hardly wait till I get a chance to back Shawn into a corner next month ;) jk
10-07-2009 2:41 AM |
@isheeple: Thanks for your comments, the more I am reading and researching the more I see the same issues that you have shared, which doesn't surprise me. I'd like to hear your honest opinions though, because that's the whole point of my question. I want to go purist but then again it may not be possible...
After extensive googling/binging/researching, following are my views at the moment, as in work-in-progress views:
CONCLUSION: Keep your data/calls/bindings related items in M and VM layers. Triggers/Behaviors/etc in XAML (VIEW) layer plus any additional programmatic UI/graphics/interactive can go in code-behind. Make good use of commanding and eventing as much as possible through Prism. These are my rules now and I am sticking to it and documenting it here.
Its still a discussion but I am banging the gavel... order order!
Since these forums are meant for problem solving, I am taking this discussion to my blog now in order to avoid pollution. See you there if interested...
NOTE: If you happen to be a developer and a designer at the same time, I recommend you get your head completely shaved before you go dive into this mess. This will help you from unintended baldness, serious scalp injuries, lost relationships, and what not. You get the idea.
10-12-2009 8:51 PM |
Found another interesting "feature" in Blend3. I posted it HERE
Blendability – A whole new meaning… Tell me if you experienced the same?