A few suggestions

May 18, 2010 at 4:09 AM
Edited May 18, 2010 at 7:36 AM

I started this in the review section, but it has size limits, and my post there looks somewhat crippled.

Here are the comments as I read through the manual...

1. It is touted as how to use the great new features in ASP.NET 4 - but I didn't come across much that couldn't be done in 3.5... True, EF data model has foreign keys and you use them occasionally (see item 6 below) - but I don't think you are mentioning them as new feature. Same for adding function to take advantage of stored procedure. Maybe there are some minor differences; but if I had a question "what can I do in .NET 4 that I couldn't before" - I would probably be underwhelmed.

2. Generally, I try not to use the companion code, but rather develop my own as I follow the manual (with exception of CSS and other web design features where I am a complete idiot). Here, it was quite difficult. For example (and there are many similar), on page 21, you write "In our site master page we’ll add a div for the left side column that will contain our product category menu". Add where? Does it matter? Is it really "adding", or in fact replacing something existing with code snippet? Yes, one can always cheat and look at the companion code - but it takes away from the quality of the tutorial.

3. Similar, when you describe ListViews - the obvious first step is to drag a control from the tool box. So, I think it would be much more helpful if you started with whatever is possible to do in UI. Absent that - the only way is to just cut and paste your code into the project. Easy - but it doesn't teach the reader much! And there is a bigger problem. If you combine configuration and cut'n'pasting - you are very likely to get the following error:

Could not determine a MetaTable. A MetaTable could not be determined for the data source 'DataSourceNameHere' and one could not be inferred from the request URL. Make sure that the table is mapped to the dats source, or that the data source is configured with a valid context type and table name, or that the request is part of a registered DynamicDataRoute

Funny, that data is misspelled in the error message - but so be it. The reader stares at the code that is exactly like in the book and doesn't know what to do. Fortunately, there is a post that describes this problem.

4. Now, my biggest gripe. On page 35 you have the following code:

 

<a href='AddToCart.aspx?ProductID= <%# Eval("ProductID") %>' style="border: 0 none white">
<img id="Img1" src="~/Styles/Images/add_to_cart.gif" runat="server"
alt="" style="border-width: 0" />
</a>

 

In other words, you are adding an item to the cart in GET call. Isn't it against all that Tim Berners-Lee taught us?! One of my first long English words was idempotent :)

5. There are a few errors (a little bit too many for 84 pages). Most are typos (funniest is AJAC on page 66), but one can confuse the reader not familiar with partial classes! On pages 37-38 MyShoppingCart is in different namespaces (TailspinSpyworks and TailspinSpyworks.Classes). I don't think it will work!

6. Creating OrderDetail records on page 59. You probably have a reason to first select all cart records from the view, and then select the same records from the table in order to delete them. However, it is not obvious, and worth explaining. And aren't you only adding the first line from the cart by tinkering with i = 0 / if i < 1 / i++ What are the disadvantages of doing it in a more straightforward way?

 
//------------------------------------------------------------------------+
// Create a new OderDetail Record for each item in the Shopping Cart |
//------------------------------------------------------------------------+
var myCart = (from c in db.ShoppingCarts where c.CartID == UserName select c);

foreach (ShoppingCart item in myCart)
{
   OrderDetail od = new OrderDetail {
      OrderID = newOrder.OrderID,
      ProductID = item.ProductID,
      Quantity = item.Quantity,
      UnitCost = item.Product.UnitCost
   };
   db.OrderDetails.AddObject(od);

   db.DeleteObject(item);
}
db.SaveChanges();

7. Last (at least for today) Obviously, it's a matter of preference, but VS2010 project has jQuery preinstalled. AJAX library, apparently, requires separate download, or at least configuration. Doesn't it give a hint where Microsoft's direction is? Granted, you and ScottGu don't need such hints :) but the users are very good at reading the tea leaves! So, why not use the JavaScript library that owns the future?!

Coordinator
May 18, 2010 at 1:07 PM

Thanks

May 18, 2010 at 4:23 PM
Thank you for your analysis, virshu. For a beginner like me, it is very helpful to know some of the pitfalls of this tutorial. I agree that it needs to be polished and more thorough. Leaving spelling and other errors in it gives the impression that it's being done hurriedly or that little mistakes don't matter much.