Tuesday, June 3, 2014

Comparing ASP.NET MVC tutorials: OdeToFood, Nerddinner, and MVC Music Store

I worked through three ASP.NET MVC tutorials: NerdDinner, OdeToFood, and MVC Music Store.  All had their pro's and con's, and I definitely learned much from them.  The pluralsight tutorial OdeToFood was, far and away, the best put together tutorial of the bunch, and if you had to pick one, that would be the one to do.  NerdDinner wasn't bad but is showing it's age as it was developed using MVC2 (though I thought I saw something about updates...). The MVC Music Store tutorial also had a lot of interesting stuff but I would have to consider it the weakest of these three tutorials.



NerdDinner



This tutorial is located on asp.net under MVC 2.0.  This is basically a blitz 80 minute tutorial video done in Visual Studio 2010, but it hits all the key points in .NET MVC. Some parts are kind of outdated but I was able to get everything working in VS2013.
  • Basic setup
  • ASPX views (I used Razor)
  • Linq to Sql, Database first
  • Model binding
  • Repository pattern for db access
  • Bing Maps (though I substituted Google Maps in my version), and the JavaScript to make it work
  • A couple unit tests - including fake db
  • Treating ajax calls differently in Actions
One complaint I have about this tutorial is that they do a LOT of handwaving. "I'm going to do blahblahblah" then boom, it's all magically there and it isn't explained.  Plus the RSVP part is completely skipped over...

I liked the generic interface for the database in OdeToFood a lot better than the way it is done in this tutorial, because the way it's done here requires an overload for every table. Not so bad when you only have two tables but it would make expansion a nightmare...

I took the liberty of implementing the RSVP part and making the links and markers act a little more like the way they show the finished NerdDinner site acting.  There is a lengthy written tutorial that probably covers that stuff, but I thought it would be more fun to "just do it". Ha! I should say that although the video is only 80 minutes, it will take much longer to complete the tutorial if you plan on actually implementing the site, simply because you have to keep pausing it to catch up your code (and a whole LOT longer if, like me, you stray off the path they beat for you to do things like, oh, using Google Maps API instead of Bing...).

Their code files are on codeplex: http://nerddinner.codeplex.com/
My version is on GitHub: https://github.com/sabotuer99/NerdDinner


OdeToFood


Not pretty but the functionality is there

This is the pluralsight.com MVC 4 tutorial. This tutorial is much more deep and deliberate than the
NerdDinner tutorial, with about 7½ hours of video. The following points are covered in the series:
  • Setting up the environment
  • Creating models, controllers, actions, views
  • Adding routes to the routing table
  • Using Razor in views, HTML Helpers, Model binding
  • Entity Framework: Code first, migrations, seeding database
  • JQuery to implement AJAX features (partial updates, autocomplete)
  • Forms Authentication, Roles, OAuth, Cross-site forgery prevention
  • Caching (settings, profiles)
  • Localization using resource files
  • Unit testing
  • Deployment
Their code files are on codeplex: https://odetofoodmvc4.codeplex.com
My version is on GitHub:  https://github.com/sabotuer99/flaming-octo-robot

This tutorial doesn't look as flashy as the NerdDinner tutorial, what with it's fancy map and all, but I got a lot out of this tutorial.  Demonstrating the generic DbContext interface for the repository was brilliant. They gave more than lip service to unit testing, and they covered the pitfalls of implementing caching. They walk you through pretty much everything, I didn't get that feeling of being left hanging like I did so often with NerdDinner.  Overall a very good tutorial.

One note with mine: it uses an Azure Sql server database (which will be gone by now), so make sure you update the default connection string in Web.config if you use my code...


MVC Music Store




This is the last of the three tutorials that I completed.  This is a written tutorial for ASP.NET MVC3.  As with the other two, though, I completed the tutorial using Visual Studio 2013 (the tutorial uses 2010), so there will be some difference between what I ultimately end up with and what the tutorial produces.

The tutorial covers the following features:
  • Entity Framework Code First
  • Model binding (though they had annotation issues...)
  • Strongly typed Razor views
  • Implementing a shopping cart!
  • Ajax, partial views
I ended up just using the default connections string rather than use the connection string they use, since it gave me problems (probably didn't have the same version of SQL Server installed...)

This tutorial uses the Web Configuration Tool, which is deprecated in VS 2013, so getting the users and roles set up was... an adventure.  After several hours and much frustration I managed to get some code put together that adds an "Administrator" user and puts that user in the "Administrator" role.

I did a number of small problems. On page 76 of the tutorial they show the "Album" class which has this annotation [Bind(Exclude = "AlbumId")] ... this will break the Edit action because it won't bind AlbumId to the model passed back by the post and you'll get the error below.  Also, sometimes they are a bit flakey about what they want the application to do... like do you want to go back to store browse after I add an item to my cart, or go look at my cart summary?

Optimistic Concurrency Exception
Kinda hard to find the entity to update without the Id...

One BIG problem I had with this tutorial is that it covered nothing on unit testing.  Even NerdDinner at least gave unit testing some lip service, and both NerdDinner and OdeToFood implemented a repository pattern for data access to make unit testing with fakes easy.  I was pretty disappointed in that aspect of this tutorial.

Their code files are on codeplex: http://mvcmusicstore.codeplex.com/
My version is on GitHub:  https://github.com/sabotuer99/MVCMusicStore

No comments:

Post a Comment