14 Mar

I’m writing a MVVM book – What would you like to see in it?

Category:UncategorizedTag: :

I have started a quest that so many developers do; I am attempting to write a short book on the MVVM development pattern.  When I say short, I mean short.  Probably between 50 – 70 pages, most of it being code and examples.  This is my first attempt at a book and I’m not quite sure what developers really want to know about MVVM.  So please, feel free to let me know what you would like to see in a book about MVVM.

UPDATE: I am not longer writing the book as it takes more time than I have.  Although I would be happy to answer any MVVM questions you may have.

32 thoughts on “I’m writing a MVVM book – What would you like to see in it?

  1. Real examples, examples on what to do with non-MVVM friendly controls, like the WPF toolkit controls. How to get data and messages around the application.

  2. I would like to see real application done by using TDD/BDD in MVVM. And Others great to see as well Screen Navigator and Composite View.

  3. I would like to see where does the controller fit in the MVVM. I want to see how does using MVVM help us to make xamls blendable.

  4. How to write unittests for the parts of the pattern and your own best practise of how to best implement commands. It would be great if it contained some more complex implementations, not only easy stuff that one can read in a blog. Looking forward to your book! 🙂

  5. Like a MVVM novella? 🙂 Anyway, as one that has written a research document on this I know one thing: you need to make it structured. If I want to find something in it, I need a clear way of getting what I need without Ctrl-F (because I don’t know what I need yet).
    What I personally would like to learn more about MVVM regards the less clear cases: events where no commands are available, unit testing, messaging between classes, events between different views, etc.

  6. Also, I would like to know what are the best practices to handle dialogs (such as MessageBox)using the MVVM model.

  7. 1. Start with the pattern in isolation and move to examples combining the pattern with other current practices as you move along. Most authors only describe MVVM in conjunction with other techniques they’re trying to promulgate. Start with one basic, coded example, then do an example using property binding, then show an example where you interact with the DAL, etc.

    2. UML before each application of the pattern. It not only summarizes what you’re going to talk about but simplifies recognizing the change in topics.

    3. Good introductions and summaries for each application of the pattern. Few technical authors understand how to write these. Introductions/summaries aren’t helpful if they’re chatty or just contain some obligatory text for formatting continuity. Intros should give the bullets about what is going to be discussed and why it’s going to be discussed. Summaries should give a detailed review of what was discussed. Busy readers looking for specific information read the introduction, skim the section headers, then read the summary/conclusion. Only then will they dig through the chapter.

    4. Include arguments against, or variations of, your approach. If you look at most treatments of MVP (typically on blogs, as it’s not covered well in books), you’ll see the authors don’t really know the pattern (either PV or SC), and also don’t know variations of it (e.g., observer, publish/subscribe, view using the presenter like a proxy, etc.). As a reader, I find the best books are those that show multiple techniques and then explain why the author prefers one for a given context.

    5. Cover testability.

    6. Compress the code. Cut down on vertical space. Use automatic properties instead of properties with backing fields when possible, because they’re less verbose. One thing I keep seeing in new technical books is this tendency to make the book appear longer by using verbose code examples, usually with a large font and lots of space in between.

    7. Discuss integrating MVVM with layered applications, particularly those with model classes in domain layers, those with DALs, those with service layers, those needing to reuse the classes across either a UI overhaul, or those where the application has both a WPF UI and a web interface.

  8. This is great feedback. I am definitely taking notes and will try to include everything mentioned. It looks like this book might turn out to be longer than 50 pages after all. Keep it coming.

  9. Small list of what I’ve been struggling with :
    – Communication between viewmodels.
    – Opening other views from a viewmodel.
    – Working with modal view and dialogs from a viewmodel.
    – navigation between views.
    – Catching events from the view in the viewmodel (like when a user tries to close a WPF Window by clicking on the upper right close button).
    – Blendability.

  10. A common scenario is when executing code in a different thread, to free up the UI thread (so it doens’t freeze in long operations). How to do this async execution with the MVVM pattern?

  11. Great idea, looking forward to it!

    – In LOB applications it is not unusual to use DataSets/DataTables in combination with editable datagrids (edit multiple rows, then commit/rollback all changes). Should you use MVVM or just the VS-designer drag-drop DataGrid/DataBindingSource/TableAdapter?
    – Master-detail relations.
    – Undo/Redo stack.

    Thank you in advance.

  12. @Taco

    Well, MVVM is specific to the WPF and Silverlight technologies. It almost sounds like you are talking about WinForms. If you are in WinForms you may want to look at the Presentation Model pattern my Martin Fowler. Either way, MVVM is just a pattern, and like most patterns, it was designed to help in the all mightly quest of attaining seperation of concern, and testability. There is no rule or law that says you must use a pattern. If you are comfortable with code-behind, and binding directly to a table adapter, then by all means go for it. If you are interested in any kind of pattern based development, try to find one that you like. Just remember, patterns are just there for guidance, feel free to modify them to fit your needs.

  13. @Brian Lagunas
    I do realize MVVM is normally used in WPF/Silverlight. You asked what we would like to see in your book and I can imagine that it is quite useful for developers (who are switching from WinForms to WPF and it’s related patterns) to get an explanation in what cases to use the MVVM pattern and why to use it.
    Imagine a WinForms application with twenty not extremely complex forms and a customer who wants them to be converted to WPF because of the dull grey controls don’t fit in the new ‘bling-bling’ company policy. Should the rusty developer who normally lives in ‘VS-designer mode’ switch to using the MVVM pattern and spend more time typing code? It would be nice if this developer can make the right decision after reading your book…

    … and no, that developer is not me, it is someone I know 😉

  14. For dialogs, use dependency injection in the same way that you would with service layer implementations. If you need help with this, contact me through my blog and I’ll send you some sample code.

    What I’d like to see is a ThreadSafeObservableCollectionViewModel with SelectedItem and SelectedItems properties.

  15. I am quite interested to know way of writing database application (mostly with SQL Server) in WPF using MVVM. So, including some sample (at least CRUD operations) on this topic would be great!

  16. Most articles I have seen on MVVM focus on V-VM, and don’t go at all into the Model, some thoughts on that would be nice.
    Also, I would really welcome some guidance on instantiation and dependencies organization: should the View come first? the ViewModel? Instantiate in code or bind in xaml? Where do containers fit with MVVM?

  17. Combobox selectedChange event was not handled by viewmodel.here i am taking about the event.Not the property. I think you undestood my point of view.Please explain it clearly how to handle the Selection changed event in the view-model…

  18. I would like worked ( and explained ) examples covering real world LOB issues fully. So I would expect Database access, a datagrid and CRUD for complex ( at least parent-child ) data. Error handling. Dialogue boxes, printing and some asynchronous process handling. A book is an opportunity to start with the basics and explain them then cover both how you do the routine and handle the exceptions. On the web there are examples but they are mainly trivial. Those few that are more complex are badly explained. If you’re a genius who has worked in MVVM for years I suspect it’s difficult to work out what bits the rest of us need explaining.

  19. I think it would be helpful if you discuss how seperation of views from models would help different teams.
    For example: When UX team designs views in the expression blend, they don’t need to interact with real models.
    How to use seperate models in design mode,debug mode and release mode would be helpful.
    I think giving Silverlight or WPF samples would add lot of benefit.

  20. It would be helpful if you discuss how seperation of views from models would help different teams.
    For example: When UX team designs views in the expression blend, they don’t need to interact with real models.
    How to use seperate models in design mode,debug mode and release mode would be helpful.
    I think giving Silverlight or WPF samples would add lot of benefit.

  21. I’d like to see how keyboard events (and those with key modifiers) are handled as well as drag and drop events.

  22. I am dealing with Master-Detail scenario and MVVM for 2 months now.

    Having a View with partials/regions each datatemplated with a ViewModel holding a business model , CRUD operations are not possible because the regions need data from each other like SelectedCustomerViewModel,SelectedOrderViewModel etc… but there is only DataContext for all those viewmodels (main and the regions) and I do not think we should use the Mediator pattern to shoot around the needed data between those related regions aka viewmodels.

    So if you can show complex master-detail count in as your most grateful customer 🙂

  23. from easy to hard:
    1. Simple Data Entry form
    2. Master-detail Data Entry form
    3. Data Entry form implemented by stored procedure on SQL server ( every day life for many LOB applications)
    4. something like datagrid with dynamic columns in runtime ( yes, that ‘s right !)
    5. ability to do undo/redo – save batch of data

Comments are closed.