By Michael K. Campbell
At the PDC this week, Microsoft announced the ASP.NET MVC 2 Beta. Likewise, Phil Haack has mentioned that he's at least thinking about what will go into version 3. As such, it appears that it's now safe to say that ASP.NET MVC is here to stay.
Books SHOULD Make It Easier
If you haven't dabbled with ASP.NET MVC yet, the good news is that it's now been out long enough for a handful of books to crop up about it. More importantly, if you HAVE dabbled in MVC or even written some applications in it, then you've likely got some questions about how certain things work—or you're curious about best practices. Again, the release of books in this sphere should help.
One of the big problems with technical books is that it's VERY hard for a book to serve as a way to teach people about a new technology and to serve as a reference for people who already understand the technology. Unfortunately though, people typically want books to meet both needs. Consequently, it's common for publishers and authors to try so hard to accomplish both tasks that they end up failing in both regards. Every once in a while though, books do manage to pull off both feats.
A quick look on Amazon.com shows that there are roughly 10 ASP.NET MVC titles available today. I've only had time to read two of them. Interestingly enough, not only are both of them great books, but they both also do a fantastic job of teaching and serving as reference materials.
Two Great ASP.NET MVC Books
The first of these two books is “ASP.NET MVC In Action” by Jeffrey Palermo, Ben Scheirman, and Jimmy Bogard from Manning Press. The second is “Pro ASP.NET MVC Framework” by Steve Sanderson's from APress.
Both of these books do an exceptional job of introducing ASP.NET MVC. Yet neither book is for beginning developers. Instead, they both introduce ASP.NET MVC paradigms and essentials to existing ASP.NET developers. Both books also do a great job of explaining the current limitations and problems that have grown up around the use of ASP.NET WebForms and their abstraction of HTTP details away from developers. As such, not only will both of these books show you how to do things with the ASP.NET MVC framework, but they'll show you why.
In fact, in some ways, reading both of these books feels almost a bit like reading a mystery novel. Both books take you by the hand, walk you through the crime-scene, and help you start to put the pieces together in order to solve the “mystery” yourself. In this regard, both books do a phenomenal job of teaching because the end result of reading either of these books is that you'll come out with a better understanding of ASP.NET WebForms and why ASP.NET MVC exists . And how it addresses problems stemming from the WebForms approach.
By way of example, both books make a point of showcasing how ASP.NET MVC applications are much more suited to testing, but not just for the sake of testing. Instead, both books make it emphatically clear that while testing and TDD are great approaches to development, the real benefit of creating code that is easy to test is that you end up with code that's easier to manage and extend. (Consequently, I would argue that both of these books not only help developers learn a new technology, but they help developers improve their craft, which is also a tall order.)
Two Excellent Examples of Teaching and Reference
What I really loved about Steve Sanderson's book is that he tackles the issue of the dual nature of technical books head-on. The book is divided into two main sections: the first half of the book provides a high-level overview of what the ASP.NET MVC Framework means and gives a guided tour, or walkthrough, of building a sample MVC application. What's nice about the examples is that they're much more than the typical (i.e., crappy) hello-world samples you see in many articles, presentations, or even books. Instead, this sample application touches upon a lot of core concepts and requirements that developers would bump into with REAL applications - meaning that the author then walks you through how to address those issues from an MVC point of reference.
The second half of the book assumes that you already have a decent understanding of how ASP.NET MVC works (and if you've read the first half of the book that's definitely true) and then goes into an in-depth review of ASP.NET MVC Framework components, best practices, and pain-points. As part of this review, the author covers best practices for using Models, Controllers, and Views and also taps into routing, Action Filters, and how to leverage ASP.NET intrinsics from within MVC applications without sacrificing code quality or abandoning MVC conventions.
In other words, in addition to doing a great job of teaching readers about ASP.NET MVC development, this book also serves as a great reference material you'll find yourself reviewing over and over again. Overall, I enjoyed both parts of this book and am convinced that EITHER half of this book would be worth the price of the book, so getting both halves for the price of one book is a great buy.
Similarly, “ASP.NET MVC In Action” also does a great job of walking developers through an introduction to MVC development that feels or reads a like spending time with another developer at a whiteboard. It too provides a great overview of concepts and also addresses WHY the ASP.NET MVC Framework does things the way it does. Furthermore, to help drive abstract concepts home with concrete examples, “ASP.NET MVC In Action” references an OSS sample application you can download and peruse as well, providing some great samples and practical examples.
Though the distinction between teaching and reference'material within “ASP.NET MVC In Action” isn't as clear-cut as in Sanderson's book, “ASP.NET MVC In Action” still manages to kill both birds with the same stone. Once the introductory chapters are out of the way, “ASP.NET MVC In Action” delves into a guided, hands-on, review of ASP.NET MVC Framework components and calls out pitfalls, best-practices, and reasoning/rationale behind why MVC applications work the way that they do. There are also some great sections covering best practices for building Models, Controllers, and Views, as well as addressing scalability concerns. An interesting section of the book also compares ASP.NET MVC to other MVC implementations (such as Ruby on Rails, etc.), calling out how and why the folks at Microsoft did things they way that they did.
If I had one complaint to make about this book it would be that it needs a chapter outlining MVC Contrib in more detail. I'm sure some people might balk about coverage of a third-party add on in a book about Microsoft's ASP.NET MVC Framework. But given how involved the authors are with MVC Contrib (and given how they point out ways that it solves common MVC problems) I think it would be a crime for the second edition of this book to omit a simple chapter showing how to get, install, and leverage MVC Contrib for development tasks because I think the authors are leaving a lot of value still on the table.
Other Books Abound
Both of these books are excellent - some of the best technical books I've ever read. And that's NOT just my zeal for ASP.NET MVC shining through. These books are both very well organized and written.
Of course, I'm sure some of the other books out there are great too. I just haven't had time to read them. But based upon some of the reviews on Amazon.com along with knowing about the authors of some of these other books, I'm sure that many of them would serve as a great way to get started with ASP.NET MVC development for the uninitiated.
The key take away though is that if you haven't taken the time to look into ASP.NET MVC development yet, you now have no excuse because there are now some excellent resources that you can easily tap to get started.