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.
If you’re interested in how real gaming applications look like, I suggest reading Bill Reiss’s blog, Andy Beaulieu’s blog and many other Silverlight Gaming oriented blogs.
Just like this picture, when looking at the Gaming Architecture samples in this book, I’m left thinking “This isn’t right”…
Mistake #3: Not a Good MVVM Book
MVVM is essentially about these 3 things:
1) Data Binding
2) Commands
3) VisualStateManager.
Once you’ve got those three basic aspects down, everything else flows naturally.
Maybe this would have been a more appropriate book cover?
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.
From Code Smells on Jeff Atwood’s “Coding Horror” blog:
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.
Feel free to read the whole discussion or my summary of the points made.
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 Bugnion
2) Shawn Wildermuth
3) John Papa
4) Jesse Liberty
5) And lots more
Sincerely,
-- Justin Angel
Comments
Reed Copsey Says:
Justin Angel Says:
Great question.
From my perspective, VSM allows you to declare visual states in a way that's designer friendly.
Let's consider a simple user form: the "Agree To conditions" page. There's a checkbox on the page that says "I Agree to the terms and conditions" and a button on the page that is only clickable when that checkbox is marked.
Whether you declare visual states or not - This form has 2 visual states:
1) User Agreed to Conditions
2) User has not Agreed to conditions
The page will need to maintain those visual states.
Using VSM allows you to surface those Visual States as a contract between the View and the ViewModel. With the added bonus of being extremely designer friendly.
Pontus Munck Says:
Bob Baker Says:
Pete O'Hanlon Says:
We are busy having a discussion about this right now, and there's a lot of people disagreeing with the conclusions there; especially with regards to what the pillars of MVVM actually are.
Joe Bako Says:
The whole point in seperating out the M and VM from the V is for loose coupling, code re-use, and testability. Any book discussing MVVM needs to touch upon all of these aspects, and an "Advanced" MVVM book should deep dive into many ways to take advantage of these benefits, with pros and cons for each.
From this standpoint, it doesn't matter what application is used as a demonstration, or even the technology. The book is "Advanced MVVM," not "Advanced WPF" or "Advanced Silverlight" or "Advanced Blendability for WPF and Silverlight." None of those technologies have anything to do with MVVM, other than MVVM is popularized from them.
So, with this in mind, I'd like to see a bit more of an objective review of the book from the perspective of what it teaches about MVVM itself - not what it does (or doesn't) teach about C#, WPF, Silverlight, Blend, or games.
Glenn Block Says:
As far as the scenario, Josh can tell you I initially had an adverse reaction, but after talking to him I changed my mine. Josh's goal was not to show MVVM for business apps, it was to focus on the simplicity of the pattern and how to use it. He refined it to the bare basics in a set of easy to grasp scenarios. I do think he can go much further, but I really enjoyed the book.
Glenn
Justin Angel Says:
I'd assume that could be considered "an MVVM implementation". Is it too much to ask for that in a book titled "Advanced MVVM" the MVVM implementation be real-world relevant? I don't think so.
Choosing a game for the MVVM book was a mistake.
The scenario is indeed easy to grasp, but there's a tremendous amount of hacking and reinvention of square wheels becuase of this bad problem domain.
Josh Smith Says:
I'm sorry that you didn't enjoy my book. It sounds like you and I have very different opinions on what MVVM is and what constitutes a good MVVM book. I'm happy with how my book turned out, and I've received a lot of positive feedback from folks who have read it. I hope your review proves useful to others who think along similar lines to you, and prevents them from buying a book they might not enjoy.
Thanks,
Josh
Pontus Munck Says:
I would have liked a book with more focus on LOB, how to solve common UI designs using MVVM, different ways to bind View-ViewModel, event routing, Blendability etc. I don't think it's wrong to talk about specific WPF/Silverlight technologies in an advanced MVVM book. After all, the main reason for inventing the MVVM name for an old design pattern was technology driven.
It's not a bad book, it was just not what I was hoping for. I still think you should buy it if you want to learn more about MVVM.
solve different
sacha Says:
I would also argue that VSM has nothing to do with MVVM, after all its Model-View-ViewModel.
I has also written a MVVM framework that has recieved a hell of a lot of very positive feedback from people actually do MVVM for LOB (your biggest audience of the pattern), and I liked the book, and could still see where Josh was going with it all.
I have a great deal of time for both of you, but I still feel Joshs book has a lot to offer a lot of different stages of developer.
I do agree I would have like a LOB example,. but a game it also ok by me
Mike Stokes Says:
In my mind, if you take it with a grain of salt and apply it to your situation and coding style then even if you get one great takeaway tip, it's worth $15. But I'd like to see something written more in the style you suggest and using that approach. I think there's room for many styles but yours is most relevant to us and our Silverlight development strategy.
Rohit Says:
SXG: Man you are blunt but funny, never ever have I come across a personal website which is fully done in silverlight, I was wondering the intentions of doing it in the first place.
Rohit Says:
Ward Bell Says:
Once you accept that (a) Josh's extended essay isn't definitive and (b) the code is full of smells, you can relax and appreciate the art of it ... the gentle way it invites someone new to MVVM to join the party.
The first order of business is to get developers to embrace separation of view from the code that drives the view. Everything after that is detail.
It doesn't really matter whether he uses a game or LOB to illustrate; both benefit from the pattern.
Of course we can't just leave it there.
I didn't. I wrote my own review long ago (http://codebetter.com/blogs/wardbell/archive/2010/03/19/mvvm-josh-smith-s-way.aspx) although, due to the vagaries of real life I postponed publication until today.
If you have a moment, I think you'll find I raise many of the same objections and others as well. I hope I've done so in a constructive manner.
I've heard that your review pissed people off. I don't think it's that bad actually. Perhaps there is something in your style - the way it verges on lampoon, it's strident, absolutist tone - that conveys an arrogance which obscures your message. You might want to reconsider that next time. P.S., we share this fault as we do so much else :-)
Of your points I take serious issue only with the notion that VSM is intrinsic to MVVM; for me VSM is merely a facilitator, one in the bag of tricks that make MVVM easier to implement in WPF or Silverlight. I too called out the ill-advised trigger-happy moments in Josh's example; the VSM would have made the code much cleaner and clearer. But that observation is quite apart from your conflation of VSM and MVVM.
--
p.s.: What's with the tiny comments textbox? You forced me to write with VS 1995 (aka, NotePad).
How does one add a link inside a comment? Ctrl-K blasted me out of the page (I thought it discarded my comment as well). What a pain; even an HTML blog figures this out. Grumble, grumble.
Jeremy Brayton Says:
The problem with a book of this nature, and specifically the code, is 98% of the people are going to copy/paste/refactor. It's a shame to admit I'm one of those but that's how I learn. Get something that works, put a stick of dynamite under it, and reassemble it once it blows up.
I think the point is that this book is a circle jerk for existing MVVM experts, and why most of the WPF Disciples group seems pissed off about this review. Of course you're going to like it, you already understand the core concepts. The "advanced" in the title, at least to me, is taking what a beginner book talks about and running a marathon versus that beginner sprint in a relay race of sorts. I don't feel like the baton was passed at all. Like a runner just started at some arbitrary time going down side streets and shortcuts. He reaches his destination but without the baton and being so far outside the elected course of a marathon did he really get that proper accomplishment?
I'll reiterate that I think Josh and the WPF Disciples group are great. I've learned a ton just by a very few reads but being an inexperienced MVVM n00b I doubt I could buy this book until I'm well passed intermediate and bordering on expert. That's not to say I wouldn't enjoy it until then but I'd have to know what to ignore and I won't be to that stage for a little while longer, which is kinda sad on my part.
Rohan Says:
It could have been done a long better, considering Josh Smith's potential as an author. On the other hand, Justin Angel could have written the review in a much better way. i.e without that big Reg cross strike and so many "failure" mentions. It almost pulled me to voice my support for Josh, on this book. Anyway I just conveyed what I wanted to convey. Thanks
Rohan Says:
John Mikalauskas Says:
I agree with most of what you said but you could have been slightly more diplomatic. Josh rocks and I know you love him so...you could have mentioned some of the strengths of the book: patterns, simplicity, advanced concepts, etc...
Now since ALL I do is LOB apps, why don't you write a nice book for us guys to sharpen up on. I am currently on a app that has multiple views into a single view model - how exactly should I code that? Right now a public prop in the main vm...but that seems "old school" (which I am) Testing through the error dialogs is a pain, still. A common dialog for user notifications would be great. I use Async/ Await for the spinnie things to show up and entertain the user but am I doing that correctly? It does not have to be lamba/ delegate advanced but am I doing it sort of right? I do not know. It works but it would be great for a full 55 page book on LOB best practices. And I'd pay double Josh's price for that anytime.
But thanks for the opinion piece on the book.
And sorry, I've never used VSM. I might and certainly your response to Reed (Thanks for all you do Reed!) is so simple, I am not sure I would even consider VSM...
Peace out.