1

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

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'd like to know how developers implement the code-behind where the active node is highlighted after a short time duration in a while loop.

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

eglease
  • 2,445
  • 11
  • 18
  • 28
chz
  • 355
  • 1
  • 7
  • 21

1 Answers1

3

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
  • 54,668
  • 9
  • 68
  • 101
  • "...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 Aug 31 '10 at 04:06
  • 1
    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 Aug 31 '10 at 15:44