This morning I went to one of Seattle’s numerous coffeehouses to get breakfast. While waiting in line, the two guys in front of me (looked like coworkers) were talking, and I overheard them use the term “ViewModel.” When their conversation came to a lull, I politely asked if they’re talking about MVVM. The following conversation ensued, between one of the guys and myself:
Guy: “Yes, we are actually.”Me: “Oh cool, that’s a great pattern. Always an interesting topic.”Guy: “We use it all the time.”Me: “What do you like about it?”Guy: “I like that it’s based on dependency injection. That makes it really easy to test ViewModels.”Me: “What do you mean that it’s based on DI?”Guy: “I mean, it’s based on DI. Have you ever actually used the pattern?” [Guy2 now smirks pretentiously]Me: “Yes, I’ve used it. But, to me, it’s based on Models, Views, and ViewModels. That’s it, no DI.”Guy: “Well it sounds like you don’t really get it then. It’s complicated, so you need to read a lot about it.”Me: “Oh, that’s good to know. What do you suggest I read to learn about it?”Guy: “Start with Josh Smith’s MVVM article in MSDN Magazine.”
I kid you not. That is literally what the guy told me. I burst out laughing so loud that I felt embarrassed and had to leave. The guy must have thought I was psychotic!
It’s worth noting that my MVVM article on MSDN never once mentions dependency injection, inversion of control, or any other dependency inversion technique. That’s because dependency inversion has nothing to do with MVVM.