Book Review: 20 Recipes for Programming MVC 3

No Comments

I was excited about the opportunity to read and review the book “20 Recipes for Programming MVC 3″. I was hoping for some great programming gems that combined my love of Mvc programming with patterns. This book fell far short of my expectations. The first chapter discusses the use of the Authorize attribute and the out of the box FormsAuthentication security that comes with the default Mvc projects. Somewhat disappointed I pressed on, thinking this may be a good book for someone new to Mvc programming.

Chapter two discusses creating Controllers and View from the Visual Studio context menus, with a brief example that uses Entity Framework. Chapter three covers data annotation attributes and even creates a sample validation attribute.

It was in chapter four, Implementing Multiple Languages, that I started having doubts about the book for the novice Mvc developer. First off, the author uses the ViewBag property exclusively. The current practice in Mvc programming is to use strongly typed View Models. It’s my belief that using ViewBag is a poor programming practice. Second, I don’t agree with the multi-language approach presented by the book. The application itself sets the culture in the thread. The better approach is to let the browser indicate which language the user prefers. No extra code in your application (or web site) is required.

In the fifth chapter the author discusses sending emails from your Mvc application. I was disappointed that he did not create an email service that implements a simple email interface. Chapter six covers adding the ability for users to retrieve their account password. I was happy to see the use of a view model here, but disappointed that solution presented is not as safe as it should be. If a user enters an email address that is not in the database, the user is returned to the form. Instead good practice dictates the user should be presented with a page indicating the password was sent to the email address entered in the previous form.

The next several chapters begin an exercise in sorting, paging, and filtering a list of records. The recipe presented does not provide SEO friendly URLs. Using the code in the book your web site would have URLs like the following, http://www.erictopia.com/books?sortOrder=Title&page=2, instead of something more SEO friendly like http://www.erictopia.com/books/sort/title/2. There are no strongly typed views presented in these chapters. The views are derived from PagedList with additional view data in the ViewBag property.

Chapter 10 introduces searching without the use of the jQuery autocomplete plugin. A great Mvc 3 recipe would have been how to integrate the fore mentioned jQuery plugin into the web site/application for searching.

Chapter 11 discusses uploading a file from a form. At the most basic level the chapter presents some decent information. I would have been happier if it had first created a FileSystem interface for storing files. In chapter 12 the author introduces thumbnail creation for your uploaded files. Too bad the solution does not maintain aspect ratios in the thumbnail creation process. He also goes through a long process for creating the thumbnail instead of using Image.GetThumbnailImage.

In chapter 13 we get into Ajax calls, using the Ajax class which in turn uses the Microsoft Ajax script libraries. Does anyone use those anymore? It would have been better if the examples used jQuery and showed how to unobtrusively convert these links to ajax. Chapter 14 adds ajax to forms. Once again, using jQuery would have been the preferred method.

The Microsoft Web Helpers are introduced in chapter 15, specifically the CAPTCHA helper. Mobile views are presented in chapter 16. I am not convinced that the same view should be used for desktop and mobile browsers. Chapter 17 was probably my favorite of all the chapters in this book. It’s on asynchronous controllers, something I haven’t done any research. This may be a good start on learning about asynchronous controllers.

We see the jQuery Autocomplete plugin covered in chapter 18. This is something that should have been in chapter 10. Here the author makes a case for placing all records into the web page if the number of records is 40,000 or less. I have always triggered the autocomplete on a minimum of three characters and had the controller method return a maximum of 10 or so records. It may be worth an investigation one of these days.

Routing is covered in chapter 19 and caching in chapter 20. The first routing example is very well done and would most likely be of use to most Mvc developers.  The second example, not so much, as it pulls routing information from the sub-domain of the url. The chapter on caching does a very good job of introducing Mvc caching and database caching.

Overall I was disappointed in the book. There are some good items in the book, if you know what to look for.  Unfortunately, this book is an introductory book and those most interested in the information won’t know enough to tell the good from the bad. I would give this book one star.

Rating Scale

4 stars – Excellent book from cover to cover, should definitely be in your library.

3 stars – Has some really good chapters and information, not much fluff or bad content

2 stars -The amount of useful content is roughly equal the un-useful content. Recommended only if you’re looking for information contained in the useful sections of the book.

1 star – Contains some good information if you know where to look, more bad or misleading content than good

0 stars – Plain o sucks, not worth the bits to store it on your Nook, Kindle, etc.


Kick It on DotNetKicks.com
Digg This
Reddit This
Stumble Now!
Buzz This
Vote on DZone
Share on Facebook
Bookmark this on Delicious
Kick It on DotNetKicks.com
Shout it
Share on LinkedIn
Bookmark this on Technorati
Post on Twitter
Google Buzz (aka. Google Reader)

Leave a Reply

Comment moderation is enabled. Your comment may take some time to appear.