Monday, March 1, 2010

Book Review: ASP.NET MVC Framework Unleashed

I just finished reading ASP.NET MVC Framework Unleased by Stephen Walther.  It was an extremely fast read: I finished it in a little under two weeks.  Unfortunately, I was able to finish it so quickly because it contained very little information.  I was rather disappointed by the content.  I really don't like giving bad reviews, but I feel like I should get my thoughts down for other folks who may be interested in this topic.  Please note, this is a review of the book itself, not the underlying ASP.NET MVC technology.

Beginner, Intermediate, or Advanced?
My biggest problem with Unleashed is that it cannot decide what level it is targeted at.  The cover lists it as "User Level: Intermediate-Advanced," but the actual content seems to jump from one level to another.  For example, there are step-by-step instructions on configuring and using the ASP.NET Membership Database (ASPNETDB.mdf).  I would consider this to be "beginner" level content.  For the majority of real-world applications, you will not use the ASPNETDB.mdf database for your user authentication / authorization, instead going for a more robust security model such as implementing a custom MembershipProvider.  This is not covered, however.

But the text does not qualify as Intermediate or Advanced as there is very little actual content.  The majority of the book is code samples.  Code samples are generally a good thing, but the code samples here are full-files.  This means that when looking at the various elements (such as Views and Controllers), you end up seeing the same "boiler-plate" code over and over again.  Many times there are only a few unique lines of code in a 30 line listing.  In addition, descriptions of the code samples are limited to a paragraph or two with no in-depth description of the concepts at hand.  This is combined with listings in both C# and VB (again, not necessarily a bad thing).  I often felt like I was "skimming" a 30 page chapter in just 10 minutes or so due to the use of code samples and lack of description.

As a final example, there are 2 chapters devoted to AJAX and jQuery.  In the introduction to the book, the author assumes that the reader is familiar with HTML and .NET (either C# or VB).  However, it does not mention AJAX or jQuery as pre-requisites.  AJAX is used much differently in ASP.NET MVC than it is in Web Forms, yet there is no discussion of those differences.  There is just a handful of samples with little explanation.

Lack of Focus
Another problem is the lack of focus.  ASP.NET MVC has many unique features, but many of the concepts are shared with ASP.NET Web Forms and the .NET framework at large.  I wanted the book to focus on the concepts that differ from non-ASP.NET MVC applications, but there was a lot of overlap.

To expand on the example above (the Membership database), the security concepts (users, roles, principles, etc.) are the same as ASP.NET Web Forms applications, but there were several large sections dedicated to authentication.  And as noted above, this was only at the "beginner" level and did not touch on intermediate or advanced topics.

As another example, Unleashed spends a lot of time with the Entity Framework.  There are step-by-step instructions on creating a SQL Express database and setting up Entity Framework entities.  In addition, it also spends a bit of time talking about the Repository pattern and Service layers of the application.  These all related to the "M" (Model) of MVC.  But the point of the "M" is that you can implement your model in an infinite number of ways.  Again, this may be appropriate for a "beginner" level book, but it should go beyond merely mentioning other options if it is trying to be something more.

Ironically, I think that the topic covered best by this book is Test Driven Development (TDD).  Throughout the text, there is a focus on the "Red / Green / Refactor" methodology of TDD.  And the final part of the book (6 chapters on building a sample application) is a very good walkthrough of using the test-first method to fulfill the use cases.  Had this book been called Test Driven Development with ASP.NET MVC, I would probably give this book a much better review.

Summary
Ultimately, the only reason that I was able to follow this book is because I went through ASP.NET MVC training.  But the reason that I purchased the book was so that I could have a reference with more detail.  As an example, I was looking for details on HTML Helpers, both the helpers "in the box" and custom helpers.  The book has a few mentions of the existing helpers, but does not go into any detail on the options and parameters available.  As for creating custom helpers, there is an example of it, but nothing much beyond the sample code.

I really don't like giving bad reviews.  I realize that putting any technical book together is a lot of work.  However, technical books are also my life-blood.  They are my primary source of in-depth learning.  In addition, they are quite expensive.  I do have enough information to complete my project (which was the primary goal of training + book), but I'm still looking for a good reference book.  Since ASP.NET MVC version 2 is just around the corner (releasing with .NET 4.0 in April), I'll probably hold out before purchasing another.

In working with ASP.NET MVC, I'm becoming a fan of it.  So, I'll be posting more about the technology topic in the future.  I'll also keep you informed of other useful resources that I run across.

[Update: I have found a good book on this topic: Pro ASP.NET MVC 4 by Adam Freeman. You can see my review here: Book Review: Pro ASP.NET MVC 4.]

Happy Coding!

Tuesday, February 23, 2010

New to Me: ASP.NET MVC

ASP.NET MVC was New 18 Months Ago
I first heard about ASP.NET MVC in October 2008 (at the VSLive! conference).  Scott Hanselman gave a keynote that presented an overview and announced the beta release.  At that point, it looked interesting, but with all of the new technologies that have been thrown at us over the last several years, I couldn't devote any time to look into it.  Plus, I was comfortable with WebForms, having spent the previous 3 years developing fairly significant web apps.

So, here we are a year and a half later.  I was struggling with a project at work.  I knew that I could accomplish the task with WebForms, but all of my UI designs that I had worked through on the whiteboard seemed to come out as a mess.  I had a nagging feeling that ASP.NET MVC was the solution to this problem.  I took some time to look into it some more, and it turns out that it was the right direction.

Why ASP.NET MVC was the Answer
My main problem is that I needed to present data to the user in a different format depending on the record type.  And I wouldn't know the record type until run time.  ASP.NET WebForms is a "page first" model.  This means that the user requests a particular page (through a URL).  The page is then processed on the server which then presents the output to the user.  ASP.NET MVC is an "action first" model.  This means that instead of requesting a physical page, the user requests an action (also through a URL).  This action is processed by a Controller.  In my situation, the Controller can instantiate the Model (from my business layer) and then, based on the record type, can present the specific View (aspx page) that is appropriate.

So, I've taken a crash course in ASP.NET MVC.  After going through some on-line training and working through a simple test app, I'm convinced that this is the right solution for this particular project.  The design is much cleaner and will be easier to maintain.

Resources
I was fortunate enough to win a 1-year subscription to the Pluralsight OnDemand! library.  In the library is a 10 hour on-line course for ASP.NET MVC, and I took a couple of days last week to go through it.  This was an excellent resource.  (If you are interested in trying Pluralsight OnDemand! yourself, just stop by the website; they offer 7-day trial subscriptions if you drop them a note.)

In addition, I picked up "ASP.NET MVC Framework Unleashed" by Stephen Walther as a printed reference.  I'm still working my way through the book, but I've found a lot of useful information so far.

More to Come
Stay tuned for more to come.  My project at work is still in progress.  I'll have a lot of learnings from it (as I do with most of my projects).  When I run across interesting items, good tips, and pitfalls, I'll be sure to post them here.

Happy Coding!

Wednesday, February 17, 2010

Jeremy on .NET Rocks! (sort of)

Okay, so now that I have your attention, I wasn't really on .NET Rocks!.  But Carl and Richard did read my e-mail on show #525.  Here's a link (if you're curious): .NET Rocks! Show #525.  You can skip ahead to about 4 minutes in.

And BTW, they are sending me a hoody.

Saturday, February 13, 2010

Quick Byte: Statement Lambdas

Overview
The first time I came across a lambda expression, I was perplexed.  I could tell that something important was going on, but I got stuck on the new syntax.  As I studied them some more, I had an "aha" moment, and it all clicked into place.  This is a brief runthrough of that process with statement lambdas.

Get It Here
You can get the walkthrough (just a short 3-page one) and sample code here: http://www.jeremybytes.com/Demos.aspx.

Direct Links:
PDF Walkthrough
Code Download

Let me know what you think.  If you find this useful (or not), drop me a note at feedback@jeremybytes.com.

Happy Coding!

Sunday, January 31, 2010

SoCal Code Camp

Thank you!

A big thank you to everyone who attended my sessions at the SoCal Code Camp.  I had a great time, and I hope that all of you did, too.

As a reminder, for all of my sessions: the slides, code samples, and walkthroughs are available here: http://www.jeremybytes.com/Demos.aspx.

Drop me a note if you had a chance to attend.  I'd love to hear what you thought.

Sunday, January 10, 2010

Introduction to XAML with WPF

(Editor's note: I will be presenting this topic at the SoCal Code Camp Jan 30 & 31, 2010.)

Overview
Understanding XAML (eXtensible Application Markup Language) is a key to creating the latest .NET user experiences in WPF and Silverlight. We will introduce the basic concepts around XAML and take a look at various features such as namespaces, elements, properties, events, attached properties and some basic layout. We’ll create a simple WPF application that covers these fundamentals. Although you will probably end up doing most of your UI design with a drag-and-drop tool such as Expression Blend, knowing the internals gives you a leg up in making the final tweaks to ensure an excellent user experience.

Get It Here
As mentioned in a previous post, the demos are now available in PDF form here: http://www.jeremybytes.com/Demos.aspx.

Direct Links:
PDF Walkthrough
Code Download

Happy coding!

Monday, January 4, 2010

Introduction to Data Templates and Value Converters in Silverlight 3

(Editor's note: I will be presenting this topic at the SoCal Code Camp Jan 30 & 31, 2010.)

Overview
Business applications are all about data, and laying out that data is critical to creating a good user experience. Fortunately, Silverlight 3 has several tools, including Data Templates and Value Converters, that make this easier for the business application developer to manage. Today, we'll take a look at consuming a WCF service and creating the layout of the data. By the time we're done, you should have a good understanding of the basics of Data Templates and Value Converters.

Get It Here
As mentioned in a previous post, the demos are now available in PDF form here: http://www.jeremybytes.com/Demos.aspx.

Here's some direct links:
PDF Walkthough
Code Download

Happy coding!