﻿<?xml version="1.0" encoding="utf-8"?><rss version="2.0"><channel><title>Ayende @ Rahien</title><link>http://ayende.com</link><description>Ayende @ Rahien</description><copyright>Copyright (C) Ayende Rahien  2004 - 2021 (c) 2026</copyright><ttl>60</ttl><item><title>Ayende Rahien commented on Porting the MVC Music Store to Raven: ShoppingCartController</title><description>cart.GetCount() was a database query, _very_ expensive.
  
I don't care about the actual impl detail, I care about whatever this is an in memory operation or a remote operation
</description><link>http://ayende.com/4526/porting-the-mvc-music-store-to-raven-shoppingcartcontroller#comment15</link><guid>http://ayende.com/4526/porting-the-mvc-music-store-to-raven-shoppingcartcontroller#comment15</guid><pubDate>Sun, 30 May 2010 17:26:29 GMT</pubDate></item><item><title>Michael Valenty commented on Porting the MVC Music Store to Raven: ShoppingCartController</title><description>Why would you prefer cart.Lines.Count over cart.GetCount()? cart.Lines.Count is a Law of Demeter violation. You don't encapsulate the logic that @David pointed out should actually be cart.Sum(x =&gt; x.Quantity). Maybe it should be a property to suggest it's not an expensive operation, but it seems like it's something the cart should own.
</description><link>http://ayende.com/4526/porting-the-mvc-music-store-to-raven-shoppingcartcontroller#comment14</link><guid>http://ayende.com/4526/porting-the-mvc-music-store-to-raven-shoppingcartcontroller#comment14</guid><pubDate>Sun, 30 May 2010 15:33:01 GMT</pubDate></item><item><title>Michel commented on Porting the MVC Music Store to Raven: ShoppingCartController</title><description>For the DeleteId value, HTML id can't start with a number (
[http://validator.w3.org/docs/errors.html#ve-122](http://validator.w3.org/docs/errors.html#ve-122)). So instead of returning the number part of the id, you should return the full id minus the "/" : DeleteId = id.Replace('/', string.Empty)
</description><link>http://ayende.com/4526/porting-the-mvc-music-store-to-raven-shoppingcartcontroller#comment13</link><guid>http://ayende.com/4526/porting-the-mvc-music-store-to-raven-shoppingcartcontroller#comment13</guid><pubDate>Thu, 27 May 2010 21:36:05 GMT</pubDate></item><item><title>Harry Steinhilber commented on Porting the MVC Music Store to Raven: ShoppingCartController</title><description>@Michael, 
  
The point was that ShoppingCart.AddToCart() does not contain any data access. The data access is in the ShoppingCartController.AddToCart(). In the original version, the data access was in the business object instead of the controller.
</description><link>http://ayende.com/4526/porting-the-mvc-music-store-to-raven-shoppingcartcontroller#comment12</link><guid>http://ayende.com/4526/porting-the-mvc-music-store-to-raven-shoppingcartcontroller#comment12</guid><pubDate>Thu, 27 May 2010 19:06:48 GMT</pubDate></item><item><title>Michael Teper commented on Porting the MVC Music Store to Raven: ShoppingCartController</title><description>Ayende, Kiliman, you are both right,  I missed the ShoppingCart reference. Thanks!
</description><link>http://ayende.com/4526/porting-the-mvc-music-store-to-raven-shoppingcartcontroller#comment11</link><guid>http://ayende.com/4526/porting-the-mvc-music-store-to-raven-shoppingcartcontroller#comment11</guid><pubDate>Thu, 27 May 2010 18:56:44 GMT</pubDate></item><item><title>Kiliman commented on Porting the MVC Music Store to Raven: ShoppingCartController</title><description>Oops... sorry for the double post. I didn't expect Ayende to moderate my comment so quickly. Thanks!
</description><link>http://ayende.com/4526/porting-the-mvc-music-store-to-raven-shoppingcartcontroller#comment10</link><guid>http://ayende.com/4526/porting-the-mvc-music-store-to-raven-shoppingcartcontroller#comment10</guid><pubDate>Thu, 27 May 2010 18:53:53 GMT</pubDate></item><item><title>Ayende Rahien commented on Porting the MVC Music Store to Raven: ShoppingCartController</title><description>Michael,
  
Sure it is, but it is not in the shopping cart code
</description><link>http://ayende.com/4526/porting-the-mvc-music-store-to-raven-shoppingcartcontroller#comment9</link><guid>http://ayende.com/4526/porting-the-mvc-music-store-to-raven-shoppingcartcontroller#comment9</guid><pubDate>Thu, 27 May 2010 18:53:21 GMT</pubDate></item><item><title>Ayende Rahien commented on Porting the MVC Music Store to Raven: ShoppingCartController</title><description>Json,
  
Post/redirect/get is much better option, sure.
</description><link>http://ayende.com/4526/porting-the-mvc-music-store-to-raven-shoppingcartcontroller#comment8</link><guid>http://ayende.com/4526/porting-the-mvc-music-store-to-raven-shoppingcartcontroller#comment8</guid><pubDate>Thu, 27 May 2010 18:52:01 GMT</pubDate></item><item><title>Kiliman commented on Porting the MVC Music Store to Raven: ShoppingCartController</title><description>@Michael, I believe he's means the ShoppingCart model does not include any data access code. 
  
  
See his previous post: "Porting the MVC Music Store to Raven: ShoppingCart" (sorry, edited due to link being consider spam.. ugh!)
  
  
The calling code, in this case the controller, is responsible for loading and persisting the model.
  
  
I suppose you could add another level of abstraction by introducing a ShoppingCartService that managed the data access instead of the controller, but for a simple application, this is probably overkill.
  
  
</description><link>http://ayende.com/4526/porting-the-mvc-music-store-to-raven-shoppingcartcontroller#comment7</link><guid>http://ayende.com/4526/porting-the-mvc-music-store-to-raven-shoppingcartcontroller#comment7</guid><pubDate>Thu, 27 May 2010 18:51:16 GMT</pubDate></item><item><title>Ayende Rahien commented on Porting the MVC Music Store to Raven: ShoppingCartController</title><description>David,
  
You are correct
</description><link>http://ayende.com/4526/porting-the-mvc-music-store-to-raven-shoppingcartcontroller#comment6</link><guid>http://ayende.com/4526/porting-the-mvc-music-store-to-raven-shoppingcartcontroller#comment6</guid><pubDate>Thu, 27 May 2010 18:51:12 GMT</pubDate></item><item><title>Michael Teper commented on Porting the MVC Music Store to Raven: ShoppingCartController</title><description>Ugn, subtext ate the generic part. Here's what I meant:
  
Wouldn't session.Load&lt;Album&gt;(id) call be data access?
</description><link>http://ayende.com/4526/porting-the-mvc-music-store-to-raven-shoppingcartcontroller#comment5</link><guid>http://ayende.com/4526/porting-the-mvc-music-store-to-raven-shoppingcartcontroller#comment5</guid><pubDate>Thu, 27 May 2010 18:17:37 GMT</pubDate></item><item><title>Michael Teper commented on Porting the MVC Music Store to Raven: ShoppingCartController</title><description>Wouldn't session.Load
&lt;album(id) call be data access?
&gt;</description><link>http://ayende.com/4526/porting-the-mvc-music-store-to-raven-shoppingcartcontroller#comment4</link><guid>http://ayende.com/4526/porting-the-mvc-music-store-to-raven-shoppingcartcontroller#comment4</guid><pubDate>Thu, 27 May 2010 18:16:35 GMT</pubDate></item><item><title>josh commented on Porting the MVC Music Store to Raven: ShoppingCartController</title><description>@David Depends on what you are intending to show. The line count or the total item count.
</description><link>http://ayende.com/4526/porting-the-mvc-music-store-to-raven-shoppingcartcontroller#comment3</link><guid>http://ayende.com/4526/porting-the-mvc-music-store-to-raven-shoppingcartcontroller#comment3</guid><pubDate>Thu, 27 May 2010 16:40:43 GMT</pubDate></item><item><title>Jason Meckley commented on Porting the MVC Music Store to Raven: ShoppingCartController</title><description>an approach I use with controller's is post-redirect-get for commands. by managing transactions (SaveChanges) from a Filter there is no need to call session.SaveChanges() in the action. you also avoid the "resend post data" if the user refreshes the page.
  
  
in this series you are only porting the data access, so keeping the controllers as similar as possible makes sense.
  
  
What are your thoughts?
</description><link>http://ayende.com/4526/porting-the-mvc-music-store-to-raven-shoppingcartcontroller#comment2</link><guid>http://ayende.com/4526/porting-the-mvc-music-store-to-raven-shoppingcartcontroller#comment2</guid><pubDate>Thu, 27 May 2010 16:21:19 GMT</pubDate></item><item><title>David Thibault commented on Porting the MVC Music Store to Raven: ShoppingCartController</title><description>I believe that shoppingCart.Lines.Count should be shoppingCart.Lines.Sum(x =&gt; x.Quantity)
  
  
However I did not look at the original code so it may be correct.
</description><link>http://ayende.com/4526/porting-the-mvc-music-store-to-raven-shoppingcartcontroller#comment1</link><guid>http://ayende.com/4526/porting-the-mvc-music-store-to-raven-shoppingcartcontroller#comment1</guid><pubDate>Thu, 27 May 2010 15:57:12 GMT</pubDate></item></channel></rss>