Why ASP.NET MVC?

An Interview with Phil Haack of Microsoft

by Michael Swaine

We chat with the Project Manager for the ASP.NET MVC project at Microsoft.

“You should interview Phil Haack,” Jonathan McCracken told me on the day that he turned in his article on ASP.NET MVC for this issue. “He can provide some perspective on the technology.” It seemed like a good idea. So we did.

ms:
Thanks for chatting with us, Phil. Could you start by describing your role on the ASP.NET team?

ph:
My role on the ASP.NET team is to provide comic relief and to raise a ruckus. As my co-workers often remind me, I’m not that funny. So I guess it’s a good thing that my official role is that of a Program Manager (PM).

ms:
Which means—?

ph:
The Program Manager role at Microsoft means slightly different things to different teams, but in general PMs focus on the big picture when it comes to a feature or product, making sure we’re building the right features, and then driving the product or feature set to completion.

On the ASP.NET team, we often use the term “ownership,” as in a PM “owns” certain features. Often, this means simply making sure nothing falls through the cracks. My primary focus has been ASP.NET MVC, but I own several other features as well.

ms:
What’s your technical background?

ph:
Not counting an abacus, my first computer was a TRS-80 Color Computer my dad bought when I was around five or six. That was my first exposure to programming and computers, though much of that was time spent with my dad typing in hundreds of pages of BASIC listings. I remember also writing a lot of stupid little programs at the time. I wrote a Mad Lib-style program as well as a program that was intended to store all my sordid secrets (which admittedly were few). The program required a password, but was easily circumvented by a command to list the source code. It was many years before I learned about such things as encryption and hashing algorithms.

That experience started a lifelong love for computers, though I didn’t start programming professionally until I graduated from college. I studied mathematics in college and really enjoyed it and just assumed I would go on to graduate school. But I had all these college bills racked up so I decided to take a brief stint to work before applying to graduate school. I’m still on that “brief” stint.

ms:
Apart from your work at Microsoft, you are active in open source work. You lead the Subtext Project, an open source blog engine on the ASP.NET platform. How did that come about?

ph:
At my first job I really enjoyed the creativity in writing software but often chafed at many of the unfulfilling projects that I worked on, hoping to work on something more interesting. I also felt isolated working at a very small company in a place (Los Angeles) where there was The Industry and it wasn’t software. I just wasn’t connected to a lot of like-minded developers.

That’s when I discovered the triumvirate that in many ways has defined my career since then: RSS, Blogging, and Open Source Software. These three things connected me to a large world-wide community of developers interested in improving the craft of software and sharing ideas.

I tiptoed my way into open source. I started off by contributing documentation to RSS Bandit, an open source desktop RSS aggregator. Over time as trust grew, that led to commit access and I implemented a few small features. Around that time I also started playing with .TEXT and grew frustrated with how complicated the setup was. The author of .TEXT started a business with a few others and turned .TEXT into a non-open source product called Community Server.

At the time, I felt their product targeted a different audience from the hobbyist who wants to hack on a blog engine. Since .TEXT was effectively dead, I decided to fork it into a new project geared toward the hobbyist developer that I named Subtext.

That started my plunge into managing an open source project, which is in many ways like becoming a parent. At the time I had no idea of the level of commitment I was getting into and how much of my time it would consume. Not to mention all the sleepless nights.

ms:
What led you to join Microsoft?

ph:
Before joining Microsoft, my entire career had been in Los Angeles working on the Microsoft stack. I spent most of my first job writing web applications using Active Server Pages (ASP) and later ASP.NET.

I often hoped to work on software projects that allowed for more time to think about the long term rather than always writing software due yesterday. I thought working at a place like Microsoft building frameworks might provide more interesting work than the work I was currently engaged in, but I loved living in Los Angeles and didn’t really give it much thought.

But many years later, I was visiting Microsoft as part of a VSIP conference and I happened to go wandering in building 42 (where all the magic happens) to see who I might run into.

ms:
Wandering the halls of Microsoft to see who you might run into is an interesting style of networking. How did it work out?

ph:
It just so happened that I ran into none other than Scott Guthrie, a General Manager at that time, who wanted to show me something cool that the ASP.NET team was in the early stages of prototyping.

He drew an action method on the whiteboard and I was immediately sold. After he described what they had done so far, I told him immediately “I want to work on that!” and we got the ball rolling.

ms:
So that gets you to Microsoft and involved with ASP.NET. What is the history of the MVC Framework? Was it developed as a result of developer requests?

ph:
I joined Microsoft after the framework was underway, so I wasn’t there at the genesis. But as I understand it, the ALT.NET movement was a real impetus in its origins. At the time, a vocal group of ASP.NET developers were touting the benefits of the simpler model of web development embodied by Monorail, which itself was inspired by Ruby on Rails.

ASP.NET MVC was developed as an alternative to the existing Web Forms framework for building web applications for those who preferred this pattern of web development.

ms:
One of the touted virtues of ASP.NET MVC is that it enables TDD. How important is it to your own development work?

ph:
I’d be a pretty crappy developer if it weren’t for TDD, so yeah, I’d consider it pretty important to my own development work.

I remember when I was first introduced to it after reading some article about it. I didn’t grok it at first, coming from an ASP background. How could code test other code? That just didn’t seem reasonable considering the code I was writing at the time.

It wasn’t until my company hired a developer who was well versed in TDD and was willing to coach the team that I started to really grok the mechanics of TDD. Later, I realized the reason I didn’t grok it at first was that I was thinking about it in terms of the code I had written in the past. But TDD is a technique for shaping the design of code. The code I wrote using TDD looked nothing like the code I wrote before. It exhibited better separation of concerns, was more cohesive and focused, and was easier to change.

But it has been a long process of learning for me and I am still a student. For example, I take pride that Subtext started with 0 unit tests and now has over 1500. I’m ashamed at how many of them hit the database, though as a form of penance I am in the midst of a long-term refactoring to change that.

ms:
Could you sketch out the argument for using ASP.NET MVC?

ph:
There are many features of ASP.NET MVC that make it a compelling offering. One of my favorites is its support for binding submitted form inputs to arguments of an action method by matching up the name of the input to the argument name. With ASP.NET MVC, there’s no need to go foraging in a Request dictionary to extract submitted form values.

With a feature called model binding, we take it even further by binding submitted form values to matching properties of an input model. You can apply validation attributes on that model so that validation occurs when binding, and that validation can be “floated” to the client via JavaScript. This is a nice way to drive client-side validation based off of the validation applied to the model on the server.

The ASP.NET MVC framework itself is designed to reduce the friction for developers when writing unit tests of their code during development. It’s also extremely extensible, which many in the community have taken advantage of by developing custom view engines and other such features.

A big benefit of ASP.NET MVC is that it’s part of a larger family of well integrated products. ASP.NET MVC builds on top of a mature ASP.NET framework that provides performance, scalability, and a very solid well-tested platform.

And ASP.NET itself builds on top of the .NET Framework and the CLR. I particularly enjoy working with a modern language like C#.

ASP.NET MVC also leverages Visual Studio, which is a fantastic and powerful IDE. ASP.NET MVC layers on extensions to Visual Studio that allow you to easily scaffold a view while writing code via a keyboard shortcut or a context menu.

One of my favorite quotes about ASP.NET MVC was on Twitter from someone who said for them, ASP.NET MVC makes web development fun again.

ms:
Can you characterize the developers who are using ASP.NET MVC?

ph:
Originally, I thought the audience would primarily be the very advanced professional developer interested in TDD and this style of development. But I’ve found that the audience is much bigger than I expected and is all over the map. We have large enterprises like Dell taking a big bet on it as well as start-ups like StackOverflow.

ms:
What’s been the reaction of developers with Ruby on Rails experience?

ph:
It’s been a mixed reaction.

Some have not been favorable towards it, as they feel that a framework built on statically typed languages doesn’t have the expressiveness and elegance of code written in Ruby.

On the other hand, I’ve heard from many Rails developers who have found themselves working on a .NET project for various reasons and were very happy that ASP.NET MVC was an option for them. They found it to be a more familiar pattern to them than Web Forms and enjoyed working with it and gave it a thumbs-up.

ms:
Well, thanks again, Phil. We really appreciate your taking the time to answer these questions.

ph:
My pleasure.

Phil Haack is a megalomaniacal software developer with delusions of... well, uh, just delusions. As a code junkie, he not only enjoys writing software, but writing about software on his blog. By day, he is a Senior Program Manager at Microsoft on the ASP.NET team. By night he changes diapers while leading the Subtext Project, an open source blog engine. And no, they are not his own diapers.