"Advanced MVVM" Book Review

261 views
Skip to first unread message

Justin Angel

unread,
Mar 12, 2010, 1:56:31 PM3/12/10
to wpf-di...@googlegroups.com

Hi Folks,

 

I published a castigating review of Josh’s new “Advanced MVVM” book.

http://JustinAngel.net/AdvancedMvvmBookReview

 

Feel free to leave your feedback in the comments or on this list.

If there’s anything I haven’t taken into account, I’d love to change the blog post and make it more even-handed.

 

-- Justin Angel

(Feeling like the furry green guy who stole the winter festival.)

Peter O'Hanlon

unread,
Mar 12, 2010, 3:09:30 PM3/12/10
to wpf-di...@googlegroups.com
Ahem.
 
"MVVM is essentially about these 3 things:
1) Data Binding
2) Commands
3) VisualStateManager. "
 
That's a particular Silverlight conceit. VSM is a poor second cousin in WPF.
 
Having read Josh's book, I think that it's beholden on me to leap to his defence here, you should have mentioned that this is effectively part 2. This book is the follow up to Josh's highly successful MVVM article in the MSDN magazine. BTW - MVVM is essentially about 1 thing, separating the View from the ViewModel from the Model; everything else is just implementation detail.

--
Peter O'Hanlon

Cory Plotts

unread,
Mar 12, 2010, 3:18:16 PM3/12/10
to wpf-di...@googlegroups.com
I totally agree with Peter ... my reaction on reading that the VSM was one of the main tenets of MVVM .... was "What? Are you serious?"

I've only read halfway through Advanced MVVM but have thoroughly enjoyed it so far ... and think it offers a lot to the community in terms of what MVVM is about.

And to your point that it isn't a good gaming tutorial ... I don't think that was Josh's intent at all. It was to illustrate MVVM and how you could apply that to any scenario ... even a simple game.

Jeremiah Morrill

unread,
Mar 12, 2010, 3:20:13 PM3/12/10
to wpf-di...@googlegroups.com
 It was to illustrate MVVM and how you could apply that to any scenario ... even a simple game.

I was just about to write something similar when your email came in.

-Jer 

Evan Lang

unread,
Mar 12, 2010, 3:30:06 PM3/12/10
to wpf-di...@googlegroups.com

As nothing more than a pattern, it’d be instructive to point out that MVVM could be implemented through LISP and INI files.

 

It would surely be the cause of a great many suicides, but it could be done…

 

Seriously though, I think a blog post about how one might implement the tenets of MVVM in non-XAML, non-C# based environments might be highly instructive out there to the apparently confused masses who think MVVM is an API.  I’m no MVVM guru so I’d invite any of you guys to feel free to jump on that. J

Peter O'Hanlon

unread,
Mar 12, 2010, 3:38:31 PM3/12/10
to wpf-di...@googlegroups.com
Now that's just sick.
--
Peter O'Hanlon
361.gif

Bill Kempf

unread,
Mar 12, 2010, 3:40:51 PM3/12/10
to wpf-di...@googlegroups.com
Yeah, even Commands could be questionable in such an arbitrary and not
really relevent list (the pattern, as you say, is about the separation
and not how you achieve the separation). You can go a long way using
Behaviors and Actions instead of commands. In fact, in the early days
we had to figure out how to bend commands to be MVVM friendly. It's
only recently, when DelegateCommand and it's variants have become so
prevalent, that we've started to associate commands with MVVM. In
fact, if I were to be totally objective, I'd even say that data
binding is irrelevant to the pattern. Martin Fowler talked about the
need to synrhonize state in his article about Presentation Model
(which I believe we all agree is the same pattern), and lamented that
this resulted in a lot of "boring and repetitive" code to write, and
even went on to say he was hoping this repetitive coding "will happen
some day with technologies like .NET's data binding."

In WPF, today, it's common to use data binding and commands to
implement the MVVM pattern. In SL maybe it's also common to utilize
the VSM, though my lack of exposure to it leads me to wonder if that
doesn't to tightly couple the V and VM? But for an article that's
using WPF, I wouldn't expect to see any VSM code.

I've not read the Josh's book yet, but that part of the review stuck
out to me and made me question the validity of the rest of the review.

--
Quidquid latine dictum sit, altum sonatur.
- Whatever is said in Latin sounds profound.

War is peace. Freedom is slavery. Bugs are features.

Colin Eberhardt

unread,
Mar 12, 2010, 3:50:42 PM3/12/10
to WPF Disciples
Peter wrote:
> BTW - MVVM is essentially about 1 thing, separating the View
> from the ViewModel from the Model; everything else is just implementation
> detail.

If that is the case, why is it called the MVVM pattern and not the
presentation model (PM) pattern as described by Martin Fowler?

http://martinfowler.com/eaaDev/PresentationModel.html

I have seen MVVM described as a realization or refinement of the PM
pattern in a number of places and I would agree. It is a specific way
of implementing the PM pattern that happens to work very well in WPF /
Siverlight. It also incorporates some technology specific concepts
like developer / designer workflow.

Evan wrote:
"Seriously though, I think a blog post about how one might implement
the tenets of MVVM in non-XAML, non-C# based environments might be
highly instructive out there to the apparently confused masses who
think MVVM is an API. I'm no MVVM guru so I'd invite any of you guys

to feel free to jump on that. :) "

I recall seeing an article demonstrating how a PM can be shared across
WPF, WinForms & ASP.NET:

http://www.codeproject.com/KB/smart/PMinAction.aspx

I have not read the article in detail - so can't vouch for its
quality!

I have also used PM / MVVM in the design of complex WinForms controls.
However, when the MVVM pattern is employed in WPF it is to provide
look-less / blendable controls. For WinForms our reason for using the
pattern was for testability.

Regards,
Colin E.

Jeremiah Morrill

unread,
Mar 12, 2010, 4:00:56 PM3/12/10
to wpf-di...@googlegroups.com
"you just can’t have a conversation [with Justin Angel] about MVVM without these 3 core concepts."

There, I fixed that one for you ;)

-Jer

Colin Eberhardt

unread,
Mar 12, 2010, 4:01:31 PM3/12/10
to WPF Disciples
> In WPF, today, it's common to use data binding and commands to
> implement the MVVM pattern. In SL maybe it's also common to utilize
> the VSM, though my lack of exposure to it leads me to wonder if that
> doesn't to tightly couple the V and VM? But for an article that's
> using WPF, I wouldn't expect to see any VSM code.

The VSM concept uses attached properties to assign states to controls
and define transitions between states. I am not sure it has much to do
with MVVM. I am pretty sure that unless your VM is a Control it canot
have a visual state, in which case the VSM sits entirely within the V.

For this reason, I don't think you can castigate Josh for leaving it
out of the book.

However, if MVVM is more than just the Presentation Model, and is
about the whole process of WPF / Silverlight development, which
includes design, then the VSM is probably worth a mention.

Incidentally, in a LOB application you probably have much less need
for VSM & Blend anyhow ;-)

Regards.
Colin E.

Bill Kempf

unread,
Mar 12, 2010, 4:05:34 PM3/12/10
to wpf-di...@googlegroups.com
Arghhhhh!!!!

Because MVVM was the name given to the pattern by John Gossman when he
independently discovered it, while Presentation Model was the name
Martin Fowler gave it when he independently discovered it. It *IS THE
SAME PATTERN*. The claim that MVVM is a refinement using WPF
techniques is just a justification for sticking to the longer name
made after the fact. I've hated that distinction, because it leads
directly to claims like this one here. The pattern is NOT about data
binding, commanding, VSM, event aggregator, IoC, service location,
Behaviors, Triggers, Actions or any of the dozens of other techniques,
classes and patterns we use to realize the MVVM pattern.

--

Peter O'Hanlon

unread,
Mar 12, 2010, 4:08:06 PM3/12/10
to wpf-di...@googlegroups.com
Well said, and much more eloquently put than I could.
--
Peter O'Hanlon

Colin Eberhardt

unread,
Mar 12, 2010, 4:16:06 PM3/12/10
to WPF Disciples
I had not realized it was a parallel discovery (or invention
perhaps ;-)

However, could you implement the MVVM pattern in WPF in such a way as
to ruin the designer workflow? In this instance would people still
call it MVVM?

(By the way, this is not meant as a rhetorical question, not having
owrked with Blend or the arty types I expect use it, I am not sure of
the answer)

Regards,
Colin E.

Daniel Vaughan

unread,
Mar 12, 2010, 4:53:21 PM3/12/10
to WPF Disciples
I enjoyed the book. Thought it was solid. Josh gets it, and it's how I
do things.

On Mar 12, 9:09 pm, "Peter O'Hanlon" <pete.ohan...@gmail.com> wrote:
> Ahem.
>
> "MVVM is essentially about these 3 things:

> 1) *Data Binding*
> 2) *Commands*
> 3) *VisualStateManager*. "


>
> That's a particular Silverlight conceit. VSM is a poor second cousin in WPF.
>
> Having read Josh's book, I think that it's beholden on me to leap to his
> defence here, you should have mentioned that this is effectively part 2.
> This book is the follow up to Josh's highly successful MVVM article in the
> MSDN magazine. BTW - MVVM is essentially about 1 thing, separating the View
> from the ViewModel from the Model; everything else is just implementation
> detail.
>
>
>
> On Fri, Mar 12, 2010 at 6:56 PM, Justin Angel <J...@justinangel.net> wrote:
> >  Hi Folks,
>
> > I published a castigating review of Josh’s new “Advanced MVVM” book.
>

> >http://JustinAngel.net/AdvancedMvvmBookReview<http://justinangel.net/AdvancedMvvmBookReview>

Bill Kempf

unread,
Mar 12, 2010, 5:09:36 PM3/12/10
to wpf-di...@googlegroups.com
Yes, you can. Would I? Absolutely not! Would people still call it
MVVM? They should! They should also call it crap, but that's a
different matter ;).

Glenn Block

unread,
Mar 12, 2010, 5:12:00 PM3/12/10
to wpf-di...@googlegroups.com
MVVM as a pattern has NOTHNG to do with VSM. VSM is an implementation detail. MVVM is about one thing, UI decoupling. Commands and Databinding are the common way to achieve that. VSM might make sense, but I would hardly call it integral.

Glenn Block

unread,
Mar 12, 2010, 5:15:52 PM3/12/10
to wpf-di...@googlegroups.com
I just replied on the blog and stated my issues with your review.

Evan Lang

unread,
Mar 12, 2010, 5:16:57 PM3/12/10
to wpf-di...@googlegroups.com
If we're concerned with whom deserves credit for the invention of MVVM, it probably belongs to someone in the video game industry, though I couldn't begin to guess who. I dunno if any of them ever put a name to it, but separating code concerns from designer concerns WRT user interfaces is something they've been doing for a long, long time.

Peter O'Hanlon

unread,
Mar 12, 2010, 5:19:24 PM3/12/10
to wpf-di...@googlegroups.com
I see the way that this works now. Every now and again, one of us has to post something really controversial and then sit back and watch while the flames get higher. My turn...
 
Josh. Bach sucks. (Now I know that Josh is big enough to let critique of his book slide, but dissing the JSB will arouse him to levels of apoplexy not seen since somebody stopped Karl from taking a computer on holiday; I happen to know that Karl went Ninja on the travel agents ass that day).

--
Peter O'Hanlon

Bill Kempf

unread,
Mar 12, 2010, 5:20:07 PM3/12/10
to wpf-di...@googlegroups.com
If it's just separation of code concerns from designer concerns we go
back to Smalltalk and MVC. MVVM/Presentation Model is a variation on
this older pattern, along with other variations like Passive View. I'm
not sure if anyone in the game industry used MVVM prior to the
publication of the name or not, but if they didn't publish, they don't
get credit :). Gossman and Fowler get credit for independently
discovering/inventing this pattern in my book.

Glenn Block

unread,
Mar 12, 2010, 5:22:24 PM3/12/10
to wpf-di...@googlegroups.com
I like Fowler, but undue credit goes his way. He didn't name anything. He compiled the pattern that others were already using.

Bill Kempf

unread,
Mar 12, 2010, 5:25:53 PM3/12/10
to wpf-di...@googlegroups.com
Yeah, well, you know, we were all following the GoF patterns long
before anyone even considered the fact that there were such things as
patterns. Just because one uses a pattern does not mean they get
credit for the patterns discovery. You have to realize a pattern
exists, and provide a name and description of the pattern. Without
that, it's just code, and not a pattern.

Bill Kempf

unread,
Mar 12, 2010, 5:46:02 PM3/12/10
to wpf-di...@googlegroups.com
I just blogged on this topic (MVVM misunderstandings, not the review).

http://digitaltapestry.wordpress.com/

Laurent Bugnion, GalaSoft

unread,
Mar 12, 2010, 6:19:21 PM3/12/10
to wpf-di...@googlegroups.com
The way I explain it in my MIX talk (on Monday) is that MVVM is just
presentation model. The rest are helpers that are there to help you build SL
and WPF apps. That includes commands, messaging, VSM, etc.

Regarding databindings, the way I see it is that presentation model is an
extension of the Passive View pattern where the view is a bit more active
(since it is notifying the viewmodel when something changes). Passive view
is great because it doesn't need to be unit tested (since it is passive),
but presentation model is great in frameworks that have extensive data
binding like WPF and SL. Thus, presentation model (aka) works great in
WPF/SL.

You are mistaken that only a control can have a state. VSM can be applied to
any framework element. If you use VSM in a panel (such a grid) however, you
need to trigger the state change yourself. Typically we do this using a
Blend behavior such as the GoToStateBehavior (reacts to an event) or the
DataStateBehavior (reacts to a property change). However I would typically
not do that in WPF, because of the need to use a Blend behavior which
requires Sys.Win.Interactivity.dll. Instead I would prefer Data trigger in
WPF.

Finally, you should see the last LOB application I worked on at
IdentityMine. This thing's design was so complex (and beautiful) that I
couldn't have done it without Blend. LOB != ugly!!

;)

Cheers,
Laurent

-----Original Message-----
From: wpf-di...@googlegroups.com [mailto:wpf-di...@googlegroups.com]
On Behalf Of Colin Eberhardt
Sent: Friday, March 12, 2010 10:02 PM
To: WPF Disciples
Subject: [WPF Disciples] Re: "Advanced MVVM" Book Review

Laurent Bugnion, GalaSoft

unread,
Mar 12, 2010, 6:20:27 PM3/12/10
to wpf-di...@googlegroups.com
Agreed. This was confirmed to me by John Gossman himself. They were just
working on the same stuff approximately at the same moment.

Cheers,
Laurent

-----Original Message-----
From: wpf-di...@googlegroups.com [mailto:wpf-di...@googlegroups.com]

On Behalf Of Bill Kempf
Sent: Friday, March 12, 2010 10:06 PM
To: wpf-di...@googlegroups.com

Laurent Bugnion, GalaSoft

unread,
Mar 12, 2010, 6:23:40 PM3/12/10
to wpf-di...@googlegroups.com
There are many separation patterns. MVC is the best known probably, but
Passive View is also interesting.

In fact, if I am not mistaken, Fowler came to the Presentation Model idea
through the passive view pattern. Presentation Model, as I wrote just
before, is a variation of passive view where the view is a bit more active.
This works great in WPF and SL, because the active part is played by the
databinding system, which is included in the framework, and thus does not
need to be unit tested. So you have the advantage of passive view (no unit
test of the view) and the flexibility of a moderately active view.

Laurent

Justin Angel

unread,
Mar 12, 2010, 6:43:35 PM3/12/10
to wpf-di...@googlegroups.com

LOL. Sorry about that, I’m moving to San Francisco on Monday and I’m busy running errands.

I’ll respond to the disputed pointes soon.

 

From: wpf-di...@googlegroups.com [mailto:wpf-di...@googlegroups.com] On Behalf Of Peter O'Hanlon


Sent: March-12-10 2:19 PM
To: wpf-di...@googlegroups.com

Michael D. Brown

unread,
Mar 12, 2010, 7:23:19 PM3/12/10
to wpf-di...@googlegroups.com

Plain and simple…I haven’t read Josh’s book yet because I’ve got a huge deadline looming. But even without reading Josh’s book, I can refute your arguments.

1.       VSM didn’t exist when the MVVM pattern was created so saying that VSM is a pillar of MVVM is ludicrous.

2.       When I was planning to write an article on MVVM, my initial thought was to take an existing game (Charles Petzold’s Contagion sample) and apply MVVM to it

3.       Saying that because there was only one example of the command pattern in the book is a bad thing is faulty logic. The book is meant to provide examples of how the pieces fit together. Once he’s shown it one time, what’s the point of repeating himself?

4.       When I demonstrated the Azure Service Bus, I used a very refined and refactored sample. The audience spent more time trying to figure out what I was doing because I was using patterns that they hadn’t seen before that the point of “Hey it’s a simple WCF service call to do this” was lost. So yes the code isn’t using “best practices” but it is approachable to all levels and it doesn’t get in the way of Josh’s message regarding MVVM

5.       First you argue that his code is too simple and needs to be refactored, then you say that it’s too complex and mired in the details of the game…please make up your mind.

6.       Using DataTriggers against a bound property to change a control is a very advanced MVVM technique. VSM may have replaced the need for this, but that does not invalidate it as a valid approach.

 

I’m not sure if your “review” was just being contrarian or what. But I find it funny that I found more flaws in your discussion of the book than you found in the book. Even worse you list other resources on MVVM and don’t mention the ONLY article on the topic published in MSDN Magazine (by Josh Smith).

Michael D. Brown

unread,
Mar 12, 2010, 7:35:45 PM3/12/10
to wpf-di...@googlegroups.com

Yeah we’ve had this discussion before it’s tragic that there is a “perceived” difference in the pattern because of the two different names. I’ve applied VM to WPF, Webforms (using a nice trick with ExpressionBuilders to create a more suitable binding syntax –BTW I’ve been BEGGING Rob to consider adding a similar api to WPF, think markup extensions that get evaluated once and compiled WITH the XAML), and Winforms. MVVM, ViewModel, PresentationModel all the same thing…I wish Martin would update his article to give some “authority” to it.

 

From: wpf-di...@googlegroups.com [mailto:wpf-di...@googlegroups.com] On Behalf Of Peter O'Hanlon


Sent: Friday, March 12, 2010 4:08 PM
To: wpf-di...@googlegroups.com

Josh Smith

unread,
Mar 12, 2010, 7:45:12 PM3/12/10
to wpf-di...@googlegroups.com
Thanks for the book review, Justin. 

Josh

On Fri, Mar 12, 2010 at 10:56 AM, Justin Angel <J...@justinangel.net> wrote:

Glenn Block

unread,
Mar 12, 2010, 7:58:36 PM3/12/10
to wpf-di...@googlegroups.com
Laurent

Agreed, for a long time we didn't want to use MVVM even over PresentationModel in p&p since they seemed one and he same. The way I reconciled was that MVVM is a derivative form of PresentationModel that implies a specific method of implementation (i.e. commanding and databinding). PresentationModel on the other hand is a very general pattern for simply wrapping a model and applying UI specific formatting and logic. If you take that definition you would say that MVVM is PresentationModel, but not every application of PM is necessarily MVVM.
 
Thanks
Glenn

Glenn Block

unread,
Mar 12, 2010, 8:01:47 PM3/12/10
to wpf-di...@googlegroups.com
Having a review is great. Saying "Don't buy this book" personally I think goes over the line from personal preference.....

On Fri, Mar 12, 2010 at 4:45 PM, Josh Smith <flappl...@gmail.com> wrote:

Josh Smith

unread,
Mar 12, 2010, 8:03:08 PM3/12/10
to wpf-di...@googlegroups.com
Yeah, I agree, but what's the point in arguing with someone over it?  I can't force him to edit his own blog, so whatever...

Josh Smith

unread,
Mar 12, 2010, 8:04:57 PM3/12/10
to wpf-di...@googlegroups.com
And, plus, by making such a big stink about how awful my book supposedly is, I assume it will make the more skeptical of his readers intrigued about the book.  Who knows, it might even lead to some sales! :)

Glenn Block

unread,
Mar 12, 2010, 8:05:34 PM3/12/10
to wpf-di...@googlegroups.com
It's all about sales eh :-)

Josh Smith

unread,
Mar 12, 2010, 8:10:00 PM3/12/10
to wpf-di...@googlegroups.com
I wouldn't say it's all about the sales, but mostly. ;)

Other than the extra income, this book is something I'm proud of.  It's easy to criticize someone else's work on the Web, so I am used to receiving all types of crap from people about my publications.  I know that I'm happy with the book, and think it's a worthwhile achievement.  If someone else gets off by bashing my work in public, that's their prerogative.

Josh

Glenn Block

unread,
Mar 12, 2010, 8:14:37 PM3/12/10
to wpf-di...@googlegroups.com
Well you definitely know by the feedback that you are pushing the right buttons :-)

Josh Smith

unread,
Mar 12, 2010, 8:19:59 PM3/12/10
to wpf-di...@googlegroups.com
Or the wrong buttons, depending on who you ask! :)

Josh Smith

unread,
Mar 12, 2010, 8:27:20 PM3/12/10