Author: Raffaele Garofalo
Publisher: Microsoft Press, 2011
Aimed at: WPF developers
Pros: Good explanation of some difficult ideas
Cons: Fragmented and disorganized
Reviewed by: Mike James
This book seems to be of specific interest to those working with Windows Presentation Foundation. Will it help them?
The MVVM (Model View ViewModel) pattern is a natural for both WPF and Silverlight. You can create a codeless view simply by using XAML, binding and commands. This makes it more or less trivial to decouple the view from the ViewModel and naturally the problem of decoupling the ViewModel from the Model is more or less as it always is. So you would expect a book with the very long and explicit title "Building Enterprise Applications with Windows Presentation Foundation and the Model View ViewModel Pattern" to be very heavy on specifically WPF code with a side order of Silverlight. If so you would be wrong.
The book starts off with a waffley account of the MVVM pattern This first chapter sets the tone for the rest of the book as it jumps about first looking at the composition of a business UI, then how Visual Studio/Expression blend does it, then on the more abstract issues of separation of concerns and layers. Its a bit of a mess but it is fairly easy to read and you do learn some basic concepts.
Chapter 2 is on design patterns and it provides an abbreviated overview of the Gang of Four patterns. If you don't know what these are before you read the chapter you certainly won't after you have read it. There is more detail about the specific UI patterns that are the subject of the book and there is a reasonable account of how the MVC pattern evolved into the MVVM pattern. However, apart from mentioning them, the real details of how to use XAML, binding and commanding are missing. With a little more work this could be a good chapter but at the moment it presents a abstract view of things with a tiny touch of the real world via some simple examples. I'm not suggesting that the samples need to be bigger or more complicated - they just need to show how .NET fits into the pattern more clearly. After this the chapter goes off into a number digressions - inversion of control, dependency injection with Unity, the managed extensibility framework, DSLs and fluent code, TDD and so on. All interesting, all treated far too superficially and all fairly irrelevant to the MVVM model in WPF.
Chapter 3 moves on to the Domain Model, which again is interesting and reasonably well explained. However, again it something that you could discuss after dealing with MVVM in practical detail. The same could be said of Chapter 4 which deals with the data access layer and Chapter 5 which deals with the business layer. At the end of all of this you can't help but wonder when MVVM is going to reappear.
The answer is in Chapter 6 which finally gets to the aspects of design that are specific to MVVM - the UI layer. This does deal with some practical issues and almost explains the ideas needed to implement MVVM in WPF and Silverlight - but it is far too short and overall it is just inadequate. The book ends with an overview of some MVVM toolkits.
This is a book that promises to be on a specific topic but takes such a big overview that it just doesn't deliver. If you don't know how to make use of XAML, binding and commands to create an MVVM architecture you are not going to know after reading this book.
You will pick up a lot of design and pattern ideas and for this reason the book isn't a complete waste of paper but there are other books that are more focused on this task. The biggest problem is that the collection of topics covered are likely to be confusing if you don't have a reasonable grasp before you start.
So on the whole the verdict has to be that you should avoid this book even though it does contain some readable accounts of some important ideas. Whatever you do don't buy it if your real interest is in using the MVVM pattern in WPF/Silverlight.