“Advanced MVVM” Book Review

JustinAngel

Hi Folks,

I recently bought a copy of Josh Smith’s new self-published book “Advanced MVVM” and I’d like to share with you my impressions.

For those of you in a hurry, I’ll conclude my thoughts here. If you’re looking into learning MVVM or enriching your understanding of MVVM, Don’t buy the first edition of this book. This book is god-awful bad.

I Love Josh!

The Silverlight & WPF community is a very tight-knit group of super community ninjas. Personally, I adore Josh and hold him in the highest possible respect as a professional colleague. Josh’s blog is amazing and he’s known to share some profound revelations on the WPF Disciples mailing list.

Let me make this abundantly clear: Josh is awesome. This book isn’t. This review ignores Josh’s radiating awesomeness and focuses solely on this atrocious book.

Mistake #1: The Wrong Problem Domain – Gaming?

Generally speaking, all Silverlight & WPF applications will fall into one of the following categories: Games, Media and LOB (Line of Business). There are definitely more categories then these basic three, but those three are assuredly the majority of applications out there.

Most applications out there are going to be LOB apps. Most MVVM developers are going to be LOB developers. So why is this MVVM book about using a Game as the Sample Application?

Over here you can see a print-screen of the sample application developed in this book:

It’s fundamentally wrong to base an entire MVVM book on a game. There’s so much game related minutia in this book, that it’s easy to get distracted and forget the book is about MVVM. Realistically almost 50% of this book is gaming plumbing and not about MVVM.

To highlight this point even further: This entire codebase doesn’t have a single <TextBox />. How many of you find an application without a TextBox relevant to your day to day coding?

Mistake #2: Not even a good Games Tutorial

Developers reading this book will have to trudge through dozens of code snippets relating to Gaming application architecture.

One would at least expect that code to be useful and relevant as a gaming tutorial. But it’s not. This isn’t how you architect games.

All throughout this book I was looking for a “Sprite” class which is mandatory in all Gaming Architectures but couldn’t find it. This book rebuilds the whole concept of a Screen, Sprite and Movement without calling them by their proper names and mixing responsibility.

To put it bluntly: This is not a properly written gaming tutorial.This book should have consumed one of the many Gaming frameworks out there and not roll out it’s own. (With my favoruite Gaming framework being Bill Reiss’s SilverSprite)

That might fly in a gaming tutorial book, but not in an MVVM book. Readers of this book shouldn’t spend precious pages on reinventing a square wheel.

The book has 1 Command Sample in it, 1 Binding Sample in it and not a single VisualStateManager sample in it.

There are some sections of the book that scream out “This needs to be MVVMed” but aren’t.

The above code snippet screams out to me “Refactor into 1 Visual State Group with 4 Visual States!”. But even such a basic example is left standing in this book.

In a MVVM book, I’d expect the book to be filled with these 3 basic concepts, and yet there are hardly any mentions of them anywhere. This book isn’t about teaching MVVM fundamentals, but you just can’t have a conversation about MVVM without these 3 core concepts.

The book is stuck in a quagmire of trivialities instead of focusing on substantial MVVM issues.

Mistake #4: Not a good Code oriented book

There are lots of places in the book where I felt “Wow, If this was going through code review I wouldn’t let anyone check this in.” There’s clearly quite a few Anti-Patterns, Code Smells and Worst practices throughout the sample codebase. Even if you weren’t programming in Silverlight & WPF, these apply to any platform or coding language.

There’s some pretty fundamental anti-patterns in this book.

One thing that was like nails on a chalkboard to me was the prolific use of Enums and multiple Switch Statements.

Enum switch statements are widely regarded as an anti-pattern when there’s more then 1 switch statement per enum. Most of the enums in this book should have been refactored to independent classes.

Any change to the BubbleTaskType enum would cause many cascading changes all throughout this application. Which will cause a high overhead when maintaining this application.

Some of the code in this book just seems like there’s some pretty fundamental coding principles missing from it. The author is entitled to his own unique style of coding (like we all are), but public book authoring needs to be held to a higher standard.

Mistake #5: Doesn’t even mention Blend

One of the main benefits from MVVM is the ability to design views separately from their behaviour. MVVM Developers should use designers like Expression Blend and the Visual Studio designer to built their screens. But this book doesn’t even mention that or touches on that point.

Most of the code in this book is pretty non-designer friendly and would cause MVVM developers to get the wrong idea about MVVM development. In an advanced MVVM book I’d expect to see some talk about designers, yet there isn’t any.

Is there anything good about this book?

Sure, it’s a huge article written by an extremely smart and talented author. There are bound to be many great tips & tricks spread throughout this book.

However this book is a failure as an MVVM book, It’s a failure as a gaming tutorial book, and it’s a failure as a code sample book.

Follow-up Discussion on the WPF Disciples

We’re having a discussion on the WPF Disciples newsgroup reading this book review. There seems to be a consensus that I’m wrong and this is an incredible book.

But Justin, I want to learn MVVM!

“Well Justin, you just crashed my hopes of ever learning MVVM! I’m going to drown myself somewhere to teach you a lesson!”

Well, Please don’t. You can still easily learn MVVM like we all did. There are some great blog posts out there. Literally every Silverlight & WPF expert has written about MVVM at some point or another. Here’re a few blog post to get you started: 1) Laurent Bugnion2) Shawn Wildermuth3) John Papa4) Jesse Liberty5) And lots more