views:

48

answers:

1

Hi Folks

I'm new to WPF and after glancing thru this article,

http://stackoverflow.com/questions/3432423/mvvm-pattern-for-a-diagraming-application-with-wpf-convert-enum-to-xxxviewmodel

I like to know if MVVM could be used or encouraged to use for a simple app that I like to try: The simple app is a wpf flowchart designer that allows user to add icons to the canvas such that they are related to one another. Also I like to know how developers implement the code behind where the active node is highlighted after a short time duration in a while loop. ie suppose there are 3 nodes in the app after drag and drop. time active node 1st-5ths A 6th-10th B (active node moved from A to B) 11th-15th C (active node moved from B to C) 16th-20th A (active node from C to A because of while loop link)

Is this a good fit for MVVM pattern use ?

Thanks

+3  A: 

What MVVM comes down to is two major components:

  • Maintenance
  • Testability

The core benefits you get from the MVVM pattern are:

  1. Everything MVP / MVC brings to the table
  2. Your view model (logic behind your views) are easily testable because you can instantiate them outside of the context of the WPF/Silverlight/ASP/Whatever system (since they're essentially POCO.
  3. Your logic is separates so you can easily hot-swap out the logic behind a view using IoC/DI or just plain using a different model. One line code-change and your entire behaviour changes.

There's quite a lot of overhead that goes into designing your application around MVVM, and personally I wouldn't recommend it for small apps as it can likely double your development time.

However if you expect to be constantly maintianing / upgrading / expanding your app and need to unit test the ui functionality, it's invaluable. It can save you immense time on a large ui refactor if you took the time to set it up correctly at the start.

I know this may not answer your question specifically, but I feel these points are more relevant to chosing the MVVM pattern.

Note: remember MVVM are guidelines, not the rule, you're allowed to break it where it makes sense to, just remember to think of the implications of doing so

Aren
"...likely double your development time?" Maybe if you've never developed an MVVM application before. I use MVVM for even the very smallest of apps and it reliably pays for itself.
Robert Rossney
I was talking about the overhead setting up your app, "double" may have been a hyperbolic estimate, but there is overhead @ the start for sure, then it tapers off.
Aren