PetShop Example Question

Posts   
 
    
Wade
User
Posts: 76
Joined: 15-Jun-2004
# Posted on: 19-Apr-2005 22:10:10   

I downloaded the example and was thinking about the way the CartManager and CartItemEntity is being used between the BL and the PL. On a shoppingcart.aspx page, would it be better to bind a WebGrid to the Cart.Items Collection and perform the additions, updates, and deletes then save upon leaving the page?

Thanks, Wade

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39749
Joined: 17-Aug-2003
# Posted on: 20-Apr-2005 11:12:21   

Wade wrote:

I downloaded the example and was thinking about the way the CartManager and CartItemEntity is being used between the BL and the PL. On a shoppingcart.aspx page, would it be better to bind a WebGrid to the Cart.Items Collection and perform the additions, updates, and deletes then save upon leaving the page?

the shopping cart is the thing I'm indeed not happy with as it is now, but I first had to port the complete code to see how it really worked. They had implemented it using their own horrible paging control so I had to convert that first. It can indeed be done better, I then have to re-implement the cart as it is now done in a cluttered way, though that's the way the petshop application is implemented by MS.

I'll see if it can be changed or if others have suggestions I'm all ears, but I'll do that after the release, as the whole petshop site in general is really not an example of great design (i.o.w.: should be re-done) and it's more an example how to use the various tiers.

Frans Bouma | Lead developer LLBLGen Pro
Wade
User
Posts: 76
Joined: 15-Jun-2004
# Posted on: 20-Apr-2005 17:10:03   

I guess my question to you is, would you recommend using a grid and binding to the collection for the shopping cart page?

Thanks, Wade

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39749
Joined: 17-Aug-2003
# Posted on: 20-Apr-2005 17:30:57   

Wade wrote:

I guess my question to you is, would you recommend using a grid and binding to the collection for the shopping cart page?

Thanks, Wade

I'm not sure, I think I won't recommend that, but I haven't given it much though. One of the things the current setup offers is that total calculations, i.e. cart management is not done in the code behind but in the cart. This means that when you bind a collection to a grid, you lose that. (I think).

Though the downside to that is that the gui gets clunky, you have to do a lot of things which could be solved by databinding. As the setup does work with a controller but not with a proper viewer, the MVC pattern implemented by Sun is a bit broken simple_smile

Frans Bouma | Lead developer LLBLGen Pro
Wade
User
Posts: 76
Joined: 15-Jun-2004
# Posted on: 20-Apr-2005 18:01:14   

Anyone else out there that has a good design for a shopping cart and using LLBLGen Pro? Would you care to share it with us?

Thanks, Wade sunglasses

Devildog74
User
Posts: 719
Joined: 04-Feb-2004
# Posted on: 20-Apr-2005 22:56:24   

I wouldnt use a grid because of the overhead in binding and viewstate. I would use a data list or template control. Chances are you wont need to sort a cart, page it. You would normally need access to a header section, a footer section, and the ability to make your rows into templates.

I would probably personally use a template control and bind to it, write my own pager, and write my own delete item, change quantity, and update total methods. You will find that the viewstate is much less using a template control and it binds faster when compared to a datagrid.

IMO, using a data grid is like using a Data Set. Its great for quick prototyping, but when you need a highly customizable interface and you need to consider load, and a production environment, there are more effecient ways.

I would probably persist the cart into the session object, or even a database table. The bad thing about a db table is that if the person leaves the store you will need to clean up the cart at some point, where the session is only there while the user is. The only potentially bad thing about the session is that it can eat memory under high loads and doesnt scale to web farms without some nasty url tricks. So if you have a fast db server, then saving the cart in the db is cool, plus users can come back to the cart before it gets cleaned up and use it again. All of the big ecommerce people have carts that live for a few days.

Thats my 2 cents or shopping carts.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39749
Joined: 17-Aug-2003
# Posted on: 21-Apr-2005 10:20:47   

The cart is stored in the session as well in the petshop app, the control over it is tucked away in a weird design (scattered around over 2 tiers).

After all: a shopping cart is not something related to the BL tier. It's USED by the BL tier, IMHO. I'll change that after release, at some point in time. simple_smile

Frans Bouma | Lead developer LLBLGen Pro
Rainbow
User
Posts: 29
Joined: 23-Feb-2004
# Posted on: 23-Apr-2005 00:03:47   

Congrats on the great work frans,

I look forward to the new and improved petshop but I'll definately look into the current one to see how you've used LLBLGen in an asp.net scenario.

Thanks,

John

Otis wrote:

The cart is stored in the session as well in the petshop app, the control over it is tucked away in a weird design (scattered around over 2 tiers).

After all: a shopping cart is not something related to the BL tier. It's USED by the BL tier, IMHO. I'll change that after release, at some point in time. simple_smile

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39749
Joined: 17-Aug-2003
# Posted on: 23-Apr-2005 13:27:45   

Thanks John. simple_smile

Well, the Petshop port is the first attempt, I'm sure it will mature in the future. It now works and I now understand what the app does when and where, so improvements can be made.

Frans Bouma | Lead developer LLBLGen Pro
Wade
User
Posts: 76
Joined: 15-Jun-2004
# Posted on: 26-Apr-2005 16:16:16   

One other question, in the new design of Petshop Cart do you plan to persist the shopping cart state to the database or just use it on a Session basis?

When a potential customer comes back, do you show their previous cart and items are do you start a new one?

Thanks, Wade

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39749
Joined: 17-Aug-2003
# Posted on: 26-Apr-2005 16:49:39   

Wade wrote:

One other question, in the new design of Petshop Cart do you plan to persist the shopping cart state to the database or just use it on a Session basis?

When a potential customer comes back, do you show their previous cart and items are do you start a new one?

Thanks, Wade

The whole petshop application as a shop is completely bogus. Its setup is actually very very simple, and not that useful for a realtime shop. There isn't a 'view order' page for example, a 'list of orders' for a user, and much more. Also, the cart is a point where you would want to start all over simple_smile

Though I think instead of making the petshop a killer shop application, it's better to spend that time to port more MS examples over to .NET, like the ASP.NET starter kits for example.

Frans Bouma | Lead developer LLBLGen Pro
steele
User
Posts: 4
Joined: 26-Apr-2005
# Posted on: 26-Apr-2005 20:48:46   

Otis wrote:

Though I think instead of making the petshop a killer shop application, it's better to spend that time to port more MS examples over to .NET, like the ASP.NET starter kits for example.

I have been messing around with the AdventureWorks2000 Sample DB and this is probably a good one since it contains lots of data for testing (for example 30,000 Addresses) as well as the OLAP stuff so you can see how that works as well.

I believe this is going to be replacing Northwind as the default sample in the upcoming SQL 2005 so it would be beneficial to create a stock sample from this data.

I am giving a talk on LLBLGen Pro to our local Users Group so I may be of some help here since I plan to use this for my demo in July.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39749
Joined: 17-Aug-2003
# Posted on: 26-Apr-2005 22:17:15   

steele wrote:

Otis wrote:

Though I think instead of making the petshop a killer shop application, it's better to spend that time to port more MS examples over to .NET, like the ASP.NET starter kits for example.

I have been messing around with the AdventureWorks2000 Sample DB and this is probably a good one since it contains lots of data for testing (for example 30,000 Addresses) as well as the OLAP stuff so you can see how that works as well.

I believe this is going to be replacing Northwind as the default sample in the upcoming SQL 2005 so it would be beneficial to create a stock sample from this data.

It indeed will replace northwind, I haven't seen adventureworks stuff, but it should be a good example. Other examples I'm thinking off are the timetracker and issuetracker starter kits.

I am giving a talk on LLBLGen Pro to our local Users Group so I may be of some help here since I plan to use this for my demo in July.

great! If you need anything, let me know.

Frans Bouma | Lead developer LLBLGen Pro