views:

495

answers:

2

All of the WinForms wizards I've written in the past have a high degree of coupling between the UI and the model. That is: the individual pages know about enabling/disabling the Next/Previous buttons, how to react to the Next button being pressed, etc. It makes it all hard to test, because to test any of the logic, you've got to put a lot of scaffolding together first.

I've been using MVC (in the form of ASP.MVC) recently, and I'm finding that easy to test. I've also had a play with WPF, and I think I'm getting my head around M-V-VM.

I'm struggling with the M-V-P pattern in WinForms (i.e. no WPF-style databinding). In particular, I need to implement a wizard.

Would I have a controller per page? A view model that governs the whole wizard? Something else?

This is in WinForms (not WPF), in C#. .Net 2.0 preferred.

A: 

Have a look at the Smart Client Software Factory.

RichardOD
Too many words, not enough actual background...
Roger Lipscombe
That is: too many words in SCSF, not enough actual example code. Generated code doesn't count. Also, I'm looking specifically at how to hook MVC/MVP/MVVM up to a _wizard_.
Roger Lipscombe
I somehow missed the wizard bit when reading the question- sorry. I think you need to describe more in detail the high degree of coupling are experiencing. I know the command pattern has been described as being useful when working with wizards.
RichardOD
A: 

In the end I opted for something between MVVM and MVP, using a mixture of WinForms databinding and view callback interfaces. I guess it's closer to MVP than MVVM. Each page has a viewmodel/presenter, and the wizard itself has its own viewmodel/presenter to govern flow (certain options skip later wizard pages, for example).

It turned out pretty well, and it fairly easy to write unit tests for each of the presenter classes.

The underlying wizard framework doesn't use MVVM or MVP. It's just plain ol' WinForms code.

Roger Lipscombe