MVVM. de la découverte à la maîtrise - A Book Review

Tags: MVVM, WPF, Silverlight

I just finished reading "MVVM. de la découverte à la maîtrise" (MVVM refers to the Model View ViewModel pattern if you need to ask). To my knowledge it is one of the only books that covers the full spectrum of topics related to developing an application using the MVVM pattern. In short , this is the book that teaches you how to structure and develop your WPF, Silverlight and WindowsPhone applications.

The book does however have a huge drawback - it's in French! Hopefully it will be translated soon, because it deserves a wider audience than just the French.

In English, the title of the book translates to something like: MVVM, From Discovering to Mastering. This gives you a hint that the target audience is people who are beginners when it comes to MVVM and want to develop their skills. The book does pretty much that. It is a guide through the different parts that make up the MVVM pattern with code samples to show you how the advice would be implemented in practice.

Even though I consider myself somewhat beyond the beginner level when it comes to MVVM (IMHO) I wanted to read this book because, as I mentioned above, there are so few books that deal with the full MVVM pattern. If you are content to read through a ton of blog posts about MVVM or ViewModels in particular, then the web is full of them. I do however like to read a comprehensive approach to a subject, and blog posts are useless for this.

The book is a well structured walk-though of the different components starting from an introduction of the general topic area to the different parts of MVVM, i.e. a chapter for describing how to handle the Model, another to describe the ViewModel and finally a long chapter about the View. The text takes a pragmatic approach to the code and focuses on solving the problem rather than on insisting on purity, which makes it a good practical guide for the novice in the world of MVVM. Since the book does target developers who are new to MVVM, it places much more emphasis on how to do things than on why things should be done in a particular way. The model gets less attention than the ViewModel and the View which is normal since that is more of a solved problem than the ViewModel and View whose implementation is specific to MVVM. Both the chapter about the ViewModel and the View are supported by a sample library application with code snippets to examplify a particular section. I'll get into some of the examples below, but for a beginner I would say that it is generally easy to approach while still having some expert features to bring the reader beyond the sandbox stage. As mentioned above, there is still some room to add advice to the master by adding more descriptions about the things work under the hood and how this influences choices when it comes to choosing an implementation.

The book ends with a chapter about testing you application, both as manual testing, unit testing and UI automation testing. For me this was the most disappointing chapter to read. It had been mentioned throughout the book. However when I finally got to it, it was very superficial and dealt mainly with ViewModel testing in WPF. I am fully aware of the limitations when it comes to testing Silverlight and WindowsPhone. The authors can't be critized for the complete lack of attention from Microsoft in this area, but I had hoped that the book would have contained some advice on how to work around the limitations.

I don't like nitpicking, especially not when it comes to such a large effort as this, but there are things in this book that I was surprised to see had made it to print (or in my case, to display on my Kindle).

The most important issue that I had with the book was the general lack of clear definitions when it comes to core concepts. For example, the ViewModel is described at one point as an abstraction of the View. While there is some truth in this, it clashes with the constant emphasis that the book places on decoupling the different parts of the MVVM pattern. To be very pedantic, then if the ViewModel is an abstraction of the View it must have a relation with the View (otherwise the relationship is coincidental). But if the ViewModel has a relationship with the View a coupling from the View to the ViewModel has been created. To me the ViewModel must not be coupled to the View at all and can therefore not conceptually be an abstraction of the View. Instead I would have preferred the ViewModel to be defined as a Viewable Model which depends on the Model. This way the dependency links are the right way round and the ViewModel does not need to know about the View. The diagrams in the book do actually show this but the text contradicts the diagram. What's worse is when a ViewModel is compared to apple pie. I think you have to be French to understand that comparison.

In extension of this the pragmatic approach that the authors have taken to problem solving leads to examples where View concepts bleed into the ViewModel. They do make a point to emphasize the need for distinction, but I was still left with a doubt as to how clear they wanted to make the separation. My own preference is to keep anything that smells of graphics out of the ViewModel, but sometimes the code samples blur the lines. This is probably acceptable for entry level applications, but can cause problems when it comes to enterprise level applications.

The next thing is that the code samples have erased all type names. This leads to some very odd code samples. For example, it is left up to the reader to guess that .NewGuid() is actually a call to Guid.NewGui(). That is reasonably easy to guess, but it becomes more difficult when it comes to generic type parameters. I'm not quite sure how something like that escapes proof reading, and it may only be present on the Kindle, but it is definitely annoying. In other places you stumble across code like this:

string.Format("Some text{0}{1}Some names", Environment.NewLine, Environment.NewLine);

Finally there are some odd jumps in the level of detail that is used in the examples. At one point the book describes the benefits of having strongly typed ViewModels and how this can be done using generics. Then some time is spent explaining generics, whereas when it comes to delegrates it is assumed that the reader is fully acquainted with them. I mention the example with generics specifically because it is the one thing the View doesn't care about, since the View binds itself to properties using reflection, and so mainly has value when it comes to maintaining the ViewModel.

In conclusion I would say that I wrote this review as a recommendation to go and read the book. Even if you think that you know everything about MVVM the book makes you think about your preconceptions. I hope it gets translated to English soon so it can be read by more people.

1 Comment

  • Jonathan ANTOINE said

    Hello jacob,

    Thank you for this review !

    You are right about the jump in the level of details. We should have explained delegates more deeply. It's hard to know what is obvious and what is not when you are writing :)

    I am sorry about the problem in the code snippet. I will contact our editor to fix this. Can you provide me your email so I can share it with her ?

    Finally, the model is not the less discussed part, which is in fact, strangly, the ViewModel's one. We wanted to emphase a little on this part which is less discussed and often difficult to understand for beginners.

    Thanks for your review agan !

    PS: We hope it will be translated too !

Comments have been disabled for this content.

Latest Tweets