Martin Hinshelwood (MrHinsh) on Visual Studio ALM

A Scottish software developer | SSW Solution Architect | Microsoft Visual Studio ALM MVP | Microsoft Visual Studio ALM Ranger | Scrum Developer Trainer
posts - 443, comments - 722, trackbacks - 57

My Links

News

Profile photo of Martin Hinshelwood Martin Hinshelwood on LinkedIn
Martin Hinshelwood on Twitter
Martin Hinshelwood on Facebook
Martin Hinshelwood on Messenger
Martin Hinshelwood on Feedburner

Martin is a Solution Architect at SSW, and also one of three Microsoft Visual Studio ALM MVP in the UK and has over 9 years experience in the software industry. Martin has recently joined the ranks of the Microsoft Visual Studio ALM Rangers deliver out of band solutions for missing features or guidance.

Microsoft Visual Studio ALM MVP

Martin speaks at DDD Scotland, one of the top events in the UK along with a number of User Groups across UK and Europe. And is excited to be presenting the Professional Scrum Developer course which he is one of only three qualified trainers in the UK.

Professional Scrum Developer Trainer Certified ScrumMaster

He aims to continue improve the engineering practices of development teams in the UK and Europe. He does this by migrating them to, and coaching them in the use of, Microsoft’s ALM offering in combination with Scrum. These offerings include Team Foundation Server (TFS) and Visual Studio.

Microsoft Certified Technical Specialist: Team Foundation Server  

Disclaimer

The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

Locations of visitors to this page

Twitter












Tag Cloud

Article Categories

Archives

Post Categories

Image Galleries

Blogs I read

Blogs of Friends

Personal

Projects

VSTS

MVVM for Dummies

I think that I have found one of the best articles on MVVM that I have ever read:

http://jmorrill.hjtcentral.com/Home/tabid/428/EntryId/432/MVVM-for-Tarded-Folks-Like-Me-or-MVVM-and-What-it-Means-to-Me.aspx

This article sums up what is in MVVM and what is outside of MVVM. Note, when I and most other people say MVVM, they really mean MVVM, Commanding, Dependency Injection + any other Patterns you need to create your application.

In WPF a lot of use is made of the Decorator and Behaviour pattern as well. The goal of all of this is to have pure separation of concerns. This is what every code behind file of every Control / Window / Page  should look like if you are engineering your WPF and Silverlight correctly:

C# – Ideal

  public partial class IdealView : UserControl
  {
      public IdealView()
      {
          InitializeComponent();
      }
  }

Figure: This is the ideal code behind for a Control / Window / Page when using MVVM.

C# – Compromise, but works

  public partial class IdealView : UserControl
  {
      public IdealView()
      {
          InitializeComponent();

          this.DataContext = new IdealViewModel();
      }
  }

Figure: This is a compromise, but the best you can do without Dependency Injection

VB.NET – Ideal

Partial Public Class ServerExplorerConnectView

End Class

Figure: This is the ideal code behind for a Control / Window / Page when using MVVM.

VB.NET – Compromise, but works

Partial Public Class ServerExplorerConnectView

    Private Sub ServerExplorerConnectView_Loaded(ByVal sender As Object, ByVal e As System.Windows.RoutedEventArgs) Handles Me.Loaded
        Me.DataContext = New ServerExplorerConnectViewModel
    End Sub

End Class

Figure: This is a compromise, but the best you can do without Dependency Injection

Technorati Tags:     

Print | posted on Friday, March 05, 2010 4:54 PM | Filed Under [ .NET WPF Silverlight MVVM ]

Feedback

Gravatar

# re: MVVM for Dummies

I would argue that you're wrong on three levels.

First it's possible to create and assign your ViewModel in Xaml leaving a fully clean code behind.

Second, even though it is possible to do this. That is not the goal of MVVM. The goal of MVVM is to separate the view logic that needs to be separated so that it can be testable, maintainable, and flexible. In many cases this does lead to a clean code-behind, but it's not a requirement.

Third, when we say MVVM we mean MVVM nothing more nothing less. People interchange MVVM Frameworks (which is what you describe) with the term MVVM. But the ViewModel pattern consists of the ViewModel and nothing else. There are supplementary patterns (such as eventbroker, delegatecommand and others) that work well with MVVM but MVVM does not include those patterns.

--Mike
3/10/2010 4:32 AM | Michael Brown
Gravatar

# re: MVVM for Dummies

hey, just finished reading, interesting stuff! do you offer some kind of email subscription so i can get more of your content
6/6/2010 3:20 AM | Compare Web Hosts
Gravatar

# re: MVVM for Dummies

This is great content, even a peanut could learn from this, keep it up
7/3/2010 9:30 AM | Rufus
Gravatar

# re: MVVM for Dummies

I'm adding you to my bookmarks, thanks for the tute.
7/5/2010 10:14 AM | Noosa Accommodation
Gravatar

# re: MVVM for Dummies

Made a few good points there, so well done, have you locked on in my RSS, looking forward to more
7/14/2010 10:31 AM | Website Ratings
Gravatar

# re: MVVM for Dummies

MVVM can be challenging, and this dummies guide has done me and doubtless many others a service.
7/15/2010 3:06 PM | meeting blog
Gravatar

# re: MVVM for Dummies

Hi Martin. I don't think MVVM is for me. A pattern to manage a pattern? Some say MVVM simplifies code, but I think it adds more complexity.
7/27/2010 4:25 PM | Les
Gravatar

# re: MVVM for Dummies

I'm adding you to my bookmarks, thanks for the tute.
8/23/2010 4:52 AM | websitemart
Gravatar

# re: MVVM for Dummies

If you Run fast your pc then read this article. world best i Phone Shopping Website Reviews
8/23/2010 6:37 PM | Shopping Website Reviews
Gravatar

# re: MVVM for Dummies

This blog is wonderful. I like it. This blog theme is nice for another nice wordpress theme download wordpress theme
8/23/2010 7:11 PM | download wordpress theme
Gravatar

# wow

Go along with, even though it is workable to figure out this. With the purpose of is not the goal of MVVM. The goal of MVVM is to separate the look at logic with the purpose of needs to be alive separated so with the purpose of it can be alive testable, maintainable, and flexible. Taking part in many hand baggage this does have an advantage to a clean code-behind, but it's not a requirement.


PS3 Mod
8/24/2010 6:26 PM | websitemart
Post A Comment
Title:
Name:
Email:
Website:
Comment:
Verification:
 
 

Powered by: