Feb 03, 2011
Persistance of Shopping Cart
As others before me I also would like some verification on the process of saving a cart - as I'm trying to implement some best practices in my development - and I stall over how I "should" be doing things.
If I were to venture a guess - I would pass the entire shopping cart & user back - and then just persist each item. But my feeling and ignorance are telling me I'm missing something. And then I get more insecure about the approach once we allow for updating of said orders.
The cart app isn't a perfect example - but let's say it was a recipe catalog - as they are similar. I can create and save a recipe. Then as I refine my recipe (at a later date) I can add/remove/update various ingredients. Would it be a better approach to persist each ingredient to the DB as it happens? Or to work with the recipe - and save it only at one time?
If I persist as it happens - there's no "undo" capability. Which would lead me to doing it all in the recipe "Save" type method. But if that's the case - what would be a good ("best practice"?) approach to updating some ingredients, creating others, and removing non-existant ones in one process? It seems to me that you could easily run into a number of DB calls. Is that just the inevitability of it all?
I'm sure I'm missing the obvious, or over-reading into things - and would really appreciate any sort of slap in the head to snap me out of this!