There's always a splurge of new books that come out around the RTM of any new ASP.NET related technology. Authors all over the place are burning the midnight oil, cursing the changes from one CTP to the next, through to Betas and hoping against hope that the Release Candidates and final RTMs aren't stuffed with "breaking changes" which inevitably mean total rewrites of whole sections or chapters in their draft. And then the race between the publishers is on, as each tries to get their offer to market before the others. Here, I look at three of the titles that were published around the time that ASP.NET MVC was launched, and give my judgement on how they fare in covering not only the core Framework but the key features that ASP.NET MVC is designed to offer:
Rob Conery, Scott Hanselman, Phil Haack, Scott Guthrie
WROX, ISBN 978-0-470-38461-9
Code Samples in C#
Hmmm. The Four Foreheads.
Conery, Hanselman and Haack are all senior figures within the ASP.NET team at Microsoft. Scott ("The Gu") Guthrie is the second most influential person in popular 21st century culture (after Simon Cowell), judging by the number of "Awesome!! You rock, Scott!!!" comments his every blog utterance attracts. He also "builds a few products for Microsoft". It says something about the perceived importance of the MVC Framework within Microsoft's Developer Division (which Scott Guthrie actually runs), that these four people should author a book, and then not publish it through Microsoft Press.
The book is split across two sections. The first section (Chapter 1), runs for 164 pages, and consists of an end-to-end walkthrough showing how to use the new Framework to build an application - NerdDinner. It's a relatively simple application but it features the kinds of CRUD scenarios that are most commonly found in web applications, and other features such as AJAX with ASP.NET MVC and Authentication/Authorisation. It serves its primary purpose of introducing the MVC Framework, and provides a good all round insight into this style of web development. The second section of the book comprises a further 11 chapters - each of which examines aspects of the ASP.NET MVC Framework in more detail.
I cheated a little bit with this book. I had already taken advantage of the PDF version of the first chapter that was made freely available a while before the book was finally published, so when I received the book itself, I turned straight to Chapter 2, which is about half way through the book. It contains a very interesting overview of MVC as an architectural pattern, and looks at its evolution within web development. Chapter 3 appraises ASP.NET Web Forms (candidly) and establishes the reason for introducing an MVC Framework under the ASP.NET banner. These two chapters had me completely hooked. Immensely readable and informative, the third (and subsequent) chapters feature a number of insets: Product Team Asides. In these, the thinking behind the design of the ASP.NET MVC Framework is divulged, including explanations of decisions that were made during development. Subsequent chapters give good coverage to Routing, Controllers, Views, AJAX, Filters and Security. A briefish look at Test Driven Development and Testable Design Patterns is provided and the book is wound up by a chapter on mingling Web Forms and MVC.
The practical introduction to ASP.NET MVC in the form of the NerdDinner chapter is extensive and informative. On its own, it covers a lot of the information you would expect to find in a "Beginning ASP.NET MVC" type of book. Despite that, this book is not intended to serve the purposes of those completely new to ASP.NET or web development. You will need to be familiar with web development of some kind, and practiced at C# - or willing to do a lot of reference look-ups while going through this book. The second half of the book provides a very useful reference, as well as guidance on more advanced topics.
All in all, this book is worth getting. It's clearly structured, well written and does the job it intends to. It covers the core framework well and also clean separation of concerns. While extensibility and testability were covered, ideally I felt that more could have been done in these areas.
Nick Beradi, Al Katawazi, Marco Bellinaso
WROX, ISBN 978-0-470-4105-0
Code Samples in C#
The original idea behind the "Problem - Design - Solution" series, which first appeared in 2002, was to move away from the typical reference-style of programming book, and to show developers with some experience of the ASP.NET Framework how to structure and implement an application using a Best Practices approach to ensure separation of concerns. It was updated in 2006 following the launch of Version 2.0 of the Framework, and introduced a large number of the new features that version brought to the party. It has been updated again since then to take in version 3.5.
The series centres around developing the BeerHouse application, which is available from CodePlex. The application contains a range of features that could appear in any "real-world" site, including user membership, content management, polls, comments, newsletter management and generation, localisation and e-commerce. For web forms developers looking to improve their development skills beyond a two-layer approach that involves much use of Code-Behind, this series has established itself as invaluable. The second book in the series is one of the more thoroughly thumbed tomes in my personal collection, and I would say that this book did more for me in terms of understanding how to separate the various layers in my applications than any other resource.
The MVC version follows the same pattern as its predecessors, and demonstrates a rewrite of the BeerHouse application using the MVC Framework. As with previous versions in the series, each element of the application is broken down into a Problem Statement, followed by an examination of the application Design considerations that the Problem introduces, and finally the code, or Solution that was implemented. That, unfortunately, is as far as any similarity with the previous books go.
Coverage of the MVC Framework as a development technology is pretty superficial, in my opinion, and indeed the authors refer readers to MSDN or a reference type book for more detail too often. So, the book is not intended to teach you the MVC Framework. Ok - maybe the book is intended to be a guide to Best Practice when using ASP.NET MVC in real world applications? Indeed, as part of the introduction, the authors claim that "you will have learned many of the best practices for web development, based on a solid, scalable, and extensible architecture" by the time you have reached the end of the book. Most commentators on Best Practice for ASP.NET MVC strongly advocate a TDD approach to development, or Unit Testing at the very least. This book ignores both. You will not learn how to implement any kind of testing framework at all. How about a true separation of concerns? Unfortunately, any hope I had that the book might help in this direction was blown out of the water when I downloaded the sample application. One of the Views (Article/Index) contains a call to the DataContext, and one of the PartialViews includes Code-Behind. Beyond that, the Model is exposed directly to the Controllers, with calls to the DataContext inside the Actions. this hardly fits in with the notion of a "clean" separation of concerns.
There are a number of technical and factual inaccuracies throughout the book. The authors refer to the Html and Url extension classes. They are in fact extension methods. According to the authors, the ASP.NET 3.5 team introduced the Provider model, and Profiles. They were actually introduced in version 2.0. ALT.NET is offered as a process by which you can develop your Model. It's actually not a process at all. It's a movement, if anything, that shares a set of beliefs. While most of us know that interfaces are implemented by a class, the authors will have you believe that classes inherit from interfaces. Oh - and did you know the GridView is obselete? No? Nor did I. But on page 143, I find the following:
"You may notice in this code that we are using plain old tables to show our data, This is because the GridView control that we have used so frequently in ASP.NET 2.0 is now obselete."
Individually, these errors would probably not merit a mention. However the sheer number of them (and there are more than the ones I highlighted) shakes my confidence in the technical accuaracy of the book as a whole. Another aspect of the book that left me feeling underwhelmed is the fact that large chunks of the 2.0 version of the book have been copied and pasted directly into the MVC version. However, not enough care was given to reviewing and amending the copied parts. For example, in both the Opinion Polls section and the Forums section, the LINQ queries that are used to access the database are introduced as "Stored Procedures". The text introducing them is identical to the 2.0 version of the book, but there are no stored procedures in the MVC application. I cannot understand why, in the Chapter on Localisation, the Recap of Localization in ASP.NET 1.x was retained from the 2.0 version of the book. Given that 2.0 has been with us since 2005, it seems utterly irrelevant.
Given the heritage of the Problem - Design - Solution series of books, I was keen to find something positive to say about this title. But the more I looked, the more I got irritated by it (especially with the continual reference to Partial Views as "User Controls"), and even started to feel a little cheated. I could be forgiven for thinking that the new authors wanted to do as little as possible in terms of having to re-write Marco Bellinaso's original passages. I also suspect that Bellinaso's only contribution to the book, despite appearing on the cover as one of the authors, was to allow so much of his earlier work to be re-used. This may be why he is alone in not producing anything in the Acknowledgements section at the beginning of the book. If you are looking for a book to get you started with ASP.NET MVC, this one is too shallow on the technology to merit consideration. If you are looking for something to guide you towards Best Practice, this book doesn't offer anything in that direction either.
In summary, coverage of the core elements of the Framework is thin, and extensibility, testability and clean separation of concerns are ignored.
Apress, ISBN 978-1-4302-1007-8
Code Samples in C#
This book follows a similar format to the Four Foreheads' offering, in that it begins with a number of chapters (spreading over 120 pages) that walk through building a real-world application using MVC, to introduce many of the features that come with the new Framework, and then follows this up with indepth coverage of specific areas - Routing, Views, Controllers, Ajax, Security, Deployment and the crossover between Web Forms and MVC. Where it differs significantly from the Four Foreheads is that Test Driven Development and design patterns are covered in significant detail from the off.
ASP.NET MVC is likely to introduce Test Driven Development, Inversion of Control and other design patterns to a new audience who up till now have not appreciated what they are all about. Sanderson makes these topics extraordinarily accessible through the clear way in which he explains them, and the way he integrates them into the sample application. The application (SportsStore in this case) makes use of NUnit and Moq for test, and Castle Windsor as an Inversion of Control container. Sanderson is also aware that TDD is not going to be right for everyone, and took the trouble to separate the commentary on testing from the actual development side of SportsStore by placing it in separate panels. The sample application is not intended to be "demo-ware", according to Sanderson. He deliberately sets out to establish through the application, a sound architecture and many modern best practices. The result is not as fully-featured as the BeerHouse, but this is the approach that I kind of expected Beradi and Katawazi to have taken.
Sanderson prefaces the walk through with a chapter called "Prerequisites". In this, he does an excellent job of introducing the C# 3.0 language features that are important to ASP.NET MVC, and also does another outstanding job of simplifying LINQ to SQL, which he then uses as his Data Access technology. During the subsequent chapters that examine core aspects of the Framework, Sanderson provides a lot more information than the Foreheads. What he does is focus on the first of the tenets listed above, and show how the Framework can be extended. For instance, in his coverage of Controllers, he shows how to extend the ActionResult type to produce a custom WaterMarkedImageResult, as well as how to create your own ControllerFactory. Within the chapter on Views, he discusses and illustrates implementing your own View Engine, and he looks at some features outside of the core Framework, such as the MVC Futures and MvcContrib. The chapter on Deployment was particularly useful to me in helping towards a smooth transition from my old Web Forms-based site to this version, hosted on IIS 6.
Steven Sanderson has a a very comfortable writing style. His tone is quite conversational, and his sense of humour is apparent throughout the book. And it's a genuinely warm, understated sense of humour - he avoids that kind of "Geek Humor" that besets programming books these days. His obvious depth of knowledge on his subject matter and passion for it come across fluidly, and I always had the feeling that he was acting as my personal mentor, as opposed to lecturing me.
Sanserson's book is head and shoulders above the others in many ways, especially the most important one - the coverage he gives to the elements I am measuring each book by. His coverage of the core elements of the framework is outstanding. His frequent examples on extending the framework and his inclusion of testing as part of the sample application along with use of an Inversion of Control container means that this book wins hands down.
This is apparently Steven's first programming book. I'm certain it won't be his last.
I really enjoyed reading the book by Conery, Hanselman, Haack and Guthrie. I found the insights they gave into the product team's thinking very interesting. On its own this book would get me started with ASP.NET MVC quite nicely. I will certainly be picking it up again from time to time to review their take on certain aspects of the framework. Unfortunately, I cannot think of one good reason to take the "Problem - Design - Solution" book off my shelf again. I find it hard to describe just how disappointed I was in this book. Finally, I will have difficulty in retrieving Steven Sanderson's volume from my shelf. That's because it is unlikely to be there. I will have to hunt the desks of the other developers late at night to get it back off them. Or buy them each a copy. But this book is so good, it will be worth it.
Monday, July 27, 2009 1:25 PM
Last Updated: Friday, October 10, 2014 9:19 PM
Posted by: Mikesdotnetting
Total Views to date: 51979
Unfortunately, something went wrong and your message or comments have not been submitted successfully. I'll try to fix whatever the problem is as soon as I can.
Thanks for you comments. They have been successfully sent to me. I will try to respond if necessary as soon as I can.